PathAGG / README.md
luoxd96's picture
Add transformers model card layout (vitb/vits AutoModel)
b612017 verified
|
Raw
History Blame Contribute Delete
2.25 kB
metadata
license: cc-by-nc-4.0
library_name: transformers
tags:
  - pathology
  - vision
  - vit
  - feature-extraction
  - knowledge-distillation
  - pytorch
pipeline_tag: image-feature-extraction

PathAGG

Multi-teacher pathology foundation students distilled with CRADIOv4-style aggregation from Virchow2, UNI2-h, and H1 (H-optimus-1).

Trained on ~66M TCGA + HISTAI patches (~1000 GPU-hours / student on 8× H100).
Code & EVA dumps: Luoxd1996/PathAGG.

Variant subfolder Embed Official EVA avg (9 tasks)
ViT-B/14 vitb 768 79.57
ViT-S/14 vits 384 77.93

License: CC BY-NC 4.0 — non-commercial / research only.

Load (recommended)

pip install torch timm transformers torchvision Pillow
import torch
from PIL import Image
from torchvision import transforms
from transformers import AutoModel

preprocess = transforms.Compose([
    transforms.Resize(224, interpolation=transforms.InterpolationMode.BICUBIC),
    transforms.CenterCrop(224),
    transforms.ToTensor(),
    transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
])

model = AutoModel.from_pretrained(
    "luoxd96/PathAGG",
    subfolder="vitb",   # or "vits"
    trust_remote_code=True,
).eval().cuda()

img = Image.open("patch.png").convert("RGB")
x = preprocess(img).unsqueeze(0).cuda()

with torch.inference_mode():
    cls = model(x)                 # [1, 768] or [1, 384]
    cls, patch = model(x, return_patch=True)  # patch: [1, 256, D]

EVA results (%)

Task Split ViT-S ViT-B
BreakHis val 74.36 84.62
CRC val 95.93 96.41
Gleason val 78.72 77.33
MHIST val 81.85 82.20
PCam test 93.88 93.75
Cam16Small test 83.59 85.03
PANDASmall test 66.28 67.93
CoNSeP val 63.58 64.04
MoNuSAC val 63.22 64.82
Official Avg 77.93 79.57