许可协议:apache-2.0
标签:
- 目标检测
- 视觉
- detic
数据集:
- lvis
示例展示:
- 图片链接:https://huggingface.co/datasets/mishig/sample_images/resolve/main/savanna.jpg
示例标题:热带草原
- 图片链接:https://huggingface.co/datasets/mishig/sample_images/resolve/main/football-match.jpg
示例标题:足球比赛
- 图片链接:https://huggingface.co/datasets/mishig/sample_images/resolve/main/airport.jpg
示例标题:机场
基于LVIS训练的Deformable DETR模型
Deformable DEtection TRansformer(DETR)模型,在LVIS数据集(包含1203个类别)上训练完成。该模型由Zhou等人在论文《使用图像级监督检测两万类物体》中提出,并首次发布于此代码库。
此模型对应原始代码库中发布的"Box-Supervised_DeformDETR_R50_4x"检查点。
免责声明:发布Detic的团队未为此模型编写模型卡片,因此本卡片由Hugging Face团队撰写。
模型描述
DETR模型是一个基于卷积骨干网络的编码器-解码器Transformer。在解码器输出端添加了两个头部以执行目标检测:一个线性层用于分类标签,一个多层感知机(MLP)用于边界框预测。模型通过所谓的“对象查询”在图像中检测目标,每个查询负责寻找图像中的特定对象。对于COCO数据集,对象查询数量设置为100。
训练时采用“二分匹配损失”:将N=100个对象查询的预测类别和边界框与填充至相同长度N的真实标注进行对比(例如,若图像仅含4个物体,其余96个标注的类别为“无物体”,边界框为“无边界框”)。匈牙利匹配算法用于在查询与标注间建立最优的一对一映射关系,随后通过交叉熵损失(分类)及L1与广义IoU损失的线性组合(边界框)优化模型参数。

使用场景与限制
可直接使用该原始模型进行目标检测。查看模型库以获取所有可用的Deformable DETR模型。
使用方法
使用方式如下:
from transformers import AutoImageProcessor, DeformableDetrForObjectDetection
import torch
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/deformable-detr-box-supervised")
model = DeformableDetrForObjectDetection.from_pretrained("facebook/deformable-detr-box-supervised")
inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
target_sizes = torch.tensor([image.size[::-1]])
results = processor.post_process_object_detection(outputs, target_sizes=target_sizes, threshold=0.7)[0]
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
box = [round(i, 2) for i in box.tolist()]
print(
f"检测到 {model.config.id2label[label.item()]},置信度 "
f"{round(score.item(), 3)},位置 {box}"
)
评估结果
该模型在LVIS数据集上达到31.7的边界框mAP和21.4的稀有类别mAP。
BibTeX引用信息
@misc{https://doi.org/10.48550/arxiv.2010.04159,
doi = {10.48550/ARXIV.2010.04159},
url = {https://arxiv.org/abs/2010.04159},
author = {Zhu, Xizhou and Su, Weijie and Lu, Lewei and Li, Bin and Wang, Xiaogang and Dai, Jifeng},
keywords = {Computer Vision and Pattern Recognition (cs.CV), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Deformable DETR: Deformable Transformers for End-to-End Object Detection},
publisher = {arXiv},
year = {2020},
copyright = {arXiv.org perpetual, non-exclusive license}
}