🚀 Fashion-Mnist-SigLIP2
Fashion-Mnist-SigLIP2 は、単一ラベル分類タスク向けに google/siglip2-base-patch16-224 からファインチューニングされた画像分類のビジョン言語エンコーダモデルです。SiglipForImageClassification アーキテクチャを使用して、画像を Fashion-MNIST のカテゴリに分類するように設計されています。

SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features https://arxiv.org/pdf/2502.14786

Classification Report:
precision recall f1-score support
T-shirt / top 0.8142 0.9147 0.8615 6000
Trouser 0.9935 0.9870 0.9902 6000
Pullover 0.8901 0.8610 0.8753 6000
Dress 0.9098 0.9300 0.9198 6000
Coat 0.8636 0.8865 0.8749 6000
Sandal 0.9857 0.9847 0.9852 6000
Shirt 0.8076 0.6962 0.7478 6000
Sneaker 0.9663 0.9695 0.9679 6000
Bag 0.9779 0.9805 0.9792 6000
Ankle boot 0.9698 0.9700 0.9699 6000
accuracy 0.9180 60000
macro avg 0.9179 0.9180 0.9172 60000
weighted avg 0.9179 0.9180 0.9172 60000

このモデルは、画像を以下の10クラスに分類します。
- クラス 0: "T-shirt / top"
- クラス 1: "Trouser"
- クラス 2: "Pullover"
- クラス 3: "Dress"
- クラス 4: "Coat"
- クラス 5: "Sandal"
- クラス 6: "Shirt"
- クラス 7: "Sneaker"
- クラス 8: "Bag"
- クラス 9: "Ankle boot"
🚀 クイックスタート
インストール
!pip install -q transformers torch pillow gradio
使用例
import gradio as gr
from transformers import AutoImageProcessor
from transformers import SiglipForImageClassification
from transformers.image_utils import load_image
from PIL import Image
import torch
model_name = "prithivMLmods/Fashion-Mnist-SigLIP2"
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)
def fashion_mnist_classification(image):
"""画像のファッションカテゴリを予測します。"""
image = Image.fromarray(image).convert("RGB")
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
labels = {
"0": "T-shirt / top", "1": "Trouser", "2": "Pullover", "3": "Dress", "4": "Coat",
"5": "Sandal", "6": "Shirt", "7": "Sneaker", "8": "Bag", "9": "Ankle boot"
}
predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
return predictions
iface = gr.Interface(
fn=fashion_mnist_classification,
inputs=gr.Image(type="numpy"),
outputs=gr.Label(label="Prediction Scores"),
title="Fashion MNIST Classification Labels",
description="Upload an image to classify it into one of the 10 Fashion-MNIST categories."
)
if __name__ == "__main__":
iface.launch()
✨ 主な機能
Fashion-Mnist-SigLIP2 モデルは、ファッション画像分類を目的として設計されています。衣類や履物を事前定義された Fashion-MNIST クラスに分類するのに役立ちます。潜在的な使用例は以下の通りです。
- ファッション認識:シャツ、スニーカー、ドレスなどの一般的なカテゴリにファッション画像を分類する。
- 電子商取引アプリケーション:オンライン小売業者が衣類を整理し、タグ付けするのを支援し、検索や推薦を改善する。
- 自動ファッションソート:自動在庫管理システムがファッション商品を分類するのを支援する。
- 教育目的:ビジョンベースのファッション分類モデルに関するAIとMLの研究を支援する。
📄 ライセンス
このプロジェクトは Apache-2.0 ライセンスの下で公開されています。