🚀 基于Detic方法在LVIS上训练的可变形DETR模型
本项目基于可变形检测变换器(Deformable DETR)模型,在LVIS数据集(包含1203个类别)上进行训练。该模型源自论文 Detecting Twenty-thousand Classes using Image-level Supervision(作者:Zhou等人),并首次在 此仓库 中发布。本模型对应原仓库中发布的 "Detic_DeformDETR_R50_4x" 检查点。
需注意,发布Detic的团队并未为此模型撰写模型卡片,此卡片由Hugging Face团队编写。
✨ 主要特性
- 标签:目标检测、视觉、Detic
- 数据集:COCO、LVIS
- 示例展示:
📚 详细文档
模型描述
DETR模型是一种带有卷积骨干网络的编码器 - 解码器变换器。为了进行目标检测,在解码器输出的基础上添加了两个头部:一个用于类别标签的线性层和一个用于边界框的多层感知机(MLP)。该模型使用所谓的目标查询来检测图像中的目标。每个目标查询在图像中寻找特定的目标。对于COCO数据集,目标查询的数量设置为100。
模型使用“二分匹配损失”进行训练:将N = 100个目标查询的预测类别和边界框与真实标注进行比较,标注会填充到相同的长度N(因此,如果一张图像仅包含4个目标,那么96个标注的类别将为“无目标”,边界框也为“无边界框”)。匈牙利匹配算法用于在N个查询和N个标注之间创建最优的一对一映射。接下来,使用标准的交叉熵(用于类别)以及L1和广义IoU损失的线性组合(用于边界框)来优化模型的参数。

预期用途与限制
你可以使用此原始模型进行目标检测。请参考 模型中心 查找所有可用的可变形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-detic")
model = DeformableDetrForObjectDetection.from_pretrained("facebook/deformable-detr-detic")
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"Detected {model.config.id2label[label.item()]} with confidence "
f"{round(score.item(), 3)} at location {box}"
)
评估结果
该模型在LVIS数据集上实现了32.5的边界框平均精度均值(box mAP)和26.2的罕见类别平均精度均值(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}
}
📄 许可证
本模型采用Apache-2.0许可证。