🚀 模型卡片: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},
}
📖 模型使用
预期用途
本模型旨在作为研究成果供研究社区使用。我们希望该模型能帮助研究人员更好地理解和探索零样本、文本条件目标检测,也可用于跨学科研究,特别是在训练期间需要识别标签不可用的目标的领域。
主要预期用户
主要预期用户为人工智能研究人员。我们主要设想研究人员使用该模型来更好地理解计算机视觉模型的鲁棒性、泛化能力以及其他特性、偏差和限制。