🚀 YOLOS (小型) モデル (300エポックの事前学習)
YOLOSモデルは、COCO 2017の物体検出タスク(118,000枚の注釈付き画像)でファインチューニングされています。このモデルは、Fangらによる論文 You Only Look at One Sequence: Rethinking Transformer in Vision through Object Detection で紹介され、このリポジトリ で最初に公開されました。
なお、YOLOSを公開したチームはこのモデルのモデルカードを作成していないため、このモデルカードはHugging Faceチームによって作成されています。
🚀 クイックスタート
YOLOSモデルを使用して物体検出を行うことができます。以下に使用例を示します。
from transformers import YolosImageProcessor, YolosForObjectDetection
from PIL import Image
import requests
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
image_processor = YolosImageProcessor.from_pretrained('hustvl/yolos-small-300')
model = YolosForObjectDetection.from_pretrained('hustvl/yolos-small-300')
inputs = image_processor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
bboxes = outputs.pred_boxes
現在、画像プロセッサとモデルはどちらもPyTorchをサポートしています。
✨ 主な機能
YOLOSは、DETR損失を使用して学習されたVision Transformer (ViT) です。シンプルな構造でありながら、ベースサイズのYOLOSモデルはCOCO 2017のバリデーションセットで42 APを達成することができます(DETRやFaster R-CNNなどのより複雑なフレームワークと同等の性能)。
📦 インストール
このモデルを使用するには、transformers
ライブラリが必要です。以下のコマンドでインストールできます。
pip install transformers
💻 使用例
基本的な使用法
from transformers import YolosImageProcessor, YolosForObjectDetection
from PIL import Image
import requests
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
image_processor = YolosImageProcessor.from_pretrained('hustvl/yolos-small-300')
model = YolosForObjectDetection.from_pretrained('hustvl/yolos-small-300')
inputs = image_processor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
bboxes = outputs.pred_boxes
📚 ドキュメント
モデルの説明
YOLOSは、DETR損失を使用して学習されたVision Transformer (ViT) です。モデルは "二部マッチング損失" を使用して学習されます。具体的には、N = 100の各物体クエリの予測クラスとバウンディングボックスを、同じ長さNにパディングされた正解注釈と比較します。ハンガリアンマッチングアルゴリズムを使用して、N個のクエリとN個の注釈の間に最適な1対1のマッピングを作成します。その後、標準的な交差エントロピー(クラスに対して)とL1損失と一般化IoU損失の線形結合(バウンディングボックスに対して)を使用して、モデルのパラメータを最適化します。
想定される用途と制限
このモデルは物体検出に使用できます。利用可能なすべてのYOLOSモデルを探すには、モデルハブ を参照してください。
🔧 技術詳細
学習データ
YOLOSモデルは、ImageNet-1k で事前学習され、COCO 2017物体検出 でファインチューニングされています。COCO 2017は、それぞれ118,000枚と5,000枚の注釈付き画像からなる学習セットとバリデーションセットを持つデータセットです。
学習方法
モデルはImageNet-1kで300エポック事前学習され、COCOで150エポックファインチューニングされました。
評価結果
このモデルは、COCO 2017のバリデーションセットで 36.1 のAP (平均精度) を達成しています。評価結果の詳細については、原著論文の表1を参照してください。
📄 ライセンス
このモデルはApache-2.0ライセンスの下で公開されています。
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}
}