Instructions to use Rainy-fog/CerS-Path with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- timm
How to use Rainy-fog/CerS-Path with timm:
import timm model = timm.create_model("hf_hub:Rainy-fog/CerS-Path", pretrained=True) - Notebooks
- Google Colab
- Kaggle
CerS pathology encoders
Inference code and weights for three pathology patch encoders.
| Model name | Weight file | Feature dimension |
|---|---|---|
CerS-Path |
weights/CerS-Path.pth |
1024 |
CerS-PHIKON |
weights/CerS-PHIKON.pth |
768 |
CerS-CTrans |
weights/CerS-CTrans.pth |
768 |
Install
python -m pip install -r requirements.txt
Python usage
from PIL import Image
import torch
from cers_models import get_preprocess, load_model
device = "cuda" if torch.cuda.is_available() else "cpu"
model = load_model("CerS-Path", device=device)
preprocess = get_preprocess()
image = Image.open("example_patch.jpg").convert("RGB")
batch = preprocess(image).unsqueeze(0).to(device)
with torch.inference_mode():
features = model(batch)
print(features.shape)
Replace CerS-Path with CerS-PHIKON or CerS-CTrans to use another model.
Directory extraction
python extract_features.py \
--model CerS-PHIKON \
--input /path/to/patches \
--output outputs/features.pt \
--device cuda:0 \
--batch-size 128
The command saves a feature tensor (.pt) and a matching path index (.csv).
Verify
python verify_models.py --device cuda:0
sha256sum -c SHA256SUMS
For research use only; not for clinical diagnosis.
- Downloads last month
- -