🚀 基於DINOv2訓練的視覺變換器(大型模型)
本項目是使用DINOv2方法訓練的視覺變換器(ViT)模型。該方法由Oquab等人在論文 DINOv2: Learning Robust Visual Features without Supervision 中提出,並首次在 此倉庫 中發佈。
聲明:發佈DINOv2的團隊並未為此模型編寫模型卡片,此模型卡片由Hugging Face團隊編寫。
🚀 快速開始
本模型可用於圖像特徵提取,你可以在 模型中心 查找針對特定任務微調後的版本。
✨ 主要特性
- 自監督預訓練:視覺變換器(ViT)是一種類似BERT的變換器編碼器模型,以自監督的方式在大量圖像集上進行預訓練。
- 特徵提取能力:通過預訓練,模型學習到圖像的內在表示,可用於提取對下游任務有用的特徵。
- 無微調頭部:此模型不包含任何微調後的頭部。
📚 詳細文檔
模型描述
視覺變換器(ViT)是一種變換器編碼器模型(類似BERT),以自監督的方式在大量圖像集上進行預訓練。
圖像以固定大小的圖像塊序列形式輸入到模型中,並進行線性嵌入。同時,在序列開頭添加一個 [CLS] 標記,用於分類任務。在將序列輸入到變換器編碼器的各層之前,還會添加絕對位置嵌入。
需要注意的是,此模型不包含任何微調後的頭部。
通過對模型進行預訓練,它學習到圖像的內在表示,這些表示可用於提取對下游任務有用的特徵。例如,如果你有一個帶標籤的圖像數據集,可以在預訓練的編碼器之上添加一個線性層,訓練一個標準的分類器。通常會在 [CLS] 標記之上添加一個線性層,因為該標記的最後隱藏狀態可以看作是整個圖像的表示。
預期用途和侷限性
你可以使用原始模型進行特徵提取。可在 模型中心 查找針對你感興趣的任務進行微調後的版本。
💻 使用示例
基礎用法
from transformers import AutoImageProcessor, AutoModel
from PIL import Image
import requests
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
processor = AutoImageProcessor.from_pretrained('facebook/dinov2-large')
model = AutoModel.from_pretrained('facebook/dinov2-large')
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
last_hidden_states = outputs.last_hidden_state
📄 許可證
本項目採用Apache-2.0許可證。
BibTeX引用
misc{oquab2023dinov2,
title={DINOv2: Learning Robust Visual Features without Supervision},
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},
year={2023},
eprint={2304.07193},
archivePrefix={arXiv},
primaryClass={cs.CV}
}