nielsr HF staff commited on
Commit
bb69e0f
1 Parent(s): 1475a37

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +64 -0
README.md ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - dino
5
+ - vision
6
+ datasets:
7
+ - imagenet-1k
8
+ ---
9
+
10
+ # Vision Transformer (giant-sized model) trained using DINOv2
11
+
12
+ Vision Transformer (ViT) model trained using the DINOv2 method. It was introduced in the paper [DINOv2: Learning Robust Visual Features without Supervision](https://arxiv.org/abs/2304.07193) by Oquab et al. and first released in [this repository](https://github.com/facebookresearch/dinov2).
13
+
14
+ Disclaimer: The team releasing DINOv2 did not write a model card for this model so this model card has been written by the Hugging Face team.
15
+
16
+ ## Model description
17
+
18
+ The Vision Transformer (ViT) is a transformer encoder model (BERT-like) pretrained on a large collection of images in a self-supervised fashion.
19
+
20
+ Images are presented to the model as a sequence of fixed-size patches, 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.
21
+
22
+ Note that this model does not include any fine-tuned heads.
23
+
24
+ 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.
25
+
26
+ ## Intended uses & limitations
27
+
28
+ You can use the model for classifying an image among one of the [1000 ImageNet labels](https://huggingface.co/datasets/huggingface/label-files/blob/main/imagenet-1k-id2label.json). See the [model hub](https://huggingface.co/models?search=facebook/dinov2) to look for
29
+ other fine-tuned versions on a task that interests you.
30
+
31
+ ### How to use
32
+
33
+ Here is how to use this model:
34
+
35
+ ```python
36
+ from transformers import AutoImageProcessor, AutoModelForImageClassification
37
+ from PIL import Image
38
+ import requests
39
+
40
+ url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
41
+ image = Image.open(requests.get(url, stream=True).raw)
42
+
43
+ processor = AutoImageProcessor.from_pretrained('facebook/dinov2-giant-imagenet1k-1-layer')
44
+ model = AutoModelForImageClassification.from_pretrained('facebook/dinov2-giant-imagenet1k-1-layer')
45
+
46
+ inputs = processor(images=image, return_tensors="pt")
47
+ outputs = model(**inputs)
48
+ logits = outputs.logits
49
+ predicted_class_idx = logits.argmax(-1).item()
50
+ print("Predicted class:", model.config.id2label[predicted_class_idx])
51
+ ```
52
+
53
+ ### BibTeX entry and citation info
54
+
55
+ ```bibtex
56
+ misc{oquab2023dinov2,
57
+ title={DINOv2: Learning Robust Visual Features without Supervision},
58
+ author={Maxime Oquab and Timothée Darcet and Théo Moutakanni and Huy Vo and Marc Szafraniec and Vasil Khalidov and Pierre Fernandez and Daniel Haziza and Francisco Massa and Alaaeldin El-Nouby and Mahmoud Assran and Nicolas Ballas and Wojciech Galuba and Russell Howes and Po-Yao Huang and Shang-Wen Li and Ishan Misra and Michael Rabbat and Vasu Sharma and Gabriel Synnaeve and Hu Xu and Hervé Jegou and Julien Mairal and Patrick Labatut and Armand Joulin and Piotr Bojanowski},
59
+ year={2023},
60
+ eprint={2304.07193},
61
+ archivePrefix={arXiv},
62
+ primaryClass={cs.CV}
63
+ }
64
+ ```