🚀 YOLOS (tiny-sized) モデル
YOLOSモデルは、COCO 2017物体検出データセット(118k枚の注釈付き画像)でファインチューニングされています。このモデルは、Fangらによる論文 You Only Look at One Sequence: Rethinking Transformer in Vision through Object Detection で紹介され、このリポジトリ で最初に公開されました。
なお、YOLOSを公開したチームはこのモデルのモデルカードを作成していないため、このモデルカードはHugging Faceチームによって作成されています。
🚀 クイックスタート
このモデルは物体検出に使用できます。利用可能なすべてのYOLOSモデルを探すには、モデルハブ を参照してください。
✨ 主な機能
YOLOSは、DETR損失を使用してトレーニングされたVision Transformer (ViT) です。シンプルな構造でありながら、ベースサイズのYOLOSモデルはCOCO 2017バリデーションセットで42 APを達成できます(DETRやFaster R-CNNなどのより複雑なフレームワークと同等)。
📚 ドキュメント
モデルの説明
このモデルは「二部マッチング損失」を使用してトレーニングされています。具体的には、N = 100の各物体クエリの予測クラスとバウンディングボックスを、同じ長さNにパディングされた正解注釈と比較します(例えば、画像に4つの物体しか含まれていない場合、96の注釈はクラスとして「物体なし」、バウンディングボックスとして「バウンディングボックスなし」になります)。ハンガリアンマッチングアルゴリズムを使用して、N個のクエリとN個の注釈の間に最適な1対1のマッピングを作成します。次に、標準的な交差エントロピー(クラスに対して)とL1損失と一般化IoU損失の線形結合(バウンディングボックスに対して)を使用して、モデルのパラメータを最適化します。
想定される用途と制限
このモデルは物体検出に使用できます。すべての利用可能なYOLOSモデルを探すには、モデルハブ を参照してください。
使い方
このモデルの使用方法は以下の通りです。
from transformers import YolosImageProcessor, YolosForObjectDetection
from PIL import Image
import torch
import requests
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
model = YolosForObjectDetection.from_pretrained('hustvl/yolos-tiny')
image_processor = YolosImageProcessor.from_pretrained("hustvl/yolos-tiny")
inputs = image_processor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
bboxes = outputs.pred_boxes
target_sizes = torch.tensor([image.size[::-1]])
results = image_processor.post_process_object_detection(outputs, threshold=0.9, target_sizes=target_sizes)[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をサポートしています。
トレーニングデータ
YOLOSモデルは、ImageNet-1k で事前学習され、COCO 2017物体検出 データセット(それぞれ118k/5k枚の注釈付き画像をトレーニング/バリデーションに使用)でファインチューニングされています。
トレーニング
このモデルは、ImageNet-1kで300エポック事前学習され、COCOで300エポックファインチューニングされています。
評価結果
このモデルは、COCO 2017バリデーションセットで28.7のAP(平均精度)を達成しています。評価結果の詳細については、元の論文を参照してください。
BibTeX引用
@article{DBLP:journals/corr/abs-2106-00666,
author = {Yuxin Fang and
Bencheng Liao and
Xinggang Wang and
Jiemin Fang and
Jiyang Qi and
Rui Wu and
Jianwei Niu and
Wenyu Liu},
title = {You Only Look at One Sequence: Rethinking Transformer in Vision through
Object Detection},
journal = {CoRR},
volume = {abs/2106.00666},
year = {2021},
url = {https://arxiv.org/abs/2106.00666},
eprinttype = {arXiv},
eprint = {2106.00666},
timestamp = {Fri, 29 Apr 2022 19:49:16 +0200},
biburl = {https://dblp.org/rec/journals/corr/abs-2106-00666.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
📄 ライセンス
このモデルはApache-2.0ライセンスの下で提供されています。