Vishalpainjane commited on
Commit
f131b3e
·
verified ·
1 Parent(s): 7d15414

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import gradio as gr
3
+ import tensorflow as tf
4
+
5
+ model = tf.keras.models.load_model('model1.h5')
6
+
7
+ def recognize_digit(image):
8
+ if image is not None:
9
+ image = np.array(image)
10
+ image.resize((28,28), refcheck=False)
11
+
12
+
13
+ image = image.reshape((1,28,28,1)).astype('float32') / 255
14
+
15
+ prediction = model.predict(image)
16
+
17
+ return {str(i): float(prediction[0][i]) for i in range(10)}
18
+ else:
19
+ return ''
20
+
21
+ iface = gr.Interface(
22
+ fn=recognize_digit,
23
+ inputs=gr.Image(image_mode='L'),
24
+ outputs=gr.Label(num_top_classes=10),
25
+ live=True
26
+ )
27
+
28
+ iface.launch()