Prostate DINOv1 ViT-B/16 (TCGA-PRAD)
What this repository contains. The weights of the prostate-specific DINOv1 encoder trained by the authors, and the full analysis code of the accompanying study in
code/. The four pathology foundation models compared in the study (UNI, UNI2-h, CONCH, Prov-GigaPath) are not redistributed here; see Comparison encoders.
A ViT-B/16 image encoder trained from scratch with DINO self-distillation on
H&E patches from TCGA-PRAD diagnostic whole-slide images. It maps a
224×224 H&E patch to a 768-dimensional embedding (final-layer [CLS] token).
It was released to support reproduction of the analyses in the paper below,
in which it serves as the prostate-specific encoder.
Not for clinical use. This model has not been validated for diagnosis, grading, prognosis, or any patient-facing decision.
Model details
| Architecture | ViT-B/16 (timm vit_base_patch16_224), 85.8M parameters |
| Output | 768-d [CLS] embedding (no classification head) |
| Training objective | DINO self-distillation; weights released are the teacher backbone |
| Initialisation | Random (trained from scratch, no ImageNet weights) |
| Training data | 449 TCGA-PRAD diagnostic WSIs from 403 patients |
| Training patches | ~20× magnification; [TO FILL: number of patches] |
| Epochs | 100 |
| Batch size | 32 per GPU |
| Learning rate | 1e-4 |
| Multi-crop | 2 global crops (scale 0.3–1.0) + 6 local crops |
| Projection head output dim | 8,192 (discarded after training) |
| Teacher temperature / momentum | 0.04 / 0.996 |
| Mixed precision | fp16 |
| Seed | 42 |
How to use
import timm, torch
from PIL import Image
from torchvision import transforms
model = timm.create_model(
"hf-hub:buseyaren/prostate-cancer-clustering-foundation-models",
pretrained=True,
).eval()
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
])
img = Image.open("patch.png").convert("RGB") # ideally Macenko-normalised
with torch.inference_mode():
emb = model(transform(img).unsqueeze(0)) # shape [1, 768]
example.py embeds a folder of patches end to end, including Macenko
normalisation with stain_normalizer.py.
Expected input
- H&E patches at approximately 20× (the training magnification).
- Macenko stain normalisation before encoding. In the paper, the stain
reference was fitted on 50 patches sampled with seed 42 from the patches
being encoded (
OD = −ln(I/240), background OD threshold 0.15, 1st/99th-percentile angle bounds). Patches larger than 512 px were downsized to 512×512 before normalisation. - Resize to 224×224 (bilinear, no crop) and ImageNet mean/std normalisation.
Intended use
- Research on representation learning and unsupervised analysis of prostate H&E histopathology.
- Reproducing the encoder-level results of the accompanying paper.
Out of scope: clinical diagnosis or grading; deployment without independent validation; use as evidence that unsupervised clusters correspond to biological phenotypes.
Limitations
- Same-domain overlap with the benchmark. All 439 TCGA-PRAD WSIs in the paper's clustering benchmark are among the 449 slides used for pretraining. TCGA-PRAD results for this encoder are therefore same-domain performance, not independent external validation. Transfer was assessed only on the non-TCGA image collections (PANDA-Radboud, SICAPv2, crowdDataset, crowd-SICAPv2).
- Single training source. All training slides come from TCGA-PRAD, so the representation reflects that cohort's scanners, staining protocols, and patient population.
- Compact geometry is not biological validity. In the paper, this encoder produced the most compact clusters under an internal index, yet that advantage largely disappeared under a neighbour-graph criterion, and clusters recovered known diagnostic contrasts only weakly. Embeddings from this model should not be interpreted as defining tissue phenotypes without positive controls and held-out validation.
- Behaviour on magnifications other than ~20×, on non-H&E stains, or on tissue other than prostate has not been evaluated.
Comparison encoders
The paper compares this encoder with four publicly released pathology foundation models. Their weights require an access request from the original authors and are not redistributed here; embeddings derived from them are not shared either.
| Model | Repository |
|---|---|
| UNI | https://huggingface.co/MahmoodLab/UNI |
| UNI2-h | https://huggingface.co/MahmoodLab/UNI2-h |
| CONCH | https://huggingface.co/MahmoodLab/CONCH |
| Prov-GigaPath | https://huggingface.co/prov-gigapath/prov-gigapath |
Code
The code/ folder contains the complete pipeline used in the paper:
patch preparation, Macenko normalization, feature extraction for all five
encoders, the locked PCA-50 + k-Means clustering, the alternative clustering and
dimensionality-reduction analyses, positive controls, cribriform recovery,
held-out-slide permutation tests, and figure generation. See
code/README.md for installation and the mapping from
scripts to analyses.
Training data and licence
Training used open-access TCGA-PRAD diagnostic slides from the NCI Genomic
Data Commons. The model weights and code are released under the Apache License
2.0 (see LICENSE). Users are responsible for complying with the terms of any
data they process with this model. The licence does not make the model suitable
for clinical use.