timm
/

Image Feature Extraction
timm
PyTorch
Safetensors
rwightman HF staff commited on
Commit
ab8a47f
1 Parent(s): efd5bc1

Update model config and README

Browse files
Files changed (2) hide show
  1. README.md +99 -2
  2. model.safetensors +3 -0
README.md CHANGED
@@ -2,6 +2,103 @@
2
  tags:
3
  - image-classification
4
  - timm
5
- library_tag: timm
 
 
 
6
  ---
7
- # Model card for vit_large_patch32_224.orig_in21k
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  tags:
3
  - image-classification
4
  - timm
5
+ library_name: timm
6
+ license: apache-2.0
7
+ datasets:
8
+ - imagenet-21k
9
  ---
10
+ # Model card for vit_large_patch32_224.orig_in21k
11
+
12
+ A Vision Transformer (ViT) image classification model. Trained on ImageNet-21k in JAX by paper authors, ported to PyTorch by Ross Wightman.
13
+
14
+
15
+ ## Model Details
16
+ - **Model Type:** Image classification / feature backbone
17
+ - **Model Stats:**
18
+ - Params (M): 327.9
19
+ - GMACs: 15.3
20
+ - Activations (M): 11.1
21
+ - Image size: 224 x 224
22
+ - **Papers:**
23
+ - An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale: https://arxiv.org/abs/2010.11929v2
24
+ - **Dataset:** ImageNet-21k
25
+ - **Original:** https://github.com/google-research/vision_transformer
26
+
27
+ ## Model Usage
28
+ ### Image Classification
29
+ ```python
30
+ from urllib.request import urlopen
31
+ from PIL import Image
32
+ import timm
33
+
34
+ img = Image.open(urlopen(
35
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
36
+ ))
37
+
38
+ model = timm.create_model('vit_large_patch32_224.orig_in21k', pretrained=True)
39
+ model = model.eval()
40
+
41
+ # get model specific transforms (normalization, resize)
42
+ data_config = timm.data.resolve_model_data_config(model)
43
+ transforms = timm.data.create_transform(**data_config, is_training=False)
44
+
45
+ output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
46
+
47
+ top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
48
+ ```
49
+
50
+ ### Image Embeddings
51
+ ```python
52
+ from urllib.request import urlopen
53
+ from PIL import Image
54
+ import timm
55
+
56
+ img = Image.open(urlopen(
57
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
58
+ ))
59
+
60
+ model = timm.create_model(
61
+ 'vit_large_patch32_224.orig_in21k',
62
+ pretrained=True,
63
+ num_classes=0, # remove classifier nn.Linear
64
+ )
65
+ model = model.eval()
66
+
67
+ # get model specific transforms (normalization, resize)
68
+ data_config = timm.data.resolve_model_data_config(model)
69
+ transforms = timm.data.create_transform(**data_config, is_training=False)
70
+
71
+ output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor
72
+
73
+ # or equivalently (without needing to set num_classes=0)
74
+
75
+ output = model.forward_features(transforms(img).unsqueeze(0))
76
+ # output is unpooled, a (1, 50, 1024) shaped tensor
77
+
78
+ output = model.forward_head(output, pre_logits=True)
79
+ # output is a (1, num_features) shaped tensor
80
+ ```
81
+
82
+ ## Model Comparison
83
+ Explore the dataset and runtime metrics of this model in timm [model results](https://github.com/huggingface/pytorch-image-models/tree/main/results).
84
+
85
+ ## Citation
86
+ ```bibtex
87
+ @article{dosovitskiy2020vit,
88
+ title={An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale},
89
+ 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},
90
+ journal={ICLR},
91
+ year={2021}
92
+ }
93
+ ```
94
+ ```bibtex
95
+ @misc{rw2019timm,
96
+ author = {Ross Wightman},
97
+ title = {PyTorch Image Models},
98
+ year = {2019},
99
+ publisher = {GitHub},
100
+ journal = {GitHub repository},
101
+ doi = {10.5281/zenodo.4414861},
102
+ howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
103
+ }
104
+ ```
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e03b017a25da2b67285317915fc9d6678b6415a989e53488029880c8e518959c
3
+ size 1311626056