🚀 Deformable DETRモデル(ResNet - 50バックボーン、ボックスリファインメントと2段階)
Deformable DETRは、COCO 2017物体検出データセットでエンドツーエンドに学習された物体検出モデルで、高い精度を実現します。
🚀 クイックスタート
このモデルは物体検出に使用できます。すべての利用可能なDeformable DETRモデルを探すには、モデルハブを参照してください。
✨ 主な機能
- エンコーダ - デコーダトランスフォーマーアーキテクチャを使用し、畳み込みバックボーンを備えています。
- 物体検出のために、デコーダ出力の上にクラスラベル用の線形層とバウンディングボックス用のMLPが追加されています。
- 「二部マッチング損失」を使用して学習され、ハンガリアンマッチングアルゴリズムで最適なマッピングを作成します。
📦 インストール
このモデルを使用するには、transformers
ライブラリが必要です。以下のコマンドでインストールできます。
pip install transformers
💻 使用例
基本的な使用法
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-with-box-refine-two-stage")
model = DeformableDetrForObjectDetection.from_pretrained("SenseTime/deformable-detr-with-box-refine-two-stage")
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}"
)
現在、特徴抽出器とモデルの両方がPyTorchをサポートしています。
📚 ドキュメント
モデルの説明
DETRモデルは、畳み込みバックボーンを持つエンコーダ - デコーダトランスフォーマーです。物体検出を行うために、デコーダ出力の上に2つのヘッドが追加されています。クラスラベル用の線形層とバウンディングボックス用のMLP(多層パーセプトロン)です。モデルは、いわゆる物体クエリを使用して画像内の物体を検出します。各物体クエリは、画像内の特定の物体を探します。COCOの場合、物体クエリの数は100に設定されています。
モデルは「二部マッチング損失」を使用して学習されます。N = 100の各物体クエリの予測クラス + バウンディングボックスを、同じ長さNにパディングされた正解アノテーションと比較します(つまり、画像に4つの物体しか含まれていない場合、96のアノテーションはクラスとして「物体なし」、バウンディングボックスとして「バウンディングボックスなし」になります)。ハンガリアンマッチングアルゴリズムを使用して、N個のクエリとN個のアノテーションの間に最適な1対1のマッピングを作成します。次に、標準的な交差エントロピー(クラス用)とL1損失と一般化IoU損失の線形結合(バウンディングボックス用)を使用して、モデルのパラメータを最適化します。

想定される用途と制限
このモデルは物体検出に使用できます。
🔧 技術詳細
- モデルタイプ:エンコーダ - デコーダトランスフォーマー
- 学習データ:COCO 2017物体検出(学習用に118k、検証用に5kのアノテーション付き画像)
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ライセンスの下で提供されています。