timm
/

Image Classification
timm
PyTorch
Safetensors
rwightman HF staff commited on
Commit
3f095d0
1 Parent(s): e48841f

Update model config and README

Browse files
Files changed (2) hide show
  1. README.md +120 -2
  2. model.safetensors +3 -0
README.md CHANGED
@@ -2,7 +2,125 @@
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-1k
9
+ - wit-400m
10
+ - imagenet-12k
11
  ---
12
+ # Model card for vit_base_patch32_clip_384.openai_ft_in12k_in1k
13
+
14
+ A Vision Transformer (ViT) image classification model. Pretrained on WIT-400M image-text pairs by OpenAI using CLIP. Fine-tuned on ImageNet-12k and then ImageNet-1k in `timm`. See recipes in [Reproducible scaling laws](https://arxiv.org/abs/2212.07143).
15
+
16
+
17
+ ## Model Details
18
+ - **Model Type:** Image classification / feature backbone
19
+ - **Model Stats:**
20
+ - Params (M): 88.3
21
+ - GMACs: 12.7
22
+ - Activations (M): 12.1
23
+ - Image size: 384 x 384
24
+ - **Papers:**
25
+ - Learning Transferable Visual Models From Natural Language Supervision: https://arxiv.org/abs/2103.00020
26
+ - Reproducible scaling laws for contrastive language-image learning: https://arxiv.org/abs/2212.07143
27
+ - An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale: https://arxiv.org/abs/2010.11929v2
28
+ - **Dataset:** ImageNet-1k
29
+ - **Pretrain Dataset:**
30
+ - WIT-400M
31
+ - ImageNet-12k
32
+
33
+ ## Model Usage
34
+ ### Image Classification
35
+ ```python
36
+ from urllib.request import urlopen
37
+ from PIL import Image
38
+ import timm
39
+
40
+ img = Image.open(urlopen(
41
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
42
+ ))
43
+
44
+ model = timm.create_model('vit_base_patch32_clip_384.openai_ft_in12k_in1k', pretrained=True)
45
+ model = model.eval()
46
+
47
+ # get model specific transforms (normalization, resize)
48
+ data_config = timm.data.resolve_model_data_config(model)
49
+ transforms = timm.data.create_transform(**data_config, is_training=False)
50
+
51
+ output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
52
+
53
+ top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
54
+ ```
55
+
56
+ ### Image Embeddings
57
+ ```python
58
+ from urllib.request import urlopen
59
+ from PIL import Image
60
+ import timm
61
+
62
+ img = Image.open(urlopen(
63
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
64
+ ))
65
+
66
+ model = timm.create_model(
67
+ 'vit_base_patch32_clip_384.openai_ft_in12k_in1k',
68
+ pretrained=True,
69
+ num_classes=0, # remove classifier nn.Linear
70
+ )
71
+ model = model.eval()
72
+
73
+ # get model specific transforms (normalization, resize)
74
+ data_config = timm.data.resolve_model_data_config(model)
75
+ transforms = timm.data.create_transform(**data_config, is_training=False)
76
+
77
+ output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor
78
+
79
+ # or equivalently (without needing to set num_classes=0)
80
+
81
+ output = model.forward_features(transforms(img).unsqueeze(0))
82
+ # output is unpooled, a (1, 145, 768) shaped tensor
83
+
84
+ output = model.forward_head(output, pre_logits=True)
85
+ # output is a (1, num_features) shaped tensor
86
+ ```
87
+
88
+ ## Model Comparison
89
+ Explore the dataset and runtime metrics of this model in timm [model results](https://github.com/huggingface/pytorch-image-models/tree/main/results).
90
+
91
+ ## Citation
92
+ ```bibtex
93
+ @inproceedings{Radford2021LearningTV,
94
+ title={Learning Transferable Visual Models From Natural Language Supervision},
95
+ 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},
96
+ booktitle={ICML},
97
+ year={2021}
98
+ }
99
+ ```
100
+ ```bibtex
101
+ @article{cherti2022reproducible,
102
+ title={Reproducible scaling laws for contrastive language-image learning},
103
+ 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},
104
+ journal={arXiv preprint arXiv:2212.07143},
105
+ year={2022}
106
+ }
107
+ ```
108
+ ```bibtex
109
+ @article{dosovitskiy2020vit,
110
+ title={An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale},
111
+ 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},
112
+ journal={ICLR},
113
+ year={2021}
114
+ }
115
+ ```
116
+ ```bibtex
117
+ @misc{rw2019timm,
118
+ author = {Ross Wightman},
119
+ title = {PyTorch Image Models},
120
+ year = {2019},
121
+ publisher = {GitHub},
122
+ journal = {GitHub repository},
123
+ doi = {10.5281/zenodo.4414861},
124
+ howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
125
+ }
126
+ ```
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:822ec6e705552a279f1c0092bacf826ec7402690b039033b1ccbf7cad44cd626
3
+ size 353206012