timm
/

Image Classification
timm
PyTorch
Safetensors
rwightman HF staff commited on
Commit
f046178
1 Parent(s): 6ff1a3a

Update model config and README

Browse files
Files changed (2) hide show
  1. README.md +110 -2
  2. model.safetensors +3 -0
README.md CHANGED
@@ -2,6 +2,114 @@
2
  tags:
3
  - image-classification
4
  - timm
5
- library_tag: timm
 
 
 
 
6
  ---
7
- # Model card for beit_base_patch16_384.in22k_ft_in22k_in1k
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  tags:
3
  - image-classification
4
  - timm
5
+ library_name: timm
6
+ license: apache-2.0
7
+ datasets:
8
+ - imagenet-1k
9
+ - imagenet-22k
10
  ---
11
+ # Model card for beit_base_patch16_384.in22k_ft_in22k_in1k
12
+
13
+ A BEiT image classification model. Trained on ImageNet-22k with self-supervised masked image modelling (MIM) using a DALL-E dVAE as visual tokenizer. Fine-tuned on ImageNet-22k and then ImageNet-1k.
14
+
15
+
16
+ ## Model Details
17
+ - **Model Type:** Image classification / feature backbone
18
+ - **Model Stats:**
19
+ - Params (M): 86.7
20
+ - GMACs: 55.5
21
+ - Activations (M): 101.6
22
+ - Image size: 384 x 384
23
+ - **Papers:**
24
+ - BEiT: BERT Pre-Training of Image Transformers: https://arxiv.org/abs/2106.08254
25
+ - An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale: https://arxiv.org/abs/2010.11929v2
26
+ - **Dataset:** ImageNet-1k
27
+ - **Pretrain Dataset:** ImageNet-22k
28
+ - **Original:** https://github.com/microsoft/unilm/tree/master/beit
29
+
30
+ ## Model Usage
31
+ ### Image Classification
32
+ ```python
33
+ from urllib.request import urlopen
34
+ from PIL import Image
35
+ import timm
36
+
37
+ img = Image.open(urlopen(
38
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
39
+ ))
40
+
41
+ model = timm.create_model('beit_base_patch16_384.in22k_ft_in22k_in1k', pretrained=True)
42
+ model = model.eval()
43
+
44
+ # get model specific transforms (normalization, resize)
45
+ data_config = timm.data.resolve_model_data_config(model)
46
+ transforms = timm.data.create_transform(**data_config, is_training=False)
47
+
48
+ output = model(transforms(img).unsqueeze(0)) # unsqueeze single image into batch of 1
49
+
50
+ top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
51
+ ```
52
+
53
+ ### Image Embeddings
54
+ ```python
55
+ from urllib.request import urlopen
56
+ from PIL import Image
57
+ import timm
58
+
59
+ img = Image.open(urlopen(
60
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
61
+ ))
62
+
63
+ model = timm.create_model(
64
+ 'beit_base_patch16_384.in22k_ft_in22k_in1k',
65
+ pretrained=True,
66
+ num_classes=0, # remove classifier nn.Linear
67
+ )
68
+ model = model.eval()
69
+
70
+ # get model specific transforms (normalization, resize)
71
+ data_config = timm.data.resolve_model_data_config(model)
72
+ transforms = timm.data.create_transform(**data_config, is_training=False)
73
+
74
+ output = model(transforms(img).unsqueeze(0)) # output is (batch_size, num_features) shaped tensor
75
+
76
+ # or equivalently (without needing to set num_classes=0)
77
+
78
+ output = model.forward_features(transforms(img).unsqueeze(0))
79
+ # output is unpooled, a (1, 577, 768) shaped tensor
80
+
81
+ output = model.forward_head(output, pre_logits=True)
82
+ # output is a (1, num_features) shaped tensor
83
+ ```
84
+
85
+ ## Model Comparison
86
+ Explore the dataset and runtime metrics of this model in timm [model results](https://github.com/huggingface/pytorch-image-models/tree/main/results).
87
+
88
+ ## Citation
89
+ ```bibtex
90
+ @article{bao2021beit,
91
+ title={Beit: Bert pre-training of image transformers},
92
+ author={Bao, Hangbo and Dong, Li and Piao, Songhao and Wei, Furu},
93
+ journal={arXiv preprint arXiv:2106.08254},
94
+ year={2021}
95
+ }
96
+ ```
97
+ ```bibtex
98
+ @article{dosovitskiy2020vit,
99
+ title={An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale},
100
+ 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},
101
+ journal={ICLR},
102
+ year={2021}
103
+ }
104
+ ```
105
+ ```bibtex
106
+ @misc{rw2019timm,
107
+ author = {Ross Wightman},
108
+ title = {PyTorch Image Models},
109
+ year = {2019},
110
+ publisher = {GitHub},
111
+ journal = {GitHub repository},
112
+ doi = {10.5281/zenodo.4414861},
113
+ howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
114
+ }
115
+ ```
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:441de36441dcadb0364f479e6b0578e65966f643500f4a9510494cfd95e9e63b
3
+ size 378957444