You need to agree to share your Hugging Face 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.

TinyPath

TinyPath is a 103.6M-parameter Vision Transformer for H&E histopathology tiles. It was pruned from Prov-GigaPath (1.13B parameters) and then distilled from it.

  • Architecture: ViT with 33 blocks, width 640, 10 heads, patch size 16 and a SwiGLU MLP
  • Input: 224 × 224 RGB tiles
  • Output: a 640-d CLS embedding and 196 patch tokens
  • Teacher: Prov-GigaPath

Evaluation

TinyPath and Prov-GigaPath were run through the same pipeline on three official benchmarks, HEST, EVA and PLISM, and the other three models' scores are published. H0-mini's come from the HEST and PLISM leaderboards and, for EVA, from its paper. H-optimus-0's come from the HEST, EVA 0.4.5 and PLISM leaderboards, and DistillPath-KS16-HOpt0's from its paper. Error bars are ±1 SD over repeated runs; the published scores have none.

Official benchmarks, representative scores

Benchmark Metric Better TinyPath Prov-GigaPath H0-mini (published) H-optimus-0 (published) DistillPath-KS16-HOpt0 (published)
Parameters 103.6M 1.13B 86M 1.1B 22M
HEST Mean Pearson r, 9 tasks Higher 0.3822 0.3875 0.3958 0.4150 0.376
EVA, 5 patch tasks Mean balanced accuracy Higher 0.8371 0.8425 — 0.846 0.810
EVA Camelyon16-small Balanced accuracy (test) Higher 0.8368 ± 0.0221 0.8036 ± 0.0308 0.842 0.827 —
EVA MoNuSAC Dice (release test split) Higher 0.6443 ± 0.0065 0.6834 ± 0.0066 0.643 0.685 0.634
PLISM Leaderboard score, 224 px Higher 0.530 0.333 0.541 0.480 0.480

Official benchmarks, every task

HEST Pearson r per task

PLISM at 224 px

Teacher retention per benchmark

Mean teacher retention

  • Higher is better on every benchmark: Pearson r for HEST, balanced accuracy for the EVA classification tasks, Dice for EVA MoNuSAC, and the leaderboard score and its components for PLISM.
  • A missing bar or a dash means that model has no published score on that benchmark.
  • EVA's representative score is the mean balanced accuracy of its five patch-classification tasks (BACH, BreakHis, CRC, Gleason and PatchCamelyon), with its slide task (Camelyon16-small) and segmentation task (MoNuSAC) kept separate; the mean has no error bar. It is not EVA's leaderboard average, which leaves out BACH and needs MHIST, PANDA-small and CoNSeP, none of which were run. H0-mini's paper has no BreakHis or Gleason score, so H0-mini has no five-task mean.
  • PLISM measures robustness to scanner and stain changes rather than accuracy. It is run two ways: on its 224 px tiles unresized, the setting of its public leaderboard and of H0-mini's own preprocessing, and with tiles resized to 256 px and center-cropped to 224, as PLISM's code now does for Prov-GigaPath. The representative score and the PLISM figure use 224 px, the only setting with scores for every model.
  • H0-mini is Bioptimus's 86M-parameter ViT-B, distilled from H-optimus-0 (1.1B parameters) on the same 6,093 TCGA slides as TinyPath. All its scores here use the class token, like TinyPath's. Its EVA scores come from its paper's table, which has no BreakHis or Gleason. The paper's HEST score (0.4044) concatenates the class token with the mean patch token, so the HEST leaderboard's class-token score is used instead.
  • Teacher retention divides each student's score by its own teacher's: TinyPath by Prov-GigaPath, both run here, and H0-mini by H-optimus-0, both taken from the same source. For HEST and PLISM that source is the two leaderboards. For EVA it is H0-mini's paper, whose H-optimus-0 scores differ slightly from the EVA leaderboard's in the table above. The means cover only scores both students have, so they leave out Gleason and BreakHis: over HEST and the five shared EVA tasks, TinyPath keeps 99.6% of its teacher and H0-mini 99.2%. Adding PLISM, where both students are more robust than their teachers, raises them to 108.1% and 101.1%.
  • On HEST, H0-mini scores higher than TinyPath but keeps less of its teacher: 95.4% of H-optimus-0's score, where TinyPath keeps 98.6% of Prov-GigaPath's. Under its paper's protocol it keeps 95.7% (0.4044 against H-optimus-0's 0.4224). The two students differ in more than their teachers, though: H0-mini is a ViT-B with 14 px patches and four register tokens, does not start from its teacher's weights, distills through its teacher's pretrained projection heads, which Prov-GigaPath does not ship, and saw about 215M tiles, 2.7 times TinyPath's 78.9M. Retention alone cannot say which of these differences matters.
  • DistillPath-KS16-HOpt0 is kaiko's 22M-parameter ViT-S/16, further distilled from H-optimus-0's class and patch tokens on 6,000 TCGA slides. Its paper uses the same EVA, HEST and PLISM protocols but reports PLISM retrieval at top-5 rather than top-10, so only its PLISM score and median cosine are listed.
  • TinyPath and H0-mini were trained without labels on the same 6,093 TCGA slides, which include slides from 18 of MoNuSAC's 25 test patients. Prov-GigaPath never saw TCGA.
