Abubakar Abid commited on
Commit
61a421f
·
1 Parent(s): 1d8dc18
Files changed (5) hide show
  1. .gitignore +1 -0
  2. app.py +21 -0
  3. models/mnist-99.0-acc.h5 +3 -0
  4. requirements.txt +2 -0
  5. thumbnail2.png +0 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .idea/*
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ import numpy as np
3
+ from urllib.request import urlretrieve
4
+ import gradio as gr
5
+
6
+ urlretrieve("https://gr-models.s3-us-west-2.amazonaws.com/mnist-model.h5", "mnist-model.h5")
7
+ model = tf.keras.models.load_model("mnist-model.h5")
8
+
9
+ def recognize_digit(image):
10
+ image = image.reshape(1, -1) # add a batch dimension
11
+ prediction = model.predict(image).tolist()[0]
12
+ return {str(i): prediction[i] for i in range(10)}
13
+
14
+ gr.Interface(fn=recognize_digit,
15
+ inputs="sketchpad",
16
+ outputs=gr.outputs.Label(num_top_classes=3),
17
+ live=True,
18
+ css=".footer{display:none}",
19
+ # title="MNIST Sketchpad",
20
+ description="Draw a number 0 through 9 on the sketchpad, and click submit to see the prediction. Model trained on the MNIST dataset.",
21
+ thumbnail="https://raw.githubusercontent.com/gradio-app/real-time-mnist/master/thumbnail2.png").launch();
models/mnist-99.0-acc.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:96db0bab1f1fcaa5c9bfc4821c041db55713eb4c594d738294ee7eb9ccfe75ad
3
+ size 4997568
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ tensorflow==2.3.0
2
+ gradio>=2.2.6
thumbnail2.png ADDED