You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

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
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support