zuzu commited on
Commit
d6bad87
1 Parent(s): 1a20b87
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+
5
+ model = tf.keras.models.load_model("D:\\repos\\tf.arabic\mymodel\mymodel")
6
+
7
+ def predict(img):
8
+ z = tf.keras.preprocessing.image.img_to_array(img)
9
+ z = np.expand_dims(z, axis=0)
10
+ print(z.shape, z)
11
+ y = model.predict(z)
12
+ ysoft = tf.nn.softmax(y)
13
+ ymax = np.argmax(ysoft)
14
+ return ymax
15
+
16
+ sp = gr.Sketchpad(shape=(140,100), image_mode="L", label='arabic numeral').style(height=400, width=400)
17
+ gr.Label()
18
+ gr.Interface(fn=predict,
19
+ inputs=sp,
20
+ outputs="label",
21
+ share=True,
22
+ live=True,
23
+ examples=[
24
+ ["writer001_pass01_digit2.png"],
25
+ ["writer001_pass01_digit4.png"],
26
+ ["writer001_pass07_digit9.png"],
27
+ ["writer594_pass06_digit7.png"]]).launch()