rwightman HF staff commited on
Commit
4bfbee1
1 Parent(s): 4b834de
Files changed (4) hide show
  1. README.md +136 -0
  2. config.json +42 -0
  3. model.safetensors +3 -0
  4. pytorch_model.bin +3 -0
README.md ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - image-classification
4
+ - timm
5
+ library_name: timm
6
+ license: mit
7
+ datasets:
8
+ - imagenet-1k
9
+ ---
10
+ # Model card for edgenext_base.usi_in1k
11
+
12
+ An EdgeNeXt image classification model. Trained on ImageNet-1k by paper authors using distillation (`USI` as per `Solving ImageNet`).
13
+
14
+ ## Model Details
15
+ - **Model Type:** Image classification / feature backbone
16
+ - **Model Stats:**
17
+ - Params (M): 18.5
18
+ - GMACs: 3.8
19
+ - Activations (M): 15.6
20
+ - Image size: train = 256 x 256, test = 320 x 320
21
+ - **Papers:**
22
+ - EdgeNeXt: Efficiently Amalgamated CNN-Transformer Architecture for Mobile Vision Applications: https://arxiv.org/abs/2206.10589
23
+ - Solving ImageNet: a Unified Scheme for Training any Backbone to Top Results: https://arxiv.org/abs/2204.03475
24
+ - **Dataset:** ImageNet-1k
25
+ - **Original:** https://github.com/mmaaz60/EdgeNeXt
26
+
27
+ ## Model Usage
28
+ ### Image Classification
29
+ ```python
30
+ from urllib.request import urlopen
31
+ from PIL import Image
32
+ import timm
33
+
34
+ img = Image.open(urlopen(
35
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
36
+ ))
37
+
38
+ model = timm.create_model('edgenext_base.usi_in1k', pretrained=True)
39
+ model = model.eval()
40
+
41
+ # get model specific transforms (normalization, resize)
42
+ data_config = timm.data.resolve_model_data_config(model)
43
+ transforms = timm.data.create_transform(**data_config, is_training=False)
44
+
45
+ output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
46
+
47
+ top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
48
+ ```
49
+
50
+ ### Feature Map Extraction
51
+ ```python
52
+ from urllib.request import urlopen
53
+ from PIL import Image
54
+ import timm
55
+
56
+ img = Image.open(urlopen(
57
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
58
+ ))
59
+
60
+ model = timm.create_model(
61
+ 'edgenext_base.usi_in1k',
62
+ pretrained=True,
63
+ features_only=True,
64
+ )
65
+ model = model.eval()
66
+
67
+ # get model specific transforms (normalization, resize)
68
+ data_config = timm.data.resolve_model_data_config(model)
69
+ transforms = timm.data.create_transform(**data_config, is_training=False)
70
+
71
+ output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
72
+
73
+ for o in output:
74
+ # print shape of each feature map in output
75
+ # e.g.:
76
+ # torch.Size([1, 80, 64, 64])
77
+ # torch.Size([1, 160, 32, 32])
78
+ # torch.Size([1, 288, 16, 16])
79
+ # torch.Size([1, 584, 8, 8])
80
+
81
+ print(o.shape)
82
+ ```
83
+
84
+ ### Image Embeddings
85
+ ```python
86
+ from urllib.request import urlopen
87
+ from PIL import Image
88
+ import timm
89
+
90
+ img = Image.open(urlopen(
91
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
92
+ ))
93
+
94
+ model = timm.create_model(
95
+ 'edgenext_base.usi_in1k',
96
+ pretrained=True,
97
+ num_classes=0, # remove classifier nn.Linear
98
+ )
99
+ model = model.eval()
100
+
101
+ # get model specific transforms (normalization, resize)
102
+ data_config = timm.data.resolve_model_data_config(model)
103
+ transforms = timm.data.create_transform(**data_config, is_training=False)
104
+
105
+ output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor
106
+
107
+ # or equivalently (without needing to set num_classes=0)
108
+
109
+ output = model.forward_features(transforms(img).unsqueeze(0))
110
+ # output is unpooled, a (1, 584, 8, 8) shaped tensor
111
+
112
+ output = model.forward_head(output, pre_logits=True)
113
+ # output is a (1, num_features) shaped tensor
114
+ ```
115
+
116
+ ## Citation
117
+ ```bibtex
118
+ @inproceedings{Maaz2022EdgeNeXt,
119
+ title={EdgeNeXt: Efficiently Amalgamated CNN-Transformer Architecture for Mobile Vision Applications},
120
+ author={Muhammad Maaz and Abdelrahman Shaker and Hisham Cholakkal and Salman Khan and Syed Waqas Zamir and Rao Muhammad Anwer and Fahad Shahbaz Khan},
121
+ booktitle={International Workshop on Computational Aspects of Deep Learning at 17th European Conference on Computer Vision (CADL2022)},
122
+ year={2022},
123
+ organization={Springer}
124
+ }
125
+ ```
126
+ ```bibtex
127
+ @misc{https://doi.org/10.48550/arxiv.2204.03475,
128
+ doi = {10.48550/ARXIV.2204.03475},
129
+ url = {https://arxiv.org/abs/2204.03475},
130
+ author = {Ridnik, Tal and Lawen, Hussam and Ben-Baruch, Emanuel and Noy, Asaf},
131
+ keywords = {Computer Vision and Pattern Recognition (cs.CV), Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},
132
+ title = {Solving ImageNet: a Unified Scheme for Training any Backbone to Top Results},
133
+ publisher = {arXiv},
134
+ year = {2022},
135
+ }
136
+ ```
config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architecture": "edgenext_base",
3
+ "num_classes": 1000,
4
+ "num_features": 584,
5
+ "global_pool": "avg",
6
+ "pretrained_cfg": {
7
+ "tag": "usi_in1k",
8
+ "custom_load": false,
9
+ "input_size": [
10
+ 3,
11
+ 256,
12
+ 256
13
+ ],
14
+ "test_input_size": [
15
+ 3,
16
+ 320,
17
+ 320
18
+ ],
19
+ "fixed_input_size": false,
20
+ "interpolation": "bicubic",
21
+ "crop_pct": 0.95,
22
+ "test_crop_pct": 1.0,
23
+ "crop_mode": "center",
24
+ "mean": [
25
+ 0.485,
26
+ 0.456,
27
+ 0.406
28
+ ],
29
+ "std": [
30
+ 0.229,
31
+ 0.224,
32
+ 0.225
33
+ ],
34
+ "num_classes": 1000,
35
+ "pool_size": [
36
+ 8,
37
+ 8
38
+ ],
39
+ "first_conv": "stem.0",
40
+ "classifier": "head.fc"
41
+ }
42
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44064d77619abf98e25e3ece1a2ad058d958bfc78a1a55312e338174658daa54
3
+ size 74066124
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2071aee44196e23447da90e855c21eb99cd2f101d03dbdee8d0dbdc52fafe95f
3
+ size 74122661