rwightman HF staff commited on
Commit
03b1b3b
1 Parent(s): 4305909

Update model config and README

Browse files
Files changed (2) hide show
  1. README.md +136 -2
  2. model.safetensors +3 -0
README.md CHANGED
@@ -2,6 +2,140 @@
2
  tags:
3
  - image-classification
4
  - timm
5
- library_tag: timm
 
 
 
 
6
  ---
7
- # Model card for mobilenetv3_large_100.miil_in21k_ft_in1k
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  tags:
3
  - image-classification
4
  - timm
5
+ library_name: timm
6
+ license: apache-2.0
7
+ datasets:
8
+ - imagenet-1k
9
+ - imagenet-21k-p
10
  ---
11
+ # Model card for mobilenetv3_large_100.miil_in21k_ft_in1k
12
+
13
+ A MobileNet-v3 image classification model. Petrained on ImageNet-21k-P and fine-tuned on ImageNet-1k by Alibaba MIIL.
14
+
15
+
16
+ ## Model Details
17
+ - **Model Type:** Image classification / feature backbone
18
+ - **Model Stats:**
19
+ - Params (M): 5.5
20
+ - GMACs: 0.2
21
+ - Activations (M): 4.4
22
+ - Image size: 224 x 224
23
+ - **Papers:**
24
+ - Searching for MobileNetV3: https://arxiv.org/abs/1905.02244
25
+ - **Dataset:** ImageNet-1k
26
+ - **Pretrain Dataset:** ImageNet-21k-P
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('mobilenetv3_large_100.miil_in21k_ft_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
+ 'mobilenetv3_large_100.miil_in21k_ft_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, 112, 112])
78
+ # torch.Size([1, 24, 56, 56])
79
+ # torch.Size([1, 40, 28, 28])
80
+ # torch.Size([1, 112, 14, 14])
81
+ # torch.Size([1, 960, 7, 7])
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
+ 'mobilenetv3_large_100.miil_in21k_ft_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, 960, 7, 7) 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{howard2019searching,
124
+ title={Searching for mobilenetv3},
125
+ author={Howard, Andrew and Sandler, Mark and Chu, Grace and Chen, Liang-Chieh and Chen, Bo and Tan, Mingxing and Wang, Weijun and Zhu, Yukun and Pang, Ruoming and Vasudevan, Vijay and others},
126
+ booktitle={Proceedings of the IEEE/CVF international conference on computer vision},
127
+ pages={1314--1324},
128
+ year={2019}
129
+ }
130
+ ```
131
+ ```bibtex
132
+ @misc{rw2019timm,
133
+ author = {Ross Wightman},
134
+ title = {PyTorch Image Models},
135
+ year = {2019},
136
+ publisher = {GitHub},
137
+ journal = {GitHub repository},
138
+ doi = {10.5281/zenodo.4414861},
139
+ howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
140
+ }
141
+ ```
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:436a40242a4b102d92dd5f0d6fc9e15c23aafc45dfa3a8cf00a0353c4f854eb0
3
+ size 22058004