Exact numbers
Benchmark Metric (split) Better TinyPath Prov-GigaPath H0-mini (published) H-optimus-0 (published) DistillPath-KS16-HOpt0 (published)
HEST, mean of 9 tasks Pearson r Higher 0.3822 0.3875 0.3958 0.4150 0.376
EVA PatchCamelyon Balanced accuracy (test), 5 runs Higher 0.9462 ± 0.0010 0.9436 ± 0.0015 0.942 0.943 0.921
EVA CRC Balanced accuracy (val), 5 runs Higher 0.9571 ± 0.0006 0.9519 ± 0.0014 0.961 0.955 0.943
EVA BACH Balanced accuracy (val), 5 runs Higher 0.7601 ± 0.0135 0.7637 ± 0.0025 0.774 0.759 0.742
EVA Gleason (Arvaniti) Balanced accuracy (val), 5 runs Higher 0.7346 ± 0.0092 0.7246 ± 0.0100 — 0.770 0.756
EVA BreakHis Balanced accuracy (val), 5 runs Higher 0.7875 ± 0.0098 0.8288 ± 0.0084 — 0.801 0.690
EVA Camelyon16-small Balanced accuracy (test), 20 runs Higher 0.8368 ± 0.0221 0.8036 ± 0.0308 0.842 0.827 —
EVA MoNuSAC Dice (release test split), 5 runs Higher 0.6443 ± 0.0065 0.6834 ± 0.0066 0.643 0.685 0.634
PLISM Leaderboard score (8,139 positions, 256 px) Higher 0.520 0.320 — — —
PLISM Leaderboard score (8,139 positions, 224 px) Higher 0.530 0.333 0.541 0.480 0.480

HEST, Pearson r per task (higher is better):

Encoder IDC PRAD PAAD SKCM COAD READ CCRCC LUNG LYMPH_IDC Mean
TinyPath 0.5679 0.3759 0.4722 0.5474 0.2688 0.1672 0.2395 0.5454 0.2553 0.3822
Prov-GigaPath 0.5515 0.3698 0.4746 0.5618 0.2992 0.1960 0.2429 0.5411 0.2500 0.3875
H0-mini (published) 0.5862 0.3687 0.4919 0.6012 0.2494 0.1863 0.2670 0.5482 0.2629 0.3958
H-optimus-0 (published) 0.5976 0.3848 0.4911 0.6454 0.3086 0.2216 0.2676 0.5590 0.2591 0.4150
DistillPath-KS16-HOpt0 (published) 0.554 0.349 0.458 0.554 0.261 0.177 0.228 0.546 0.256 0.376

