rwightman HF staff commited on
Commit
bff77af
1 Parent(s): 8720270
Files changed (4) hide show
  1. README.md +132 -0
  2. config.json +41 -0
  3. model.safetensors +3 -0
  4. pytorch_model.bin +3 -0
README.md ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - image-classification
4
+ - timm
5
+ library_name: timm
6
+ license: apache-2.0
7
+ datasets:
8
+ - imagenet-1k
9
+ - imagenet-22k
10
+ ---
11
+ # Model card for hgnetv2_b5.ssld_stage1_in22k_in1k
12
+
13
+ A HGNet-V2 (High Performance GPU Net) image classification model. Trained by model authors on mined ImageNet-22k and ImageNet-1k using SSLD distillation.
14
+
15
+ Please see details at https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/models/ImageNet1k/PP-HGNetV2.md
16
+
17
+
18
+ ## Model Details
19
+ - **Model Type:** Image classification / feature backbone
20
+ - **Model Stats:**
21
+ - Params (M): 39.6
22
+ - GMACs: 6.6
23
+ - Activations (M): 11.2
24
+ - Image size: train = 224 x 224, test = 288 x 288
25
+ - **Pretrain Dataset:** ImageNet-22k
26
+ - **Dataset:** ImageNet-1k
27
+ - **Papers:**
28
+ - Model paper unknown: TBD
29
+ - Beyond Self-Supervision: A Simple Yet Effective Network Distillation Alternative to Improve Backbones: https://arxiv.org/abs/2103.05959
30
+ - **Original:** https://github.com/PaddlePaddle/PaddleClas
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('hgnetv2_b5.ssld_stage1_in22k_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
+ 'hgnetv2_b5.ssld_stage1_in22k_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, 128, 56, 56])
82
+ # torch.Size([1, 512, 28, 28])
83
+ # torch.Size([1, 1024, 14, 14])
84
+ # torch.Size([1, 2048, 7, 7])
85
+
86
+ print(o.shape)
87
+ ```
88
+
89
+ ### Image Embeddings
90
+ ```python
91
+ from urllib.request import urlopen
92
+ from PIL import Image
93
+ import timm
94
+
95
+ img = Image.open(urlopen(
96
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
97
+ ))
98
+
99
+ model = timm.create_model(
100
+ 'hgnetv2_b5.ssld_stage1_in22k_in1k',
101
+ pretrained=True,
102
+ num_classes=0, # remove classifier nn.Linear
103
+ )
104
+ model = model.eval()
105
+
106
+ # get model specific transforms (normalization, resize)
107
+ data_config = timm.data.resolve_model_data_config(model)
108
+ transforms = timm.data.create_transform(**data_config, is_training=False)
109
+
110
+ output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor
111
+
112
+ # or equivalently (without needing to set num_classes=0)
113
+
114
+ output = model.forward_features(transforms(img).unsqueeze(0))
115
+ # output is unpooled, a (1, 2048, 7, 7) shaped tensor
116
+
117
+ output = model.forward_head(output, pre_logits=True)
118
+ # output is a (1, num_features) shaped tensor
119
+ ```
120
+
121
+ ## Model Comparison
122
+ ### By Top-1
123
+
124
+ ## Citation
125
+ ```bibtex
126
+ @article{cui2021beyond,
127
+ title={Beyond Self-Supervision: A Simple Yet Effective Network Distillation Alternative to Improve Backbones},
128
+ author={Cui, Cheng and Guo, Ruoyu and Du, Yuning and He, Dongliang and Li, Fu and Wu, Zewu and Liu, Qiwen and Wen, Shilei and Huang, Jizhou and Hu, Xiaoguang and others},
129
+ journal={arXiv preprint arXiv:2103.05959},
130
+ year={2021}
131
+ }
132
+ ```
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architecture": "hgnetv2_b5",
3
+ "num_classes": 1000,
4
+ "num_features": 2048,
5
+ "pretrained_cfg": {
6
+ "tag": "ssld_stage1_in22k_in1k",
7
+ "custom_load": false,
8
+ "input_size": [
9
+ 3,
10
+ 224,
11
+ 224
12
+ ],
13
+ "test_input_size": [
14
+ 3,
15
+ 288,
16
+ 288
17
+ ],
18
+ "fixed_input_size": false,
19
+ "interpolation": "bicubic",
20
+ "crop_pct": 0.965,
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
+ 7,
36
+ 7
37
+ ],
38
+ "first_conv": "stem.stem1.conv",
39
+ "classifier": "head.fc"
40
+ }
41
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:502ca89c12f52d53a2a1e1244e7bef79a0dab57220d890374c40051be6662e0a
3
+ size 158740080
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:642e8ef4f5924982ec2275c92f32b81aa78e2bc23728b06f40314c0ed90e0b0f
3
+ size 158947270