许可协议:apache-2.0
标签:
数据集:
示例展示:
- 图片地址: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
示例标题:机场
基于ResNet-50骨干网络、单尺度+空洞卷积的可变形DETR模型
可变形DEtection TRansformer(DETR)单尺度+空洞卷积模型,在COCO 2017目标检测数据集(11.8万张标注图像)上端到端训练而成。该模型由Zhu等人在论文《可变形DETR:端到端目标检测的可变形Transformer》中提出,并首次发布于此代码库。
免责声明:发布可变形DETR的团队未为此模型编写说明卡片,本卡片由Hugging Face团队撰写。
模型描述
DETR模型是一个带有卷积骨干网络的编码器-解码器Transformer。在解码器输出顶部添加了两个头以执行目标检测:一个线性层用于类别标签,一个多层感知机(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("SenseTime/deformable-detr-single-scale-dc5")
model = DeformableDetrForObjectDetection.from_pretrained("SenseTime/deformable-detr-single-scale-dc5")
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}"
)
目前,特征提取器和模型均支持PyTorch。
训练数据
可变形DETR模型在COCO 2017目标检测数据集上训练,该数据集包含11.8万张训练图像和5千张验证图像,均带有标注。
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}
}