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