🚀 Swin Transformer(基礎サイズモデル)
Swin Transformerは、解像度224x224のImageNet - 1kデータセットで学習されたモデルです。画像分類などの視覚タスクに利用でき、関連分野の研究やアプリケーションに強力なサポートを提供します。
🚀 クイックスタート
Swin Transformerモデルは画像分類タスクに使用できます。モデルセンターで、関心のあるタスクの微調整バージョンを見つけることができます。以下は、COCO 2017データセットの画像を1000のImageNetカテゴリの1つに分類するためのモデルの使用例です。
from transformers import AutoFeatureExtractor, SwinForImageClassification
from PIL import Image
import requests
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/swin-base-patch4-window7-224")
model = SwinForImageClassification.from_pretrained("microsoft/swin-base-patch4-window7-224")
inputs = feature_extractor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
predicted_class_idx = logits.argmax(-1).item()
print("Predicted class:", model.config.id2label[predicted_class_idx])
より多くのコード例については、ドキュメントを参照してください。
✨ 主な機能
Swin Transformerは視覚Transformerの一種です。より深い層で画像パッチ(灰色部分)を結合することで階層的な特徴マップを構築し、各局所ウィンドウ(赤色部分)内でのみ自己注意を計算するため、入力画像サイズに対して線形の計算量を持ちます。これにより、画像分類や密集認識タスクの汎用バックボーンネットワークとして使用できます。これに対し、以前の視覚Transformerは単一の低解像度の特徴マップしか生成できず、グローバルな自己注意の計算により、入力画像サイズに対して2次の計算量を持っていました。

出典
📚 ドキュメント
想定用途と制限
元のモデルを使用して画像分類を行うことができます。モデルセンターで、関心のあるタスクの微調整バージョンを見つけることができます。
BibTeX引用
@article{DBLP:journals/corr/abs-2103-14030,
author = {Ze Liu and
Yutong Lin and
Yue Cao and
Han Hu and
Yixuan Wei and
Zheng Zhang and
Stephen Lin and
Baining Guo},
title = {Swin Transformer: Hierarchical Vision Transformer using Shifted Windows},
journal = {CoRR},
volume = {abs/2103.14030},
year = {2021},
url = {https://arxiv.org/abs/2103.14030},
eprinttype = {arXiv},
eprint = {2103.14030},
timestamp = {Thu, 08 Apr 2021 07:53:26 +0200},
biburl = {https://dblp.org/rec/journals/corr/abs-2103-14030.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
📄 ライセンス
このプロジェクトはApache - 2.0ライセンスの下で提供されています。