Image Classification
Transformers
Safetensors
English
siglip
fashion
mnist
siglip2
prithivMLmods commited on
Commit
e195bf2
·
verified ·
1 Parent(s): d85472f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +75 -1
README.md CHANGED
@@ -11,6 +11,8 @@ tags:
11
  - mnist
12
  - siglip2
13
  ---
 
 
14
 
15
  ![sfsfsdf.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/c0hTpHVZmTQySkYq9aCls.png)
16
 
@@ -34,4 +36,76 @@ T-shirt / top 0.8142 0.9147 0.8615 6000
34
  weighted avg 0.9179 0.9180 0.9172 60000
35
  ```
36
 
37
- ![Untitled.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/4RcQ0vyPssALOOCIhpNqu.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  - mnist
12
  - siglip2
13
  ---
14
+ # **Fashion-Mnist-SigLIP2**
15
+ > **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.
16
 
17
  ![sfsfsdf.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/c0hTpHVZmTQySkYq9aCls.png)
18
 
 
36
  weighted avg 0.9179 0.9180 0.9172 60000
37
  ```
38
 
39
+ ![Untitled.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/4RcQ0vyPssALOOCIhpNqu.png)
40
+
41
+ The model categorizes images into the following 10 classes:
42
+ - **Class 0:** "T-shirt / top"
43
+ - **Class 1:** "Trouser"
44
+ - **Class 2:** "Pullover"
45
+ - **Class 3:** "Dress"
46
+ - **Class 4:** "Coat"
47
+ - **Class 5:** "Sandal"
48
+ - **Class 6:** "Shirt"
49
+ - **Class 7:** "Sneaker"
50
+ - **Class 8:** "Bag"
51
+ - **Class 9:** "Ankle boot"
52
+
53
+ # **Run with Transformers🤗**
54
+
55
+ ```python
56
+ !pip install -q transformers torch pillow gradio
57
+ ```
58
+
59
+ ```python
60
+ import gradio as gr
61
+ from transformers import AutoImageProcessor
62
+ from transformers import SiglipForImageClassification
63
+ from transformers.image_utils import load_image
64
+ from PIL import Image
65
+ import torch
66
+
67
+ # Load model and processor
68
+ model_name = "prithivMLmods/Fashion-Mnist-SigLIP2"
69
+ model = SiglipForImageClassification.from_pretrained(model_name)
70
+ processor = AutoImageProcessor.from_pretrained(model_name)
71
+
72
+ def fashion_mnist_classification(image):
73
+ """Predicts fashion category for an image."""
74
+ image = Image.fromarray(image).convert("RGB")
75
+ inputs = processor(images=image, return_tensors="pt")
76
+
77
+ with torch.no_grad():
78
+ outputs = model(**inputs)
79
+ logits = outputs.logits
80
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
81
+
82
+ labels = {
83
+ "0": "T-shirt / top", "1": "Trouser", "2": "Pullover", "3": "Dress", "4": "Coat",
84
+ "5": "Sandal", "6": "Shirt", "7": "Sneaker", "8": "Bag", "9": "Ankle boot"
85
+ }
86
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
87
+
88
+ return predictions
89
+
90
+ # Create Gradio interface
91
+ iface = gr.Interface(
92
+ fn=fashion_mnist_classification,
93
+ inputs=gr.Image(type="numpy"),
94
+ outputs=gr.Label(label="Prediction Scores"),
95
+ title="Fashion MNIST Classification",
96
+ description="Upload an image to classify it into one of the 10 Fashion-MNIST categories."
97
+ )
98
+
99
+ # Launch the app
100
+ if __name__ == "__main__":
101
+ iface.launch()
102
+ ```
103
+
104
+ # **Intended Use:**
105
+
106
+ 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:
107
+
108
+ - **Fashion Recognition:** Classifying fashion images into common categories like shirts, sneakers, and dresses.
109
+ - **E-commerce Applications:** Assisting online retailers in organizing and tagging clothing items for better search and recommendations.
110
+ - **Automated Fashion Sorting:** Helping automated inventory management systems classify fashion items.
111
+ - **Educational Purposes:** Supporting AI and ML research in vision-based fashion classification models.