bhaveshgoel07 commited on
Commit
c58a525
1 Parent(s): 6c403f3

Added application file

Browse files
Files changed (3) hide show
  1. app.py +27 -0
  2. hindimnist.pkl +3 -0
  3. mnist_cnn.pth +3 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pickle
3
+ import numpy as np
4
+
5
+ # Load your model
6
+ with open('your_mnist_model.pkl', 'rb') as f:
7
+ model = pickle.load(f)
8
+
9
+ def predict(image):
10
+ # Preprocess the image
11
+ image = image.reshape(1, 28, 28) / 255.0 # Normalize to 0-1
12
+
13
+ # Make prediction
14
+ probabilities = model.predict_proba(image.reshape(1, -1))[0]
15
+
16
+ # Format output
17
+ return {str(i): float(prob) for i, prob in enumerate(probabilities)}
18
+
19
+ iface = gr.Interface(
20
+ fn=predict,
21
+ inputs=gr.Sketchpad(shape=(28, 28)),
22
+ outputs=gr.Label(num_top_classes=10),
23
+ title="MNIST Digit Classifier",
24
+ description="Draw a digit (0-9) in the canvas and the model will predict it."
25
+ )
26
+
27
+ iface.launch()
hindimnist.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:938ad51e94acf60cee5ddf39d228b6ac9a88cc6f441d0fe1c10b9f2349f0451f
3
+ size 1690954
mnist_cnn.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d3706230da2426c2311152abe6d3cd5db973f229af51efc1a3b98bc4c028c31
3
+ size 1689752