Add model
Browse files- README.md +161 -0
- config.json +41 -0
- model.safetensors +3 -0
- pytorch_model.bin +3 -0
README.md
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
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 mobilenetv4_conv_large.e600_r384_in1k
|
11 |
+
|
12 |
+
A MobileNet-V4 image classification model. Trained on ImageNet-1k by Ross Wightman.
|
13 |
+
|
14 |
+
Trained with `timm` scripts using hyper-parameters (mostly) similar to those in the paper.
|
15 |
+
|
16 |
+
NOTE: So far, these are the only known MNV4 weights. Official weights for Tensorflow models are unreleased.
|
17 |
+
|
18 |
+
|
19 |
+
## Model Details
|
20 |
+
- **Model Type:** Image classification / feature backbone
|
21 |
+
- **Model Stats:**
|
22 |
+
- Params (M): 32.6
|
23 |
+
- GMACs: 6.4
|
24 |
+
- Activations (M): 27.3
|
25 |
+
- Image size: train = 384 x 384, test = 448 x 448
|
26 |
+
- **Dataset:** ImageNet-1k
|
27 |
+
- **Papers:**
|
28 |
+
- MobileNetV4 -- Universal Models for the Mobile Ecosystem: https://arxiv.org/abs/2404.10518
|
29 |
+
- PyTorch Image Models: https://github.com/huggingface/pytorch-image-models
|
30 |
+
- **Original:** https://github.com/tensorflow/models/tree/master/official/vision
|
31 |
+
|
32 |
+
## Model Usage
|
33 |
+
### Image Classification
|
34 |
+
```python
|
35 |
+
from urllib.request import urlopen
|
36 |
+
from PIL import Image
|
37 |
+
import timm
|
38 |
+
|
39 |
+
img = Image.open(urlopen(
|
40 |
+
'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
|
41 |
+
))
|
42 |
+
|
43 |
+
model = timm.create_model('mobilenetv4_conv_large.e600_r384_in1k', pretrained=True)
|
44 |
+
model = model.eval()
|
45 |
+
|
46 |
+
# get model specific transforms (normalization, resize)
|
47 |
+
data_config = timm.data.resolve_model_data_config(model)
|
48 |
+
transforms = timm.data.create_transform(**data_config, is_training=False)
|
49 |
+
|
50 |
+
output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
|
51 |
+
|
52 |
+
top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
|
53 |
+
```
|
54 |
+
|
55 |
+
### Feature Map Extraction
|
56 |
+
```python
|
57 |
+
from urllib.request import urlopen
|
58 |
+
from PIL import Image
|
59 |
+
import timm
|
60 |
+
|
61 |
+
img = Image.open(urlopen(
|
62 |
+
'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
|
63 |
+
))
|
64 |
+
|
65 |
+
model = timm.create_model(
|
66 |
+
'mobilenetv4_conv_large.e600_r384_in1k',
|
67 |
+
pretrained=True,
|
68 |
+
features_only=True,
|
69 |
+
)
|
70 |
+
model = model.eval()
|
71 |
+
|
72 |
+
# get model specific transforms (normalization, resize)
|
73 |
+
data_config = timm.data.resolve_model_data_config(model)
|
74 |
+
transforms = timm.data.create_transform(**data_config, is_training=False)
|
75 |
+
|
76 |
+
output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
|
77 |
+
|
78 |
+
for o in output:
|
79 |
+
# print shape of each feature map in output
|
80 |
+
# e.g.:
|
81 |
+
# torch.Size([1, 24, 192, 192])
|
82 |
+
# torch.Size([1, 48, 96, 96])
|
83 |
+
# torch.Size([1, 96, 48, 48])
|
84 |
+
# torch.Size([1, 192, 24, 24])
|
85 |
+
# torch.Size([1, 960, 12, 12])
|
86 |
+
|
87 |
+
print(o.shape)
|
88 |
+
```
|
89 |
+
|
90 |
+
### Image Embeddings
|
91 |
+
```python
|
92 |
+
from urllib.request import urlopen
|
93 |
+
from PIL import Image
|
94 |
+
import timm
|
95 |
+
|
96 |
+
img = Image.open(urlopen(
|
97 |
+
'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
|
98 |
+
))
|
99 |
+
|
100 |
+
model = timm.create_model(
|
101 |
+
'mobilenetv4_conv_large.e600_r384_in1k',
|
102 |
+
pretrained=True,
|
103 |
+
num_classes=0, # remove classifier nn.Linear
|
104 |
+
)
|
105 |
+
model = model.eval()
|
106 |
+
|
107 |
+
# get model specific transforms (normalization, resize)
|
108 |
+
data_config = timm.data.resolve_model_data_config(model)
|
109 |
+
transforms = timm.data.create_transform(**data_config, is_training=False)
|
110 |
+
|
111 |
+
output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor
|
112 |
+
|
113 |
+
# or equivalently (without needing to set num_classes=0)
|
114 |
+
|
115 |
+
output = model.forward_features(transforms(img).unsqueeze(0))
|
116 |
+
# output is unpooled, a (1, 960, 12, 12) shaped tensor
|
117 |
+
|
118 |
+
output = model.forward_head(output, pre_logits=True)
|
119 |
+
# output is a (1, num_features) shaped tensor
|
120 |
+
```
|
121 |
+
|
122 |
+
## Model Comparison
|
123 |
+
### By Top-1
|
124 |
+
|
125 |
+
| model |top1 |top1_err|top5 |top5_err|param_count|img_size|
|
126 |
+
|--------------------------------------------------------------------------------------------------|------|--------|------|--------|-----------|--------|
|
127 |
+
| [mobilenetv4_conv_large.e600_r384_in1k](http://hf.co/timm/mobilenetv4_conv_large.e600_r384_in1k) |83.392|16.608 |96.622 |3.378 |32.59 |448 |
|
128 |
+
| [mobilenetv4_conv_large.e600_r384_in1k](http://hf.co/timm/mobilenetv4_conv_large.e600_r384_in1k) |82.952|17.048 |96.266 |3.734 |32.59 |384 |
|
129 |
+
| [mobilenetv4_conv_large.e500_r256_in1k](http://hf.co/timm/mobilenetv4_conv_large.e500_r256_in1k) |82.674|17.326 |96.31 |3.69 |32.59 |320 |
|
130 |
+
| [mobilenetv4_conv_large.e500_r256_in1k](http://hf.co/timm/mobilenetv4_conv_large.e500_r256_in1k) |81.862|18.138 |95.69 |4.31 |32.59 |256 |
|
131 |
+
| [mobilenetv4_hybrid_medium.e500_r224_in1k](http://hf.co/timm/mobilenetv4_hybrid_medium.e500_r224_in1k) |81.276|18.724 |95.742|4.258 |11.07 |256 |
|
132 |
+
| [mobilenetv4_conv_medium.e500_r256_in1k](http://hf.co/timm/mobilenetv4_conv_medium.e500_r256_in1k) |80.858|19.142 |95.768|4.232 |9.72 |320 |
|
133 |
+
| [mobilenetv4_hybrid_medium.e500_r224_in1k](http://hf.co/timm/mobilenetv4_hybrid_medium.e500_r224_in1k) |80.442|19.558 |95.38 |4.62 |11.07 |224 |
|
134 |
+
| [mobilenetv4_conv_blur_medium.e500_r224_in1k](http://hf.co/timm/mobilenetv4_conv_blur_medium.e500_r224_in1k) |80.142|19.858 |95.298|4.702 |9.72 |256 |
|
135 |
+
| [mobilenetv4_conv_medium.e500_r256_in1k](http://hf.co/timm/mobilenetv4_conv_medium.e500_r256_in1k) |79.928|20.072 |95.184|4.816 |9.72 |256 |
|
136 |
+
| [mobilenetv4_conv_medium.e500_r224_in1k](http://hf.co/timm/mobilenetv4_conv_medium.e500_r224_in1k) |79.808|20.192 |95.186|4.814 |9.72 |256 |
|
137 |
+
| [mobilenetv4_conv_blur_medium.e500_r224_in1k](http://hf.co/timm/mobilenetv4_conv_blur_medium.e500_r224_in1k) |79.438|20.562 |94.932|5.068 |9.72 |224 |
|
138 |
+
| [mobilenetv4_conv_medium.e500_r224_in1k](http://hf.co/timm/mobilenetv4_conv_medium.e500_r224_in1k) |79.094|20.906 |94.77 |5.23 |9.72 |224 |
|
139 |
+
| [mobilenetv4_conv_small.e1200_r224_in1k](http://hf.co/timm/mobilenetv4_conv_small.e1200_r224_in1k) |74.292|25.708 |92.116|7.884 |3.77 |256 |
|
140 |
+
| [mobilenetv4_conv_small.e1200_r224_in1k](http://hf.co/timm/mobilenetv4_conv_small.e1200_r224_in1k) |73.454|26.546 |91.34 |8.66 |3.77 |224 |
|
141 |
+
|
142 |
+
## Citation
|
143 |
+
```bibtex
|
144 |
+
@article{qin2024mobilenetv4,
|
145 |
+
title={MobileNetV4-Universal Models for the Mobile Ecosystem},
|
146 |
+
author={Qin, Danfeng and Leichner, Chas and Delakis, Manolis and Fornoni, Marco and Luo, Shixin and Yang, Fan and Wang, Weijun and Banbury, Colby and Ye, Chengxi and Akin, Berkin and others},
|
147 |
+
journal={arXiv preprint arXiv:2404.10518},
|
148 |
+
year={2024}
|
149 |
+
}
|
150 |
+
```
|
151 |
+
```bibtex
|
152 |
+
@misc{rw2019timm,
|
153 |
+
author = {Ross Wightman},
|
154 |
+
title = {PyTorch Image Models},
|
155 |
+
year = {2019},
|
156 |
+
publisher = {GitHub},
|
157 |
+
journal = {GitHub repository},
|
158 |
+
doi = {10.5281/zenodo.4414861},
|
159 |
+
howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
|
160 |
+
}
|
161 |
+
```
|
config.json
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architecture": "mobilenetv4_conv_large",
|
3 |
+
"num_classes": 1000,
|
4 |
+
"num_features": 960,
|
5 |
+
"pretrained_cfg": {
|
6 |
+
"tag": "e600_r384_in1k",
|
7 |
+
"custom_load": false,
|
8 |
+
"input_size": [
|
9 |
+
3,
|
10 |
+
384,
|
11 |
+
384
|
12 |
+
],
|
13 |
+
"test_input_size": [
|
14 |
+
3,
|
15 |
+
448,
|
16 |
+
448
|
17 |
+
],
|
18 |
+
"fixed_input_size": false,
|
19 |
+
"interpolation": "bicubic",
|
20 |
+
"crop_pct": 0.95,
|
21 |
+
"test_crop_pct": 1.0,
|
22 |
+
"crop_mode": "center",
|
23 |
+
"mean": [
|
24 |
+
0.485,
|
25 |
+
0.456,
|
26 |
+
0.406
|
27 |
+
],
|
28 |
+
"std": [
|
29 |
+
0.229,
|
30 |
+
0.224,
|
31 |
+
0.225
|
32 |
+
],
|
33 |
+
"num_classes": 1000,
|
34 |
+
"pool_size": [
|
35 |
+
12,
|
36 |
+
12
|
37 |
+
],
|
38 |
+
"first_conv": "conv_stem",
|
39 |
+
"classifier": "classifier"
|
40 |
+
}
|
41 |
+
}
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e7e2c1035dec14ac89c325183211eee5b593ad04d51625f22db5cdd8f3054ca5
|
3 |
+
size 131022456
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:14098c0d04f1b12fdabb6f6831c2e782792516995061d8771fd8e7486d6e52c4
|
3 |
+
size 131181986
|