File size: 2,248 Bytes
b612017
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
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](https://huggingface.co/paige-ai/Virchow2), [UNI2-h](https://huggingface.co/MahmoodLab/UNI2-h), and [H1](https://huggingface.co/bioptimus/H-optimus-1) (H-optimus-1).

Trained on **~66M** TCGA + HISTAI patches (~**1000 GPU-hours** / student on 8× H100).  
Code & EVA dumps: [Luoxd1996/PathAGG](https://github.com/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](https://creativecommons.org/licenses/by-nc/4.0/) — non-commercial / research only.**

## Load (recommended)

```bash
pip install torch timm transformers torchvision Pillow
```

```python
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** |