File size: 3,627 Bytes
50bbff2
 
 
16318d2
50bbff2
16318d2
 
 
 
 
50bbff2
16318d2
 
 
 
 
 
 
 
50bbff2
16318d2
50bbff2
16318d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101d15e
16318d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101d15e
16318d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
tags:
- image-classification
- feature-extraction
- timm
- biology
- cancer
- histology
- TIA
- tiatoolbox
library_name: timm
pipeline_tag: image-classification
license: cc-by-4.0
datasets:
- 1aurent/NCT-CRC-HE
widget:
- src: >-
    https://datasets-server.huggingface.co/assets/1aurent/NCT-CRC-HE/--/default/CRC_VAL_HE_7K/0/image/image.jpg
  example_title: debris
---

# Model card for densenet161.tiatoolbox-kather100k

A DenseNet image classification model. \
Trained by [Tissue Image Analytics (TIA) Centre](https://warwick.ac.uk/fac/cross_fac/tia/) on "kather100k" histology patches.

![](https://raw.githubusercontent.com/TissueImageAnalytics/tiatoolbox/develop/docs/tiatoolbox-logo.png)

## Model Details

- **Model Type:** Image classification / Feature backbone
- **Model Stats:**
  - Params (M): 26.7
  - Image size: 224 x 224 x 3
- **Dataset**: [kather100k](https://tia-toolbox.readthedocs.io/en/latest/_autosummary/tiatoolbox.models.dataset.info.KatherPatchDataset.html#tiatoolbox.models.dataset.info.KatherPatchDataset), also called NCT-CRC-HE
- **Original:** https://github.com/TissueImageAnalytics/tiatoolbox
- **License**: [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/legalcode)

## Model Usage

### Image Classification

```python
from urllib.request import urlopen
from PIL import Image
import torch.nn as nn
import timm

# get example histology image
img = Image.open(
  urlopen(
    "https://github.com/owkin/HistoSSLscaling/raw/main/assets/example.tif"
  )
)

# load model from the hub
model = timm.create_model(
  model_name="hf-hub:1aurent/densenet161.tiatoolbox-kather100k",
  pretrained=True,
).eval()

# get model specific transforms (normalization, resize)
data_config = timm.data.resolve_model_data_config(model)
transforms = timm.data.create_transform(**data_config, is_training=False)

data = transforms(img).unsqueeze(0) # input is a (batch_size, num_channels, img_size, img_size) shaped tensor
output = model(data)  # output is a (batch_size, num_features) shaped tensor
```

### Image Embeddings

```python
from urllib.request import urlopen
from PIL import Image
import torch.nn as nn
import timm

# get example histology image
img = Image.open(
  urlopen(
    "https://github.com/owkin/HistoSSLscaling/raw/main/assets/example.tif"
  )
)

# load model from the hub
model = timm.create_model(
  model_name="hf-hub:1aurent/densenet161.tiatoolbox-kather100k",
  pretrained=True,
  num_classes=0,
).eval()

# get model specific transforms (normalization, resize)
data_config = timm.data.resolve_model_data_config(model)
transforms = timm.data.create_transform(**data_config, is_training=False)

data = transforms(img).unsqueeze(0) # input is a (batch_size, num_channels, img_size, img_size) shaped tensor
output = model(data)  # output is a (batch_size, num_features) shaped tensor
```

## Citation

```bibtex
@article{Pocock2022,
  author    = {Pocock, Johnathan and Graham, Simon and Vu, Quoc Dang and Jahanifar, Mostafa and Deshpande, Srijay and Hadjigeorghiou, Giorgos and Shephard, Adam and Bashir, Raja Muhammad Saad and Bilal, Mohsin and Lu, Wenqi and Epstein, David and Minhas, Fayyaz and Rajpoot, Nasir M and Raza, Shan E Ahmed},
  doi       = {10.1038/s43856-022-00186-5},
  issn      = {2730-664X},
  journal   = {Communications Medicine},
  month     = {sep},
  number    = {1},
  pages     = {120},
  publisher = {Springer US},
  title     = {{TIAToolbox as an end-to-end library for advanced tissue image analytics}},
  url       = {https://www.nature.com/articles/s43856-022-00186-5},
  volume    = {2},
  year      = {2022}
}
```