rwightman HF staff commited on
Commit
d05e583
1 Parent(s): 5948a83

Update model config and README

Browse files
Files changed (3) hide show
  1. README.md +140 -2
  2. config.json +1 -0
  3. model.safetensors +3 -0
README.md CHANGED
@@ -2,6 +2,144 @@
2
  tags:
3
  - image-classification
4
  - timm
5
- library_tag: timm
 
 
 
6
  ---
7
- # Model card for fbnetc_100.rmsp_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 fbnetc_100.rmsp_in1k
11
+
12
+ A FBNet image classification model. Trained on ImageNet-1k in `timm` using recipe template described below.
13
+
14
+ Recipe details:
15
+ * A simple RmsProp based recipe without RandAugment. Using RandomErasing, mixup, dropout, standard random-resize-crop augmentation.
16
+ * RMSProp (TF 1.0 behaviour) optimizer, EMA weight averaging
17
+ * Step (exponential decay w/ staircase) LR schedule with warmup
18
+
19
+
20
+ ## Model Details
21
+ - **Model Type:** Image classification / feature backbone
22
+ - **Model Stats:**
23
+ - Params (M): 5.6
24
+ - GMACs: 0.4
25
+ - Activations (M): 6.5
26
+ - Image size: 224 x 224
27
+ - **Papers:**
28
+ - FBNet: Hardware-Aware Efficient ConvNet Design via Differentiable Neural Architecture Search: https://arxiv.org/abs/1812.03443
29
+ - **Dataset:** ImageNet-1k
30
+ - **Original:** https://github.com/huggingface/pytorch-image-models
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('fbnetc_100.rmsp_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
+ 'fbnetc_100.rmsp_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, 16, 112, 112])
82
+ # torch.Size([1, 24, 56, 56])
83
+ # torch.Size([1, 32, 28, 28])
84
+ # torch.Size([1, 112, 14, 14])
85
+ # torch.Size([1, 352, 7, 7])
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
+ 'fbnetc_100.rmsp_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, 1984, 7, 7) 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
+ Explore the dataset and runtime metrics of this model in timm [model results](https://github.com/huggingface/pytorch-image-models/tree/main/results).
124
+
125
+ ## Citation
126
+ ```bibtex
127
+ @misc{rw2019timm,
128
+ author = {Ross Wightman},
129
+ title = {PyTorch Image Models},
130
+ year = {2019},
131
+ publisher = {GitHub},
132
+ journal = {GitHub repository},
133
+ doi = {10.5281/zenodo.4414861},
134
+ howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
135
+ }
136
+ ```
137
+ ```bibtex
138
+ @inproceedings{wu2019fbnet,
139
+ title={Fbnet: Hardware-aware efficient convnet design via differentiable neural architecture search},
140
+ author={Wu, Bichen and Dai, Xiaoliang and Zhang, Peizhao and Wang, Yanghan and Sun, Fei and Wu, Yiming and Tian, Yuandong and Vajda, Peter and Jia, Yangqing and Keutzer, Kurt},
141
+ booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
142
+ pages={10734--10742},
143
+ year={2019}
144
+ }
145
+ ```
config.json CHANGED
@@ -3,6 +3,7 @@
3
  "num_classes": 1000,
4
  "num_features": 1984,
5
  "pretrained_cfg": {
 
6
  "custom_load": false,
7
  "input_size": [
8
  3,
 
3
  "num_classes": 1000,
4
  "num_features": 1984,
5
  "pretrained_cfg": {
6
+ "tag": "rmsp_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:508393c8e32a56d5f7effa21bf8ffe7097f9c44abe81e5cc53fea7d10b357d68
3
+ size 22501546