Instructions to use prithivMLmods/Fashion-Mnist-SigLIP2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/Fashion-Mnist-SigLIP2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="prithivMLmods/Fashion-Mnist-SigLIP2") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoProcessor, AutoModelForImageClassification processor = AutoProcessor.from_pretrained("prithivMLmods/Fashion-Mnist-SigLIP2") model = AutoModelForImageClassification.from_pretrained("prithivMLmods/Fashion-Mnist-SigLIP2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 4,499 Bytes
c6350e1 fb516be c6350e1 b95373c ff449c2 e195bf2 d85472f 49034d8 baf2c85 4e6e19b e195bf2 e840fb9 e195bf2 b95373c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | ---
license: apache-2.0
language:
- en
base_model:
- google/siglip2-base-patch16-224
pipeline_tag: image-classification
library_name: transformers
tags:
- fashion
- mnist
- siglip2
datasets:
- zalando-datasets/fashion_mnist
---

# **Fashion-Mnist-SigLIP2**
> **Fashion-Mnist-SigLIP2** is an image classification vision-language encoder model fine-tuned from **google/siglip2-base-patch16-224** for a single-label classification task. It is designed to classify images into **Fashion-MNIST** categories using the **SiglipForImageClassification** architecture.

*SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features* https://arxiv.org/pdf/2502.14786
```py
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
```

The model categorizes images into the following 10 classes:
- **Class 0:** "T-shirt / top"
- **Class 1:** "Trouser"
- **Class 2:** "Pullover"
- **Class 3:** "Dress"
- **Class 4:** "Coat"
- **Class 5:** "Sandal"
- **Class 6:** "Shirt"
- **Class 7:** "Sneaker"
- **Class 8:** "Bag"
- **Class 9:** "Ankle boot"
# **Run with Transformers🤗**
```python
!pip install -q transformers torch pillow gradio
```
```python
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
# Load model and processor
model_name = "prithivMLmods/Fashion-Mnist-SigLIP2"
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)
def fashion_mnist_classification(image):
"""Predicts fashion category for an 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
# Create Gradio interface
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."
)
# Launch the app
if __name__ == "__main__":
iface.launch()
```
# **Intended Use:**
The **Fashion-Mnist-SigLIP2** model is designed for fashion image classification. It helps categorize clothing and footwear items into predefined Fashion-MNIST classes. Potential use cases include:
- **Fashion Recognition:** Classifying fashion images into common categories like shirts, sneakers, and dresses.
- **E-commerce Applications:** Assisting online retailers in organizing and tagging clothing items for better search and recommendations.
- **Automated Fashion Sorting:** Helping automated inventory management systems classify fashion items.
- **Educational Purposes:** Supporting AI and ML research in vision-based fashion classification models. |