UNI UNI (v1)
General-purpose self-supervised vision encoder for H&E histopathology tiles, pretrained on more than 100 million tiles from over 100,000 whole-slide images; the reference foundation model for pathology feature extraction.
🤗 40 388 downloads / month ♥ 372 updated 2025-03-06 gatedAt a glance
What it does
UNI turns a histopathology image tile into a fixed-length embedding without any task-specific training. Downstream, those embeddings are pooled per slide (e.g. with a lightweight attention model) to classify cancer subtype, grade, detect metastases or predict molecular status.
Notable uses in oncology
Benchmarked on 34 clinical tasks of varying difficulty across 20 major tissue types, including subtyping, grading, metastasis detection and biomarker prediction; widely used as the tile encoder in academic pathology pipelines.
Tasks, data types and cancers
Architecture
Loaded through timm as hf-hub:MahmoodLab/UNI (ViT-L/16, patch 16, no classifier head). The DINOv2 recipe is unchanged; the novelty is the scale and diversity of the in-house pathology data.
Training data
Mass-100K: over 100 million tiles sampled from more than 100,000 diagnostic H&E whole-slide images across 20 major tissue types, collected at Massachusetts General Hospital and Brigham and Women's Hospital and complemented with GTEx slides. No public test data was included in pretraining, which is what makes the public benchmarks meaningful.
Linked datasets
- evaluation CAMELYON16 / CAMELYON17 Open download — slide-level metastasis detection benchmark
- evaluation PANDA — Prostate cANcer graDe Assessment Free registration — prostate Gleason grading benchmark
- evaluation TCGA — The Cancer Genome Atlas (via NCI Genomic Data Commons) Free registration — subtyping and biomarker tasks drawn from TCGA cohorts
Evaluation
| Benchmark / dataset | Metric | Value | External validation | Source |
|---|---|---|---|---|
| CAMELYON16 (breast lymph-node metastasis, slide-level) ↗ | AUROC | reported in paper (weakly supervised ABMIL) | yes | Source |
| PANDA (prostate Gleason grading) ↗ | quadratic-weighted κ / balanced accuracy | reported in paper | yes | Source |
| 34-task suite (subtyping, grading, biomarkers; 20 tissue types) | average performance vs. CTransPath / REMEDIS | best or tied-best on the majority of tasks | yes | Source |
How to run
# generic timm loader — check the model card for the exact init args and image normalisation
import timm, torch
from huggingface_hub import login
login() # gated repos: accept the licence on huggingface.co first
model = timm.create_model('hf-hub:MahmoodLab/UNI', pretrained=True)
model.eval()
cfg = timm.data.resolve_data_config({}, model=model)
transform = timm.data.create_transform(**cfg)
# emb = model(transform(tile).unsqueeze(0)) # 1 x D tile embedding
Weights are gated: request access on Hugging Face and accept the CC-BY-NC-ND licence (research only, no derivatives distribution). Use the exact 224×224 / 20× regime the card specifies — off-magnification tiles degrade features silently.
Regulatory status and intended use
Regulatory status is quoted from the source linked above and can change. Research-use-only models must not be used for clinical decisions.
Limitations and bias
- Trained on H&E only; immunohistochemistry, frozen sections and non-standard stains are out of distribution.
- Scanner and lab colour variation still matters; the paper does not report per-ancestry performance.
- Non-commercial licence blocks product use without a separate agreement.
- Slide-level tasks need a second, task-specific aggregation model that you must train and validate yourself.
Sources
This page is educational — it is not medical advice and does not replace consultation with an oncologist. Diagnostic and treatment decisions are made solely by specialist physicians.