🚀 模型卡片:OWL-ViT
OWL-ViT(開放世界定位視覺變換器的縮寫)是一個零樣本的文本條件目標檢測模型,可使用一個或多個文本查詢對圖像進行查詢。該模型在計算機視覺研究領域具有重要意義,能夠幫助研究人員更好地理解和探索零樣本、文本條件目標檢測。
🚀 快速開始
使用Transformers庫調用模型
import requests
from PIL import Image
import torch
from transformers import OwlViTProcessor, OwlViTForObjectDetection
processor = OwlViTProcessor.from_pretrained("google/owlvit-base-patch16")
model = OwlViTForObjectDetection.from_pretrained("google/owlvit-base-patch16")
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
texts = [["a photo of a cat", "a photo of a dog"]]
inputs = processor(text=texts, images=image, return_tensors="pt")
outputs = model(**inputs)
# Target image sizes (height, width) to rescale box predictions [batch_size, 2]
target_sizes = torch.Tensor([image.size[::-1]])
# Convert outputs (bounding boxes and class logits) to COCO API
results = processor.post_process_object_detection(outputs=outputs, threshold=0.1, target_sizes=target_sizes)
i = 0 # Retrieve predictions for the first image for the corresponding text queries
text = texts[i]
boxes, scores, labels = results[i]["boxes"], results[i]["scores"], results[i]["labels"]
# Print detected objects and rescaled box coordinates
for box, score, label in zip(boxes, scores, labels):
box = [round(i, 2) for i in box.tolist()]
print(f"Detected {text[label]} with confidence {round(score.item(), 3)} at location {box}")
✨ 主要特性
- 零樣本檢測:可以使用文本查詢進行目標檢測,無需針對特定目標進行訓練。
- 多模態架構:使用CLIP作為多模態主幹,結合視覺和文本特徵進行目標檢測。
- 開放詞彙分類:通過用從文本模型獲得的類名嵌入替換固定的分類層權重,實現開放詞彙分類。
📚 詳細文檔
🔧 技術細節
模型提出
OWL-ViT由Matthias Minderer、Alexey Gritsenko、Austin Stone等人在論文Simple Open-Vocabulary Object Detection with Vision Transformers中提出。
模型架構
該模型使用CLIP作為多模態主幹,其中圖像編碼器採用ViT-B/16 Transformer架構,文本編碼器採用掩碼自注意力Transformer。這些編碼器通過對比損失進行訓練,以最大化(圖像,文本)對的相似度。CLIP主幹從頭開始訓練,並與邊界框和類別預測頭一起針對目標檢測任務進行微調。
模型訓練
- 預訓練:CLIP主幹在公開可用的圖像 - 字幕數據上進行訓練,數據來源包括爬取的網站和常用的圖像數據集,如YFCC100M。
- 微調:OWL-ViT的預測頭和CLIP主幹在公開可用的目標檢測數據集上進行微調,如COCO和OpenImages。
模型日期
2022年5月
模型類型
屬性 |
詳情 |
模型類型 |
該模型使用CLIP主幹,圖像編碼器採用ViT-B/16 Transformer架構,文本編碼器採用掩碼自注意力Transformer。這些編碼器通過對比損失進行訓練,以最大化(圖像,文本)對的相似度。CLIP主幹從頭開始訓練,並與邊界框和類別預測頭一起針對目標檢測任務進行微調。 |
訓練數據 |
CLIP主幹在公開可用的圖像 - 字幕數據上訓練,數據來自爬取網站和常用圖像數據集,如YFCC100M。OWL-ViT的預測頭和CLIP主幹在公開的目標檢測數據集上微調,如COCO和OpenImages。 |
📄 許可證
本模型採用Apache-2.0許可證。
BibTeX引用
@article{minderer2022simple,
title={Simple Open-Vocabulary Object Detection with Vision Transformers},
author={Matthias Minderer, Alexey Gritsenko, Austin Stone, Maxim Neumann, Dirk Weissenborn, Alexey Dosovitskiy, Aravindh Mahendran, Anurag Arnab, Mostafa Dehghani, Zhuoran Shen, Xiao Wang, Xiaohua Zhai, Thomas Kipf, Neil Houlsby},
journal={arXiv preprint arXiv:2205.06230},
year={2022},
}
📖 模型使用
預期用途
本模型旨在作為研究成果供研究社區使用。我們希望該模型能幫助研究人員更好地理解和探索零樣本、文本條件目標檢測,也可用於跨學科研究,特別是在訓練期間需要識別標籤不可用的目標的領域。
主要預期用戶
主要預期用戶為人工智能研究人員。我們主要設想研究人員使用該模型來更好地理解計算機視覺模型的魯棒性、泛化能力以及其他特性、偏差和限制。