timm
/

Image Classification
timm
PyTorch
Safetensors
rwightman HF staff commited on
Commit
df39faf
1 Parent(s): 286ecfb

Update model config and README

Browse files
Files changed (2) hide show
  1. README.md +118 -2
  2. model.safetensors +3 -0
README.md CHANGED
@@ -2,7 +2,123 @@
2
  tags:
3
  - image-classification
4
  - timm
5
- - vision
6
- library_tag: timm
7
  license: apache-2.0
 
 
 
8
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  tags:
3
  - image-classification
4
  - timm
5
+ library_name: timm
 
6
  license: apache-2.0
7
+ datasets:
8
+ - imagenet-12k
9
+ - wit-400m
10
  ---
11
+ # Model card for vit_large_patch14_clip_224.openai_ft_in12k
12
+
13
+ A Vision Transformer (ViT) image classification model. Pretrained on WIT-400M image-text pairs by OpenAI using CLIP. Fine-tuned on ImageNet-12k in `timm`. See recipes in [Reproducible scaling laws](https://arxiv.org/abs/2212.07143).
14
+
15
+
16
+ ## Model Details
17
+ - **Model Type:** Image classification / feature backbone
18
+ - **Model Stats:**
19
+ - Params (M): 315.3
20
+ - GMACs: 77.8
21
+ - Activations (M): 57.1
22
+ - Image size: 224 x 224
23
+ - **Papers:**
24
+ - Learning Transferable Visual Models From Natural Language Supervision: https://arxiv.org/abs/2103.00020
25
+ - Reproducible scaling laws for contrastive language-image learning: https://arxiv.org/abs/2212.07143
26
+ - An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale: https://arxiv.org/abs/2010.11929v2
27
+ - **Dataset:** ImageNet-12k
28
+ - **Pretrain Dataset:**
29
+ - WIT-400M
30
+
31
+ ## Model Usage
32
+ ### Image Classification
33
+ ```python
34
+ from urllib.request import urlopen
35
+ from PIL import Image
36
+ import timm
37
+
38
+ img = Image.open(urlopen(
39
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
40
+ ))
41
+
42
+ model = timm.create_model('vit_large_patch14_clip_224.openai_ft_in12k', pretrained=True)
43
+ model = model.eval()
44
+
45
+ # get model specific transforms (normalization, resize)
46
+ data_config = timm.data.resolve_model_data_config(model)
47
+ transforms = timm.data.create_transform(**data_config, is_training=False)
48
+
49
+ output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
50
+
51
+ top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
52
+ ```
53
+
54
+ ### Image Embeddings
55
+ ```python
56
+ from urllib.request import urlopen
57
+ from PIL import Image
58
+ import timm
59
+
60
+ img = Image.open(urlopen(
61
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
62
+ ))
63
+
64
+ model = timm.create_model(
65
+ 'vit_large_patch14_clip_224.openai_ft_in12k',
66
+ pretrained=True,
67
+ num_classes=0, # remove classifier nn.Linear
68
+ )
69
+ model = model.eval()
70
+
71
+ # get model specific transforms (normalization, resize)
72
+ data_config = timm.data.resolve_model_data_config(model)
73
+ transforms = timm.data.create_transform(**data_config, is_training=False)
74
+
75
+ output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor
76
+
77
+ # or equivalently (without needing to set num_classes=0)
78
+
79
+ output = model.forward_features(transforms(img).unsqueeze(0))
80
+ # output is unpooled, a (1, 257, 1024) shaped tensor
81
+
82
+ output = model.forward_head(output, pre_logits=True)
83
+ # output is a (1, num_features) shaped tensor
84
+ ```
85
+
86
+ ## Model Comparison
87
+ Explore the dataset and runtime metrics of this model in timm [model results](https://github.com/huggingface/pytorch-image-models/tree/main/results).
88
+
89
+ ## Citation
90
+ ```bibtex
91
+ @inproceedings{Radford2021LearningTV,
92
+ title={Learning Transferable Visual Models From Natural Language Supervision},
93
+ author={Alec Radford and Jong Wook Kim and Chris Hallacy and A. Ramesh and Gabriel Goh and Sandhini Agarwal and Girish Sastry and Amanda Askell and Pamela Mishkin and Jack Clark and Gretchen Krueger and Ilya Sutskever},
94
+ booktitle={ICML},
95
+ year={2021}
96
+ }
97
+ ```
98
+ ```bibtex
99
+ @article{cherti2022reproducible,
100
+ title={Reproducible scaling laws for contrastive language-image learning},
101
+ author={Cherti, Mehdi and Beaumont, Romain and Wightman, Ross and Wortsman, Mitchell and Ilharco, Gabriel and Gordon, Cade and Schuhmann, Christoph and Schmidt, Ludwig and Jitsev, Jenia},
102
+ journal={arXiv preprint arXiv:2212.07143},
103
+ year={2022}
104
+ }
105
+ ```
106
+ ```bibtex
107
+ @article{dosovitskiy2020vit,
108
+ title={An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale},
109
+ author={Dosovitskiy, Alexey and Beyer, Lucas and Kolesnikov, Alexander and Weissenborn, Dirk and Zhai, Xiaohua and Unterthiner, Thomas and Dehghani, Mostafa and Minderer, Matthias and Heigold, Georg and Gelly, Sylvain and Uszkoreit, Jakob and Houlsby, Neil},
110
+ journal={ICLR},
111
+ year={2021}
112
+ }
113
+ ```
114
+ ```bibtex
115
+ @misc{rw2019timm,
116
+ author = {Ross Wightman},
117
+ title = {PyTorch Image Models},
118
+ year = {2019},
119
+ publisher = {GitHub},
120
+ journal = {GitHub repository},
121
+ doi = {10.5281/zenodo.4414861},
122
+ howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
123
+ }
124
+ ```
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:71fabc172630aaa31313554d5a5f80d724ba920dc0d7d0f0469f0f2e8e06282f
3
+ size 1261213442