Image Feature Extraction
Transformers
PyTorch
pathology
vision
vit
feature-extraction
knowledge-distillation
Instructions to use luoxd96/PathAGG with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use luoxd96/PathAGG with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-feature-extraction", model="luoxd96/PathAGG")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("luoxd96/PathAGG", device_map="auto") - Notebooks
- Google Colab
- Kaggle
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("luoxd96/PathAGG", device_map="auto")Quick Links
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 |
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-feature-extraction", model="luoxd96/PathAGG")