prithivMLmods commited on
Commit
d95d336
·
verified ·
1 Parent(s): 4c22be6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +102 -0
README.md CHANGED
@@ -1,7 +1,27 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
4
 
 
 
 
 
 
 
5
  ```py
6
  Classification Report:
7
  precision recall f1-score support
@@ -23,3 +43,85 @@ weighted avg 0.9928 0.9928 0.9928 60000
23
  ```
24
 
25
  ![download (2).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/qUaioZfL840_BrRhReCqd.png)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ datasets:
4
+ - ylecun/mnist
5
+ language:
6
+ - en
7
+ base_model:
8
+ - google/siglip2-base-patch16-224
9
+ pipeline_tag: image-classification
10
+ library_name: transformers
11
+ tags:
12
+ - Digits
13
+ - Mnist
14
+ - SigLIP2
15
+ - 0-t0-9
16
+ - Number-Classification
17
  ---
18
 
19
+ ![fQPjrpOKabPgt_9vCH4Qj.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/rB4X4q0YZkX0WJW6fZ83F.png)
20
+
21
+ # **Mnist-Digits-SigLIP2**
22
+
23
+ > **Mnist-Digits-SigLIP2** is an image classification model fine-tuned from **google/siglip2-base-patch16-224** to classify handwritten digits (0-9) using the **SiglipForImageClassification** architecture. It is trained on the MNIST dataset for accurate digit recognition.
24
+
25
  ```py
26
  Classification Report:
27
  precision recall f1-score support
 
43
  ```
44
 
45
  ![download (2).png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/qUaioZfL840_BrRhReCqd.png)
46
+
47
+ ### **Classes:**
48
+ - **Class 0:** "0"
49
+ - **Class 1:** "1"
50
+ - **Class 2:** "2"
51
+ - **Class 3:** "3"
52
+ - **Class 4:** "4"
53
+ - **Class 5:** "5"
54
+ - **Class 6:** "6"
55
+ - **Class 7:** "7"
56
+ - **Class 8:** "8"
57
+ - **Class 9:** "9"
58
+
59
+ ---
60
+
61
+ # **Run with Transformers🤗**
62
+
63
+ ```python
64
+ !pip install -q transformers torch pillow gradio
65
+ ```
66
+
67
+ ```python
68
+ import gradio as gr
69
+ from transformers import AutoImageProcessor, SiglipForImageClassification
70
+ from transformers.image_utils import load_image
71
+ from PIL import Image
72
+ import torch
73
+
74
+ # Load model and processor
75
+ model_name = "prithivMLmods/Mnist-Digits-SigLIP2"
76
+ model = SiglipForImageClassification.from_pretrained(model_name)
77
+ processor = AutoImageProcessor.from_pretrained(model_name)
78
+
79
+ def classify_digit(image):
80
+ """Predicts the digit in the given handwritten digit image."""
81
+ image = Image.fromarray(image).convert("RGB")
82
+ inputs = processor(images=image, return_tensors="pt")
83
+
84
+ with torch.no_grad():
85
+ outputs = model(**inputs)
86
+ logits = outputs.logits
87
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
88
+
89
+ labels = {
90
+ "0": "0", "1": "1", "2": "2", "3": "3", "4": "4",
91
+ "5": "5", "6": "6", "7": "7", "8": "8", "9": "9"
92
+ }
93
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
94
+
95
+ return predictions
96
+
97
+ # Create Gradio interface
98
+ iface = gr.Interface(
99
+ fn=classify_digit,
100
+ inputs=gr.Image(type="numpy"),
101
+ outputs=gr.Label(label="Prediction Scores"),
102
+ title="MNIST Digit Classification 🔢",
103
+ description="Upload a handwritten digit image (0-9) to recognize it using MNIST-Digits-SigLIP2."
104
+ )
105
+
106
+ # Launch the app
107
+ if __name__ == "__main__":
108
+ iface.launch()
109
+ ```
110
+
111
+ ---
112
+
113
+ # **Sample Inference**
114
+
115
+ ![Screenshot 2025-03-28 at 23-23-02 MNIST Digit Classification 🔢.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/o0YinTlr6or3V_wOJMCf3.png)
116
+ ![Screenshot 2025-03-28 at 23-25-22 MNIST Digit Classification 🔢.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/LP4upkfHfUa3wdRSSS9tp.png)
117
+ ![Screenshot 2025-03-28 at 23-25-52 MNIST Digit Classification 🔢.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/XJ0AmEg0Com-KN32jtGDu.png)
118
+ ![Screenshot 2025-03-28 at 23-26-52 MNIST Digit Classification 🔢.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/rboO-rw7BxK7S8vJMF-To.png)
119
+
120
+ # **Intended Use:**
121
+
122
+ The **Mnist-Digits-SigLIP2** model is designed for handwritten digit recognition. Potential applications include:
123
+
124
+ - **Optical Character Recognition (OCR):** Digit recognition for various documents.
125
+ - **Banking & Finance:** Automated check processing.
126
+ - **Education & Learning:** AI-powered handwriting assessment.
127
+ - **Embedded Systems:** Handwriting input in smart devices.