Views
No views yet

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.

1Classification Report:
2 precision recall f1-score support
3
4T-shirt / top 0.8142 0.9147 0.8615 6000
5 Trouser 0.9935 0.9870 0.9902 6000
6 Pullover 0.8901 0.8610 0.8753 6000
7 Dress 0.9098 0.9300 0.9198 6000
8 Coat 0.8636 0.8865 0.8749 6000
9 Sandal 0.9857 0.9847 0.9852 6000
10 Shirt 0.8076 0.6962 0.7478 6000
11 Sneaker 0.9663 0.9695 0.9679 6000
12 Bag 0.9779 0.9805 0.9792 6000
13 Ankle boot 0.9698 0.9700 0.9699 6000
14
15 accuracy 0.9180 60000
16 macro avg 0.9179 0.9180 0.9172 60000
17 weighted avg 0.9179 0.9180 0.9172 60000
!pip install -q transformers torch pillow gradio1import gradio as gr
2from transformers import AutoImageProcessor
3from transformers import SiglipForImageClassification
4from transformers.image_utils import load_image
5from PIL import Image
6import torch
7
8# Load model and processor
9model_name = "prithivMLmods/Fashion-Mnist-SigLIP2"
10model = SiglipForImageClassification.from_pretrained(model_name)
11processor = AutoImageProcessor.from_pretrained(model_name)
12
13def fashion_mnist_classification(image):
14 """Predicts fashion category for an image."""
15 image = Image.fromarray(image).convert("RGB")
16 inputs = processor(images=image, return_tensors="pt")
17
18 with torch.no_grad():
19 outputs = model(**inputs)
20 logits = outputs.logits
21 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
22
23 labels = {
24 "0": "T-shirt / top", "1": "Trouser", "2": "Pullover", "3": "Dress", "4": "Coat",
25 "5": "Sandal", "6": "Shirt", "7": "Sneaker", "8": "Bag", "9": "Ankle boot"
26 }
27 predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
28
29 return predictions
30
31# Create Gradio interface
32iface = gr.Interface(
33 fn=fashion_mnist_classification,
34 inputs=gr.Image(type="numpy"),
35 outputs=gr.Label(label="Prediction Scores"),
36 title="Fashion MNIST Classification Labels",
37 description="Upload an image to classify it into one of the 10 Fashion-MNIST categories."
38)
39
40# Launch the app
41if __name__ == "__main__":
42 iface.launch()