Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
tags:
|
3 |
+
- image-classification
|
4 |
+
- timm
|
5 |
+
- owkin
|
6 |
+
- biology
|
7 |
+
- cancer
|
8 |
+
- colon
|
9 |
+
library_name: timm
|
10 |
+
datasets:
|
11 |
+
- 1aurent/LC25000
|
12 |
+
metrics:
|
13 |
+
- accuracy
|
14 |
+
pipeline_tag: image-classification
|
15 |
+
widget:
|
16 |
+
- src: >-
|
17 |
+
https://datasets-server.huggingface.co/cached-assets/1aurent/LC25000/--/56a7c495692c27afd294a88b7aadaa7b79d8e270/--/default/train/24999/image/image.jpg
|
18 |
+
example_title: benign
|
19 |
+
- src: >-
|
20 |
+
https://datasets-server.huggingface.co/cached-assets/1aurent/LC25000/--/56a7c495692c27afd294a88b7aadaa7b79d8e270/--/default/train/17501/image/image.jpg
|
21 |
+
example_title: adenocarcinomas
|
22 |
+
---
|
23 |
+
|
24 |
+
# Model card for vit_base_patch16_224.owkin_pancancer_ft_lc25000_colon
|
25 |
+
|
26 |
+
A Vision Transformer (ViT) image classification model. \
|
27 |
+
Trained by Owkin on 40M pan-cancer histology tiles from TCGA. \
|
28 |
+
Fine-tuned on LC25000's colon subset.
|
29 |
+
|
30 |
+
## Model Details
|
31 |
+
|
32 |
+
- **Model Type:** Image classification / feature backbone
|
33 |
+
- **Model Stats:**
|
34 |
+
- Params (M): 85.8
|
35 |
+
- Image size: 224 x 224 x 3
|
36 |
+
- **Papers:**
|
37 |
+
- Scaling Self-Supervised Learning for Histopathology with Masked Image Modeling: https://www.medrxiv.org/content/10.1101/2023.07.21.23292757v2
|
38 |
+
- **Pretrain Dataset:** TGCA: https://portal.gdc.cancer.gov/
|
39 |
+
- **Dataset:** LC25000: https://huggingface.co/datasets/1aurent/LC25000
|
40 |
+
- **Original:** https://github.com/owkin/HistoSSLscaling/
|
41 |
+
- **License:** https://github.com/owkin/HistoSSLscaling/blob/main/LICENSE.txt
|
42 |
+
|
43 |
+
## Model Usage
|
44 |
+
|
45 |
+
### Image Classification
|
46 |
+
```python
|
47 |
+
from urllib.request import urlopen
|
48 |
+
from PIL import Image
|
49 |
+
import timm
|
50 |
+
|
51 |
+
# get example histology image
|
52 |
+
img = Image.open(
|
53 |
+
urlopen(
|
54 |
+
"https://datasets-server.huggingface.co/cached-assets/1aurent/LC25000/--/56a7c495692c27afd294a88b7aadaa7b79d8e270/--/default/train/24999/image/image.jpg"
|
55 |
+
)
|
56 |
+
)
|
57 |
+
|
58 |
+
# load model from the hub
|
59 |
+
model = timm.create_model(
|
60 |
+
model_name="hf-hub:1aurent/vit_base_patch16_224.owkin_pancancer_ft_lc25000_colon",
|
61 |
+
pretrained=True,
|
62 |
+
).eval()
|
63 |
+
|
64 |
+
# get model specific transforms (normalization, resize)
|
65 |
+
data_config = timm.data.resolve_model_data_config(model)
|
66 |
+
transforms = timm.data.create_transform(**data_config, is_training=False)
|
67 |
+
|
68 |
+
output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
|
69 |
+
```
|
70 |
+
|
71 |
+
### Image Embeddings
|
72 |
+
```python
|
73 |
+
from urllib.request import urlopen
|
74 |
+
from PIL import Image
|
75 |
+
import timm
|
76 |
+
|
77 |
+
# get example histology image
|
78 |
+
img = Image.open(
|
79 |
+
urlopen(
|
80 |
+
"https://datasets-server.huggingface.co/cached-assets/1aurent/LC25000/--/56a7c495692c27afd294a88b7aadaa7b79d8e270/--/default/train/24999/image/image.jpg"
|
81 |
+
)
|
82 |
+
)
|
83 |
+
|
84 |
+
# load model from the hub
|
85 |
+
model = timm.create_model(
|
86 |
+
model_name="hf-hub:1aurent/vit_base_patch16_224.owkin_pancancer_ft_lc25000_colon",
|
87 |
+
pretrained=True,
|
88 |
+
num_classes=0,
|
89 |
+
).eval()
|
90 |
+
|
91 |
+
# get model specific transforms (normalization, resize)
|
92 |
+
data_config = timm.data.resolve_model_data_config(model)
|
93 |
+
transforms = timm.data.create_transform(**data_config, is_training=False)
|
94 |
+
|
95 |
+
output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor
|
96 |
+
```
|
97 |
+
|
98 |
+
## Citation
|
99 |
+
```bibtex
|
100 |
+
@article {Filiot2023.07.21.23292757,
|
101 |
+
author = {Alexandre Filiot and Ridouane Ghermi and Antoine Olivier and Paul Jacob and Lucas Fidon and Alice Mac Kain and Charlie Saillard and Jean-Baptiste Schiratti},
|
102 |
+
title = {Scaling Self-Supervised Learning for Histopathology with Masked Image Modeling},
|
103 |
+
elocation-id = {2023.07.21.23292757},
|
104 |
+
year = {2023},
|
105 |
+
doi = {10.1101/2023.07.21.23292757},
|
106 |
+
publisher = {Cold Spring Harbor Laboratory Press},
|
107 |
+
URL = {https://www.medrxiv.org/content/early/2023/09/14/2023.07.21.23292757},
|
108 |
+
eprint = {https://www.medrxiv.org/content/early/2023/09/14/2023.07.21.23292757.full.pdf},
|
109 |
+
journal = {medRxiv}
|
110 |
+
}
|
111 |
+
```
|