🚀 基於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許可證。