模型:

facebook/dino-vits16

英文

Vision Transformer (small-sized model, patch size 16) trained using DINO

使用 DINO 方法训练的 Vision Transformer (ViT) 模型。该模型在 Emerging Properties in Self-Supervised Vision Transformers 论文中由Mathilde Caron、Hugo Touvron、Ishan Misra、Hervé Jégou、Julien Mairal、Piotr Bojanowski、Armand Joulin介绍,并在 this repository 中首次发布。

免责声明:发布 DINO 的团队没有为此模型编写模型卡片,因此该模型卡片是由 Hugging Face 团队编写的。

Model description

Vision Transformer (ViT) 是一个在自监督方式下使用大量图像(ImageNet-1k)进行预训练的转换器编码器模型(类似于 BERT),分辨率为224x224像素。

图像被表示为固定大小补丁(16x16 分辨率)的序列,并进行线性嵌入。在序列的开头添加了一个[CLS]标记,用于分类任务。在将序列输入 Transformer 编码器的层之前,还添加绝对位置嵌入。

请注意,此模型不包含任何经过微调的头部。

通过预训练模型,它学习了图像的内部表示,这可以用于提取用于下游任务的特征:例如,如果您有一个带有标签的数据集,您可以在预训练的编码器之上放置一个线性层来训练一个标准分类器。通常,在[CLS]标记上放置一个线性层,因为该标记的最后隐藏状态可以看作是整个图像的表示。

Intended uses & limitations

您可以使用原始模型进行图像分类。查看 model hub 以寻找您感兴趣的任务的微调版本。

How to use

使用该模型的方法如下:

from transformers import ViTImageProcessor, ViTModel
from PIL import Image
import requests

url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)

processor = ViTImageProcessor.from_pretrained('facebook/dino-vits16')
model = ViTModel.from_pretrained('facebook/dino-vits16')

inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
last_hidden_states = outputs.last_hidden_state

BibTeX entry and citation info

@article{DBLP:journals/corr/abs-2104-14294,
  author    = {Mathilde Caron and
               Hugo Touvron and
               Ishan Misra and
               Herv{\'{e}} J{\'{e}}gou and
               Julien Mairal and
               Piotr Bojanowski and
               Armand Joulin},
  title     = {Emerging Properties in Self-Supervised Vision Transformers},
  journal   = {CoRR},
  volume    = {abs/2104.14294},
  year      = {2021},
  url       = {https://arxiv.org/abs/2104.14294},
  archivePrefix = {arXiv},
  eprint    = {2104.14294},
  timestamp = {Tue, 04 May 2021 15:12:43 +0200},
  biburl    = {https://dblp.org/rec/journals/corr/abs-2104-14294.bib},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}