Update model config and README
Browse files- README.md +145 -2
- config.json +1 -0
- model.safetensors +3 -0
README.md
CHANGED
@@ -2,6 +2,149 @@
|
|
2 |
tags:
|
3 |
- image-classification
|
4 |
- timm
|
5 |
-
|
|
|
|
|
|
|
6 |
---
|
7 |
-
# Model card for tf_efficientnet_b1.aa_in1k
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
tags:
|
3 |
- image-classification
|
4 |
- timm
|
5 |
+
library_name: timm
|
6 |
+
license: apache-2.0
|
7 |
+
datasets:
|
8 |
+
- imagenet-1k
|
9 |
---
|
10 |
+
# Model card for tf_efficientnet_b1.aa_in1k
|
11 |
+
|
12 |
+
A EfficientNet image classification model. Trained on ImageNet-1k with auto-augment in Tensorflow by paper authors, ported to PyTorch by Ross Wightman.
|
13 |
+
|
14 |
+
|
15 |
+
## Model Details
|
16 |
+
- **Model Type:** Image classification / feature backbone
|
17 |
+
- **Model Stats:**
|
18 |
+
- Params (M): 7.8
|
19 |
+
- GMACs: 0.7
|
20 |
+
- Activations (M): 10.9
|
21 |
+
- Image size: 240 x 240
|
22 |
+
- **Papers:**
|
23 |
+
- EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks: https://arxiv.org/abs/1905.11946
|
24 |
+
- AutoAugment: Learning Augmentation Policies from Data: https://arxiv.org/abs/1805.09501
|
25 |
+
- **Dataset:** ImageNet-1k
|
26 |
+
- **Original:** https://github.com/tensorflow/tpu/tree/master/models/official/efficientnet
|
27 |
+
|
28 |
+
## Model Usage
|
29 |
+
### Image Classification
|
30 |
+
```python
|
31 |
+
from urllib.request import urlopen
|
32 |
+
from PIL import Image
|
33 |
+
import timm
|
34 |
+
|
35 |
+
img = Image.open(urlopen(
|
36 |
+
'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
|
37 |
+
))
|
38 |
+
|
39 |
+
model = timm.create_model('tf_efficientnet_b1.aa_in1k', pretrained=True)
|
40 |
+
model = model.eval()
|
41 |
+
|
42 |
+
# get model specific transforms (normalization, resize)
|
43 |
+
data_config = timm.data.resolve_model_data_config(model)
|
44 |
+
transforms = timm.data.create_transform(**data_config, is_training=False)
|
45 |
+
|
46 |
+
output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
|
47 |
+
|
48 |
+
top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
|
49 |
+
```
|
50 |
+
|
51 |
+
### Feature Map Extraction
|
52 |
+
```python
|
53 |
+
from urllib.request import urlopen
|
54 |
+
from PIL import Image
|
55 |
+
import timm
|
56 |
+
|
57 |
+
img = Image.open(urlopen(
|
58 |
+
'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
|
59 |
+
))
|
60 |
+
|
61 |
+
model = timm.create_model(
|
62 |
+
'tf_efficientnet_b1.aa_in1k',
|
63 |
+
pretrained=True,
|
64 |
+
features_only=True,
|
65 |
+
)
|
66 |
+
model = model.eval()
|
67 |
+
|
68 |
+
# get model specific transforms (normalization, resize)
|
69 |
+
data_config = timm.data.resolve_model_data_config(model)
|
70 |
+
transforms = timm.data.create_transform(**data_config, is_training=False)
|
71 |
+
|
72 |
+
output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
|
73 |
+
|
74 |
+
for o in output:
|
75 |
+
# print shape of each feature map in output
|
76 |
+
# e.g.:
|
77 |
+
# torch.Size([1, 16, 120, 120])
|
78 |
+
# torch.Size([1, 24, 60, 60])
|
79 |
+
# torch.Size([1, 40, 30, 30])
|
80 |
+
# torch.Size([1, 112, 15, 15])
|
81 |
+
# torch.Size([1, 320, 8, 8])
|
82 |
+
|
83 |
+
print(o.shape)
|
84 |
+
```
|
85 |
+
|
86 |
+
### Image Embeddings
|
87 |
+
```python
|
88 |
+
from urllib.request import urlopen
|
89 |
+
from PIL import Image
|
90 |
+
import timm
|
91 |
+
|
92 |
+
img = Image.open(urlopen(
|
93 |
+
'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
|
94 |
+
))
|
95 |
+
|
96 |
+
model = timm.create_model(
|
97 |
+
'tf_efficientnet_b1.aa_in1k',
|
98 |
+
pretrained=True,
|
99 |
+
num_classes=0, # remove classifier nn.Linear
|
100 |
+
)
|
101 |
+
model = model.eval()
|
102 |
+
|
103 |
+
# get model specific transforms (normalization, resize)
|
104 |
+
data_config = timm.data.resolve_model_data_config(model)
|
105 |
+
transforms = timm.data.create_transform(**data_config, is_training=False)
|
106 |
+
|
107 |
+
output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor
|
108 |
+
|
109 |
+
# or equivalently (without needing to set num_classes=0)
|
110 |
+
|
111 |
+
output = model.forward_features(transforms(img).unsqueeze(0))
|
112 |
+
# output is unpooled, a (1, 1280, 8, 8) shaped tensor
|
113 |
+
|
114 |
+
output = model.forward_head(output, pre_logits=True)
|
115 |
+
# output is a (1, num_features) shaped tensor
|
116 |
+
```
|
117 |
+
|
118 |
+
## Model Comparison
|
119 |
+
Explore the dataset and runtime metrics of this model in timm [model results](https://github.com/huggingface/pytorch-image-models/tree/main/results).
|
120 |
+
|
121 |
+
## Citation
|
122 |
+
```bibtex
|
123 |
+
@inproceedings{tan2019efficientnet,
|
124 |
+
title={Efficientnet: Rethinking model scaling for convolutional neural networks},
|
125 |
+
author={Tan, Mingxing and Le, Quoc},
|
126 |
+
booktitle={International conference on machine learning},
|
127 |
+
pages={6105--6114},
|
128 |
+
year={2019},
|
129 |
+
organization={PMLR}
|
130 |
+
}
|
131 |
+
```
|
132 |
+
```bibtex
|
133 |
+
@inproceedings{47890,
|
134 |
+
title = {AutoAugment: Learning Augmentation Policies from Data},
|
135 |
+
author = {Ekin Dogus Cubuk and Barret Zoph and Dandelion Mane and Vijay Vasudevan and Quoc V. Le},
|
136 |
+
year = {2019},
|
137 |
+
URL = {https://arxiv.org/pdf/1805.09501.pdf}
|
138 |
+
}
|
139 |
+
```
|
140 |
+
```bibtex
|
141 |
+
@misc{rw2019timm,
|
142 |
+
author = {Ross Wightman},
|
143 |
+
title = {PyTorch Image Models},
|
144 |
+
year = {2019},
|
145 |
+
publisher = {GitHub},
|
146 |
+
journal = {GitHub repository},
|
147 |
+
doi = {10.5281/zenodo.4414861},
|
148 |
+
howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
|
149 |
+
}
|
150 |
+
```
|
config.json
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
"num_classes": 1000,
|
4 |
"num_features": 1280,
|
5 |
"pretrained_cfg": {
|
|
|
6 |
"custom_load": false,
|
7 |
"input_size": [
|
8 |
3,
|
|
|
3 |
"num_classes": 1000,
|
4 |
"num_features": 1280,
|
5 |
"pretrained_cfg": {
|
6 |
+
"tag": "aa_in1k",
|
7 |
"custom_load": false,
|
8 |
"input_size": [
|
9 |
3,
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:44df4f85e844442fe761fb0ce92a9e4b96b2ec5d209e9169956fe033da180145
|
3 |
+
size 31471874
|