Image Classification
timm
Safetensors
Transformers
rwightman commited on
Commit
ae66b77
·
verified ·
1 Parent(s): b79b341

Add model

Browse files
Files changed (3) hide show
  1. README.md +139 -0
  2. config.json +41 -0
  3. model.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - image-classification
4
+ - timm
5
+ - transformers
6
+ pipeline_tag: image-classification
7
+ library_name: timm
8
+ license: mit
9
+ datasets:
10
+ - imagenet-1k
11
+ ---
12
+ # Model card for efficientvim_m2.e300_in1k
13
+
14
+ An EfficientViM image classification model. Trained on ImageNet-1k by paper authors.
15
+
16
+ ## Model Details
17
+ - **Model Type:** Image Classification / Feature Encoder
18
+ - **Model Stats:**
19
+ - Params (M): 13.9
20
+ - GMACs: 0.4
21
+ - Activations (M): 1.9
22
+ - Image size: 224 x 224
23
+ - **Dataset:** ImageNet-1k
24
+ - **Papers:**
25
+ - EfficientViM: Efficient Vision Mamba with Hidden State Mixer based State Space Duality: https://arxiv.org/abs/2411.15241
26
+ - **Original:** https://github.com/mlvlab/EfficientViM
27
+
28
+ ## Model Usage
29
+ ### Image Classification
30
+ ```python
31
+ from urllib.request import urlopen
32
+ from PIL import Image
33
+ import torch
34
+ import timm
35
+
36
+ img = Image.open(urlopen(
37
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
38
+ ))
39
+
40
+ model = timm.create_model('efficientvim_m2.e300_in1k', pretrained=True)
41
+ model = model.eval()
42
+
43
+ # get model specific transforms (normalization, resize)
44
+ data_config = timm.data.resolve_model_data_config(model)
45
+ transforms = timm.data.create_transform(**data_config, is_training=False)
46
+
47
+ output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
48
+
49
+ top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
50
+ ```
51
+
52
+ ### Feature Map Extraction
53
+ ```python
54
+ from urllib.request import urlopen
55
+ from PIL import Image
56
+ import timm
57
+
58
+ img = Image.open(urlopen(
59
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
60
+ ))
61
+
62
+ model = timm.create_model(
63
+ 'efficientvim_m2.e300_in1k',
64
+ pretrained=True,
65
+ features_only=True,
66
+ )
67
+ model = model.eval()
68
+
69
+ # get model specific transforms (normalization, resize)
70
+ data_config = timm.data.resolve_model_data_config(model)
71
+ transforms = timm.data.create_transform(**data_config, is_training=False)
72
+
73
+ output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
74
+
75
+ for o in output:
76
+ # print shape of each feature map in output
77
+ # e.g.:
78
+ # torch.Size([1, 128, 14, 14])
79
+ # torch.Size([1, 256, 7, 7])
80
+ # torch.Size([1, 512, 4, 4])
81
+
82
+ print(o.shape)
83
+ ```
84
+
85
+ ### Image Embeddings
86
+ ```python
87
+ from urllib.request import urlopen
88
+ from PIL import Image
89
+ import timm
90
+
91
+ img = Image.open(urlopen(
92
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
93
+ ))
94
+
95
+ model = timm.create_model(
96
+ 'efficientvim_m2.e300_in1k',
97
+ pretrained=True,
98
+ num_classes=0, # remove classifier nn.Linear
99
+ )
100
+ model = model.eval()
101
+
102
+ # get model specific transforms (normalization, resize)
103
+ data_config = timm.data.resolve_model_data_config(model)
104
+ transforms = timm.data.create_transform(**data_config, is_training=False)
105
+
106
+ output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor
107
+
108
+ # or equivalently (without needing to set num_classes=0)
109
+
110
+ output = model.forward_features(transforms(img).unsqueeze(0))
111
+ # output is a list of unpooled tensors with shapes [(1, 128, 49), (1, 256, 25), (1, 512, 9), (1, 512, 16)]
112
+
113
+ output = model.forward_head(output, pre_logits=True)
114
+ # output is a (1, num_features) shaped tensor
115
+ ```
116
+
117
+ ## Model Comparison
118
+ Explore the dataset and runtime metrics of this model in timm [model results](https://github.com/huggingface/pytorch-image-models/tree/main/results).
119
+
120
+ ## Citation
121
+ ```bibtex
122
+ @inproceedings{lee2025efficientvim,
123
+ title={EfficientViM: Efficient Vision Mamba with Hidden State Mixer based State Space Duality},
124
+ author={Lee, Sanghyeok and Choi, Joonmyung and Kim, Hyunwoo J.},
125
+ booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
126
+ year={2025}
127
+ }
128
+ ```
129
+ ```bibtex
130
+ @misc{rw2019timm,
131
+ author = {Ross Wightman},
132
+ title = {PyTorch Image Models},
133
+ year = {2019},
134
+ publisher = {GitHub},
135
+ journal = {GitHub repository},
136
+ doi = {10.5281/zenodo.4414861},
137
+ howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
138
+ }
139
+ ```
config.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architecture": "efficientvim_m2",
3
+ "num_classes": 1000,
4
+ "num_features": 1408,
5
+ "global_pool": "avg",
6
+ "pretrained_cfg": {
7
+ "tag": "e300_in1k",
8
+ "custom_load": false,
9
+ "input_size": [
10
+ 3,
11
+ 224,
12
+ 224
13
+ ],
14
+ "fixed_input_size": false,
15
+ "interpolation": "bicubic",
16
+ "crop_pct": 0.875,
17
+ "crop_mode": "center",
18
+ "mean": [
19
+ 0.485,
20
+ 0.456,
21
+ 0.406
22
+ ],
23
+ "std": [
24
+ 0.229,
25
+ 0.224,
26
+ 0.225
27
+ ],
28
+ "num_classes": 1000,
29
+ "pool_size": null,
30
+ "first_conv": "patch_embed.conv.0.conv",
31
+ "classifier": [
32
+ "heads.0",
33
+ "heads.1",
34
+ "heads.2",
35
+ "heads.3"
36
+ ],
37
+ "license": "mit",
38
+ "origin_url": "https://github.com/mlvlab/EfficientViM",
39
+ "paper_ids": "arXiv:2411.15241"
40
+ }
41
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6f208e4b7f119f9560c6b832f7d346f501b098d475c9128b02817c6014056bcb
3
+ size 55814552