adirik commited on
Commit
1f1b60d
1 Parent(s): a23be0d

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +86 -0
README.md ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - vision
5
+ datasets:
6
+ - imagenet-21k
7
+ inference: false
8
+ ---
9
+
10
+ # Vision Transformer (large-sized model)
11
+
12
+ Vision Transformer (ViT) model pre-trained on ImageNet-21k (14 million images, 21,843 classes) at resolution 384x384. It was introduced in the paper [An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale](https://arxiv.org/abs/2010.11929) by Dosovitskiy et al. and first released in [this repository](https://github.com/google-research/vision_transformer). However, this model is contributed by the Kakao Brain team and the weights were converted from their TensorFlow implementation to PyTorch by Alara Dirik.
13
+
14
+
15
+ ## Model description
16
+
17
+ The Vision Transformer (ViT) is a transformer encoder model (BERT-like) pretrained on a large collection of images in a supervised fashion, namely ImageNet-21k, at a resolution of 224x224 pixels.
18
+
19
+ Images are presented to the model as a sequence of fixed-size patches (resolution 32x32), which are linearly embedded. One also adds a [CLS] token to the beginning of a sequence to use it for classification tasks. One also adds absolute position embeddings before feeding the sequence to the layers of the Transformer encoder.
20
+
21
+ Note that this model does not provide any fine-tuned heads, as these were zero'd by Google researchers. However, the model does include the pre-trained pooler, which can be used for downstream tasks (such as image classification).
22
+
23
+ By pre-training the model, it learns an inner representation of images that can then be used to extract features useful for downstream tasks: if you have a dataset of labeled images for instance, you can train a standard classifier by placing a linear layer on top of the pre-trained encoder. One typically places a linear layer on top of the [CLS] token, as the last hidden state of this token can be seen as a representation of an entire image.
24
+
25
+ ## Intended uses & limitations
26
+
27
+ You can use the raw model for image classification. See the [model hub](https://huggingface.co/models?search=google/vit) to look for
28
+ fine-tuned versions on a task that interests you.
29
+
30
+ ### How to use
31
+
32
+ Here is how to use this model in PyTorch:
33
+
34
+ ```python
35
+ from transformers import ViTImageProcessor, ViTModel
36
+ from PIL import Image
37
+ import requests
38
+
39
+ url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
40
+ image = Image.open(requests.get(url, stream=True).raw)
41
+
42
+ processor = ViTImageProcessor.from_pretrained('kakaobrain/vit-large-patch16-384')
43
+ model = ViTModel.from_pretrained('kakaobrain/vit-large-patch16-384')
44
+
45
+ inputs = processor(images=image, return_tensors="pt")
46
+ outputs = model(**inputs)
47
+ last_hidden_state = outputs.last_hidden_state
48
+ ```
49
+
50
+ Refer to the [docs](https://huggingface.co/docs/transformers/model_doc/vit) for usage in TensorFlow and JAX/FLAX.
51
+
52
+ ## Training data
53
+
54
+ The ViT model was pretrained on [ImageNet-21k](http://www.image-net.org/), a dataset consisting of 14 million images and 21k classes.
55
+
56
+ ## Training procedure
57
+
58
+ ### Preprocessing
59
+
60
+ The exact details of preprocessing of images during training/validation can be found [here](https://github.com/google-research/vision_transformer/blob/master/vit_jax/input_pipeline.py).
61
+
62
+ Images are resized/rescaled to the same resolution (384x384) and normalized across the RGB channels with mean (0.5, 0.5, 0.5) and standard deviation (0.5, 0.5, 0.5).
63
+
64
+ ### BibTeX entry and citation info
65
+
66
+ ```bibtex
67
+ @misc{wu2020visual,
68
+ title={Visual Transformers: Token-based Image Representation and Processing for Computer Vision},
69
+ author={Bichen Wu and Chenfeng Xu and Xiaoliang Dai and Alvin Wan and Peizhao Zhang and Zhicheng Yan and Masayoshi Tomizuka and Joseph Gonzalez and Kurt Keutzer and Peter Vajda},
70
+ year={2020},
71
+ eprint={2006.03677},
72
+ archivePrefix={arXiv},
73
+ primaryClass={cs.CV}
74
+ }
75
+ ```
76
+
77
+ ```bibtex
78
+ @inproceedings{deng2009imagenet,
79
+ title={Imagenet: A large-scale hierarchical image database},
80
+ author={Deng, Jia and Dong, Wei and Socher, Richard and Li, Li-Jia and Li, Kai and Fei-Fei, Li},
81
+ booktitle={2009 IEEE conference on computer vision and pattern recognition},
82
+ pages={248--255},
83
+ year={2009},
84
+ organization={Ieee}
85
+ }
86
+ ```