ayaanzaveri commited on
Commit
a0f7663
·
1 Parent(s): be854d3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ import numpy as np
3
+ from urllib.request import urlretrieve
4
+ import gradio as gr
5
+
6
+ model = tf.keras.models.load_model("mnist-model.h5")
7
+
8
+ def recognize_digit(image):
9
+ image = cv.resize(image, (28, 28))
10
+ image = image / 255
11
+ image = image.reshape((1, 28, 28))
12
+ prediction = model.predict(image).tolist()[0]
13
+ return {str(i): prediction[i] for i in range(10)}
14
+
15
+ gr.Interface(fn=recognize_digit,
16
+ inputs="sketchpad",
17
+ outputs=gr.outputs.Label(num_top_classes=3),
18
+ live=True,
19
+ css=".footer {display:none !important}",
20
+ # title="MNIST Sketchpad",
21
+ description="Draw a number 0 through 9 on the sketchpad, and see predictions in real time.",
22
+ thumbnail="https://raw.githubusercontent.com/gradio-app/real-time-mnist/master/thumbnail2.png").launch();