timm
/

Image Classification
timm
PyTorch
Safetensors
rwightman HF staff commited on
Commit
6d96586
1 Parent(s): 70cce1d
Files changed (4) hide show
  1. README.md +140 -0
  2. config.json +33 -0
  3. model.safetensors +3 -0
  4. pytorch_model.bin +3 -0
README.md ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - image-classification
4
+ - timm
5
+ library_tag: timm
6
+ license: apache-2.0
7
+ datasets:
8
+ - imagenet-1k
9
+ - imagenet-22k
10
+ ---
11
+ # Model card for eva02_base_patch14_448.mim_in22k_ft_in22k_in1k
12
+
13
+ An EVA02 image classification model. Pretrained on ImageNet-22k with masked image modeling (using EVA-CLIP as a MIM teacher) and fine-tuned on ImageNet-22k then on ImageNet-1k by paper authors.
14
+
15
+ EVA-02 models are vision transformers with mean pooling, SwiGLU, Rotary Position Embeddings (ROPE), and extra LN in MLP (for Base & Large).
16
+
17
+ NOTE: `timm` checkpoints are float32 for consistency with other models. Original checkpoints are float16 or bfloat16 in some cases, see originals if that's preferred.
18
+
19
+
20
+ ## Model Details
21
+ - **Model Type:** Image classification / feature backbone
22
+ - **Model Stats:**
23
+ - Params (M): 87.1
24
+ - GMACs: 107.1
25
+ - Activations (M): 259.1
26
+ - Image size: 448 x 448
27
+ - **Papers:**
28
+ - EVA-02: A Visual Representation for Neon Genesis: https://arxiv.org/abs/2303.11331
29
+ - EVA-CLIP: Improved Training Techniques for CLIP at Scale: https://arxiv.org/abs/2303.15389
30
+ - **Original:**
31
+ - https://github.com/baaivision/EVA
32
+ - https://huggingface.co/Yuxin-CV/EVA-02
33
+ - **Pretrain Dataset:** ImageNet-22k
34
+ - **Dataset:** ImageNet-1k
35
+
36
+ ## Model Usage
37
+ ### Image Classification
38
+ ```python
39
+ from urllib.request import urlopen
40
+ from PIL import Image
41
+ import timm
42
+
43
+ img = Image.open(urlopen(
44
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
45
+ ))
46
+
47
+ model = timm.create_model('eva02_base_patch14_448.mim_in22k_ft_in22k_in1k', pretrained=True)
48
+ model = model.eval()
49
+
50
+ # get model specific transforms (normalization, resize)
51
+ data_config = timm.data.resolve_model_data_config(model)
52
+ transforms = timm.data.create_transform(**data_config, is_training=False)
53
+
54
+ output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
55
+
56
+ top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
57
+ ```
58
+
59
+ ### Image Embeddings
60
+ ```python
61
+ from urllib.request import urlopen
62
+ from PIL import Image
63
+ import timm
64
+
65
+ img = Image.open(urlopen(
66
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
67
+ ))
68
+
69
+ model = timm.create_model(
70
+ 'eva02_base_patch14_448.mim_in22k_ft_in22k_in1k',
71
+ pretrained=True,
72
+ num_classes=0, # remove classifier nn.Linear
73
+ )
74
+ model = model.eval()
75
+
76
+ # get model specific transforms (normalization, resize)
77
+ data_config = timm.data.resolve_model_data_config(model)
78
+ transforms = timm.data.create_transform(**data_config, is_training=False)
79
+
80
+ output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor
81
+
82
+ # or equivalently (without needing to set num_classes=0)
83
+
84
+ output = model.forward_features(transforms(img).unsqueeze(0))
85
+ # output is unpooled, a (1, 1025, 768) shaped tensor
86
+
87
+ output = model.forward_head(output, pre_logits=True)
88
+ # output is a (1, num_features) shaped tensor
89
+ ```
90
+
91
+ ## Model Comparison
92
+ Explore the dataset and runtime metrics of this model in timm [model results](https://github.com/huggingface/pytorch-image-models/tree/main/results).
93
+
94
+ |model |top1 |top5 |param_count|img_size|
95
+ |-----------------------------------------------|------|------|-----------|--------|
96
+ |eva02_large_patch14_448.mim_m38m_ft_in22k_in1k |90.054|99.042|305.08 |448 |
97
+ |eva02_large_patch14_448.mim_in22k_ft_in22k_in1k|89.946|99.01 |305.08 |448 |
98
+ |eva_giant_patch14_560.m30m_ft_in22k_in1k |89.792|98.992|1014.45 |560 |
99
+ |eva02_large_patch14_448.mim_in22k_ft_in1k |89.626|98.954|305.08 |448 |
100
+ |eva02_large_patch14_448.mim_m38m_ft_in1k |89.57 |98.918|305.08 |448 |
101
+ |eva_giant_patch14_336.m30m_ft_in22k_in1k |89.56 |98.956|1013.01 |336 |
102
+ |eva_giant_patch14_336.clip_ft_in1k |89.466|98.82 |1013.01 |336 |
103
+ |eva_large_patch14_336.in22k_ft_in22k_in1k |89.214|98.854|304.53 |336 |
104
+ |eva_giant_patch14_224.clip_ft_in1k |88.882|98.678|1012.56 |224 |
105
+ |eva02_base_patch14_448.mim_in22k_ft_in22k_in1k |88.692|98.722|87.12 |448 |
106
+ |eva_large_patch14_336.in22k_ft_in1k |88.652|98.722|304.53 |336 |
107
+ |eva_large_patch14_196.in22k_ft_in22k_in1k |88.592|98.656|304.14 |196 |
108
+ |eva02_base_patch14_448.mim_in22k_ft_in1k |88.23 |98.564|87.12 |448 |
109
+ |eva_large_patch14_196.in22k_ft_in1k |87.934|98.504|304.14 |196 |
110
+ |eva02_small_patch14_336.mim_in22k_ft_in1k |85.74 |97.614|22.13 |336 |
111
+ |eva02_tiny_patch14_336.mim_in22k_ft_in1k |80.658|95.524|5.76 |336 |
112
+
113
+ ## Citation
114
+ ```bibtex
115
+ @article{EVA02,
116
+ title={EVA-02: A Visual Representation for Neon Genesis},
117
+ author={Fang, Yuxin and Sun, Quan and Wang, Xinggang and Huang, Tiejun and Wang, Xinlong and Cao, Yue},
118
+ journal={arXiv preprint arXiv:2303.11331},
119
+ year={2023}
120
+ }
121
+ ```
122
+ ```bibtex
123
+ @article{EVA-CLIP,
124
+ title={EVA-02: A Visual Representation for Neon Genesis},
125
+ author={Sun, Quan and Fang, Yuxin and Wu, Ledell and Wang, Xinlong and Cao, Yue},
126
+ journal={arXiv preprint arXiv:2303.15389},
127
+ year={2023}
128
+ }
129
+ ```
130
+ ```bibtex
131
+ @misc{rw2019timm,
132
+ author = {Ross Wightman},
133
+ title = {PyTorch Image Models},
134
+ year = {2019},
135
+ publisher = {GitHub},
136
+ journal = {GitHub repository},
137
+ doi = {10.5281/zenodo.4414861},
138
+ howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
139
+ }
140
+ ```
config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architecture": "eva02_base_patch14_448",
3
+ "num_classes": 1000,
4
+ "num_features": 768,
5
+ "global_pool": "avg",
6
+ "pretrained_cfg": {
7
+ "tag": "mim_in22k_ft_in22k_in1k",
8
+ "custom_load": false,
9
+ "input_size": [
10
+ 3,
11
+ 448,
12
+ 448
13
+ ],
14
+ "fixed_input_size": true,
15
+ "interpolation": "bicubic",
16
+ "crop_pct": 1.0,
17
+ "crop_mode": "squash",
18
+ "mean": [
19
+ 0.48145466,
20
+ 0.4578275,
21
+ 0.40821073
22
+ ],
23
+ "std": [
24
+ 0.26862954,
25
+ 0.26130258,
26
+ 0.27577711
27
+ ],
28
+ "num_classes": 1000,
29
+ "pool_size": null,
30
+ "first_conv": "patch_embed.proj",
31
+ "classifier": "head"
32
+ }
33
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:533937d6f9f8f8d4f50627ef0d00829a5015861a5b67e1c69c5a5e45b7dc2609
3
+ size 348492484
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dbbfef826976527b9060875233f4cbeb61f9b14b8352e4116e2769c38593f054
3
+ size 348553277