Add model
Browse files- README.md +109 -0
- config.json +36 -0
- pytorch_model.bin +3 -0
README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- image-classification
|
| 4 |
+
- timm
|
| 5 |
+
library_tag: timm
|
| 6 |
+
license: apache-2.0
|
| 7 |
+
datasets:
|
| 8 |
+
- imagenet-1k
|
| 9 |
+
---
|
| 10 |
+
# Model card for efficientformer_l1.snap_dist_in1k
|
| 11 |
+
|
| 12 |
+
A EfficientFormer image classification model. Pretrained with distillation on ImageNet-1k.
|
| 13 |
+
|
| 14 |
+
## Model Details
|
| 15 |
+
- **Model Type:** Image classification / feature backbone
|
| 16 |
+
- **Model Stats:**
|
| 17 |
+
- Params (M): 12.3
|
| 18 |
+
- GMACs: 1.3
|
| 19 |
+
- Activations (M): 5.5
|
| 20 |
+
- Image size: 224 x 224
|
| 21 |
+
- **Original:** https://github.com/snap-research/EfficientFormer
|
| 22 |
+
- **Papers:**
|
| 23 |
+
- EfficientFormer: Vision Transformers at MobileNet Speed: https://arxiv.org/abs/2206.01191
|
| 24 |
+
- **Dataset:** ImageNet-1k
|
| 25 |
+
|
| 26 |
+
## Model Usage
|
| 27 |
+
### Image Classification
|
| 28 |
+
```python
|
| 29 |
+
from urllib.request import urlopen
|
| 30 |
+
from PIL import Image
|
| 31 |
+
import timm
|
| 32 |
+
|
| 33 |
+
img = Image.open(
|
| 34 |
+
urlopen('https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'))
|
| 35 |
+
|
| 36 |
+
model = timm.create_model('efficientformer_l1.snap_dist_in1k', pretrained=True)
|
| 37 |
+
model = model.eval()
|
| 38 |
+
|
| 39 |
+
# get model specific transforms (normalization, resize)
|
| 40 |
+
data_config = timm.data.resolve_model_data_config(model)
|
| 41 |
+
transforms = timm.data.create_transform(**data_config, is_training=False)
|
| 42 |
+
|
| 43 |
+
output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
|
| 44 |
+
|
| 45 |
+
top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
### Image Embeddings
|
| 49 |
+
```python
|
| 50 |
+
from urllib.request import urlopen
|
| 51 |
+
from PIL import Image
|
| 52 |
+
import timm
|
| 53 |
+
|
| 54 |
+
img = Image.open(
|
| 55 |
+
urlopen('https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'))
|
| 56 |
+
|
| 57 |
+
model = timm.create_model(
|
| 58 |
+
'efficientformer_l1.snap_dist_in1k',
|
| 59 |
+
pretrained=True,
|
| 60 |
+
num_classes=0, # remove classifier nn.Linear
|
| 61 |
+
)
|
| 62 |
+
model = model.eval()
|
| 63 |
+
|
| 64 |
+
# get model specific transforms (normalization, resize)
|
| 65 |
+
data_config = timm.data.resolve_model_data_config(model)
|
| 66 |
+
transforms = timm.data.create_transform(**data_config, is_training=False)
|
| 67 |
+
|
| 68 |
+
output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor
|
| 69 |
+
|
| 70 |
+
# or equivalently (without needing to set num_classes=0)
|
| 71 |
+
|
| 72 |
+
output = model.forward_features(transforms(img).unsqueeze(0))
|
| 73 |
+
# output is unpooled (ie.e a (batch_size, num_features, H, W) tensor
|
| 74 |
+
|
| 75 |
+
output = model.forward_head(output, pre_logits=True)
|
| 76 |
+
# output is (batch_size, num_features) tensor
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
## Model Comparison
|
| 80 |
+
|model |top1 |top5 |param_count|img_size|
|
| 81 |
+
|-----------------------------------|------|------|-----------|--------|
|
| 82 |
+
|efficientformerv2_l.snap_dist_in1k |83.628|96.54 |26.32 |224 |
|
| 83 |
+
|efficientformer_l7.snap_dist_in1k |83.368|96.534|82.23 |224 |
|
| 84 |
+
|efficientformer_l3.snap_dist_in1k |82.572|96.24 |31.41 |224 |
|
| 85 |
+
|efficientformerv2_s2.snap_dist_in1k|82.128|95.902|12.71 |224 |
|
| 86 |
+
|efficientformer_l1.snap_dist_in1k |80.496|94.984|12.29 |224 |
|
| 87 |
+
|efficientformerv2_s1.snap_dist_in1k|79.698|94.698|6.19 |224 |
|
| 88 |
+
|efficientformerv2_s0.snap_dist_in1k|76.026|92.77 |3.6 |224 |
|
| 89 |
+
|
| 90 |
+
## Citation
|
| 91 |
+
```bibtex
|
| 92 |
+
@article{li2022efficientformer,
|
| 93 |
+
title={EfficientFormer: Vision Transformers at MobileNet Speed},
|
| 94 |
+
author={Li, Yanyu and Yuan, Geng and Wen, Yang and Hu, Ju and Evangelidis, Georgios and Tulyakov, Sergey and Wang, Yanzhi and Ren, Jian},
|
| 95 |
+
journal={arXiv preprint arXiv:2206.01191},
|
| 96 |
+
year={2022}
|
| 97 |
+
}
|
| 98 |
+
```
|
| 99 |
+
```bibtex
|
| 100 |
+
@misc{rw2019timm,
|
| 101 |
+
author = {Ross Wightman},
|
| 102 |
+
title = {PyTorch Image Models},
|
| 103 |
+
year = {2019},
|
| 104 |
+
publisher = {GitHub},
|
| 105 |
+
journal = {GitHub repository},
|
| 106 |
+
doi = {10.5281/zenodo.4414861},
|
| 107 |
+
howpublished = {\url{https://github.com/rwightman/pytorch-image-models}}
|
| 108 |
+
}
|
| 109 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture": "efficientformer_l1",
|
| 3 |
+
"num_classes": 1000,
|
| 4 |
+
"num_features": 448,
|
| 5 |
+
"global_pool": "avg",
|
| 6 |
+
"pretrained_cfg": {
|
| 7 |
+
"tag": "snap_dist_in1k",
|
| 8 |
+
"custom_load": false,
|
| 9 |
+
"input_size": [
|
| 10 |
+
3,
|
| 11 |
+
224,
|
| 12 |
+
224
|
| 13 |
+
],
|
| 14 |
+
"fixed_input_size": true,
|
| 15 |
+
"interpolation": "bicubic",
|
| 16 |
+
"crop_pct": 0.95,
|
| 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": "stem.conv1",
|
| 31 |
+
"classifier": [
|
| 32 |
+
"head",
|
| 33 |
+
"head_dist"
|
| 34 |
+
]
|
| 35 |
+
}
|
| 36 |
+
}
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:33fac87c4f7e0255d08b4ce9471ab10a87bb5651695e1efdaf0b00b1ca923a68
|
| 3 |
+
size 49405489
|