zuzu
test
d6bad87
raw
history blame
829 Bytes
import gradio as gr
import tensorflow as tf
import numpy as np
model = tf.keras.models.load_model("D:\\repos\\tf.arabic\mymodel\mymodel")
def predict(img):
z = tf.keras.preprocessing.image.img_to_array(img)
z = np.expand_dims(z, axis=0)
print(z.shape, z)
y = model.predict(z)
ysoft = tf.nn.softmax(y)
ymax = np.argmax(ysoft)
return ymax
sp = gr.Sketchpad(shape=(140,100), image_mode="L", label='arabic numeral').style(height=400, width=400)
gr.Label()
gr.Interface(fn=predict,
inputs=sp,
outputs="label",
share=True,
live=True,
examples=[
["writer001_pass01_digit2.png"],
["writer001_pass01_digit4.png"],
["writer001_pass07_digit9.png"],
["writer594_pass06_digit7.png"]]).launch()