PLISM by component over 8,139 positions (higher is better in every column). TinyPath and Prov-GigaPath ran in float16:

Encoder Input Median cosine, all pairs Top-10, scanner only Top-10, staining only Top-10, both differ Leaderboard Mean cosine
TinyPath 256 px 0.7460 0.9082 0.2681 0.1581 0.520 0.7192
Prov-GigaPath 256 px 0.5533 0.5659 0.1098 0.0489 0.320 0.5388
TinyPath 224 px 0.7556 0.9218 0.2737 0.1686 0.530 0.7283
Prov-GigaPath 224 px 0.5704 0.5920 0.1178 0.0539 0.333 0.5547
H0-mini (published) 224 px 0.800 0.864 0.318 0.183 0.541 —
H-optimus-0 (published) 224 px 0.685 0.744 0.327 0.166 0.480 —
DistillPath-KS16-HOpt0 (published) 224 px 0.656 — — — 0.480 —

Teacher retention, each student's score as a percentage of its teacher's (higher is better). H0-mini's EVA scores and the H-optimus-0 scores they are divided by both come from Table 1 of H0-mini's paper:

Benchmark TinyPath Prov-GigaPath TinyPath retention H0-mini H-optimus-0 H0-mini retention
HEST, mean of 9 tasks 0.3822 0.3875 98.6% 0.3958 0.4150 95.4%
EVA PatchCamelyon 0.9462 0.9436 100.3% 0.942 0.942 100.0%
EVA CRC 0.9571 0.9519 100.5% 0.961 0.958 100.3%
EVA BACH 0.7601 0.7637 99.5% 0.774 0.758 102.1%
EVA Gleason (Arvaniti) 0.7346 0.7246 101.4% — — —
EVA BreakHis 0.7875 0.8288 95.0% — — —
EVA Camelyon16-small 0.8368 0.8036 104.1% 0.842 0.820 102.7%
EVA MoNuSAC 0.6443 0.6834 94.3% 0.643 0.679 94.7%
PLISM, 224 px 0.530 0.333 159.2% 0.541 0.480 112.7%
Mean, HEST and 5 shared EVA tasks 99.6% 99.2%
Mean, adding PLISM 108.1% 101.1%

Usage

pip install -r requirements.txt

Tiles are resized to 256 px on the shorter side (bicubic), center-cropped to 224 and normalized with ImageNet statistics. AutoImageProcessor and the timm transform do this for you.

transformers

import torch
from PIL import Image
from transformers import AutoImageProcessor, AutoModel

processor = AutoImageProcessor.from_pretrained("<org>/tinypath")
model = AutoModel.from_pretrained("<org>/tinypath", trust_remote_code=True).eval()

image = Image.open("patch.png").convert("RGB")
with torch.no_grad():
    outputs = model(processor(image, return_tensors="pt")["pixel_values"], pool_mode="cls")
embedding = outputs.pooler_output   # [1, 640]
tokens = outputs.last_hidden_state  # [1, 197, 640]

Without trust_remote_code, the same weights load into transformers' built-in TimmWrapperModel.

timm

import timm

model = timm.create_model("hf-hub:<org>/tinypath", pretrained=True).eval()
transform = timm.data.create_transform(**timm.data.resolve_data_config({}, model=model))
with torch.no_grad():
    embedding = model(transform(image).unsqueeze(0))  # [1, 640]

uint8 encoder

From a local copy of this repository:

from modeling_tinypath import build_encoder, eval_transform

encoder = build_encoder(".")
with torch.no_grad():
    embedding = encoder(eval_transform()(image).unsqueeze(0))  # [1, 640]

python run_inference.py checks that every interface loads all weights and returns identical outputs.

Downloads last month
23
Safetensors
Model size
0.1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Papers for originbio/TinyPath