Special Stain Classifier

Weights for two whole-slide image (WSI) classification models that identify 14 special histological stain types. Released alongside the paper:

Efficient Special Stain Classification for Digital Pathology Oskar Thaeter et al. — TODO: venue/arXiv link

Code and usage instructions: oskarthaeter/efficient-special-stain-classification


Models

Both models use H0-mini (fine-tuned) as the ViT backbone, which produces a 1536-d class+mean feature. Inputs are normalised internally using H0-mini's statistics.

File Input Architecture
thumbnail_896x1792.pth 896 × 1792 px slide thumbnail H0-mini → MLP head → 14 classes
patch_40x_512px.pth 40× patches, 512 px → 224 px H0-mini → linear head → 14 classes, soft-voted

Classes

Alcian Blue, Prussian Blue, Giemsa, GMS, Congo Red, Von Kossa, Rhodanine, PAS, Reticulin, Van Gieson, Warthin-Starry, Ziehl-Neelsen, H&E-FFPE, H&E-FS


Usage

Install the inference code:

git clone https://github.com/oskarthaeter/efficient-special-stain-classification
cd efficient-special-stain-classification
pip install -r requirements.txt
python download_weights.py

Thumbnail pipeline:

from pathlib import Path
import torch
from pipelines.thumbnail import load_thumbnail_model, predict

model = load_thumbnail_model(Path("weights/thumbnail_896x1792.pth"))
model.to(torch.device("cuda" if torch.cuda.is_available() else "cpu"))

result = predict(Path("slide.svs"), model, device)
print(result["predicted_class"])  # e.g. "PAS"

Soft-voting (patch-level) pipeline — requires TRIDENT patch coordinates:

from pathlib import Path
import torch
from pipelines.soft_voting import load_patch_model, predict

model = load_patch_model(Path("weights/patch_40x_512px.pth"))
model.to(torch.device("cuda" if torch.cuda.is_available() else "cpu"))

result = predict(
    slide_path=Path("slide.svs"),
    h5_path=Path("trident_output/slide.h5"),
    model=model,
    device=device,
)
print(result["predicted_class"])

See the GitHub repository for full documentation.


Citation

@article{TODO,
  title   = {TODO},
  author  = {TODO},
  year    = {2026},
}

If you use the H0-mini backbone, please also cite:

@misc{filiot2025distillingfoundationmodelsrobust,
      title={Distilling foundation models for robust and efficient models in digital pathology}, 
      author={Alexandre Filiot and Nicolas Dop and Oussama Tchita and Auriane Riou and Thomas Peeters and Daria Valter and Marin Scalbert and Charlie Saillard and Geneviève Robin and Antoine Olivier},
      year={2025},
      eprint={2501.16239},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2501.16239}, 
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for oskarthaeter/special-stains

Finetuned
(1)
this model

Paper for oskarthaeter/special-stains