File size: 393 Bytes
0615b3c
 
 
 
 
86bac40
0615b3c
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import keras
import gradio as gr

model = keras.models.load_model("model.keras")


def recognize_digit(img):
    img = img.reshape(1, 784)
    img = img / 255
    prediction = model.predict(img).tolist()[0]
    return {str(i): prediction[i] for i in range(10)}


gr.Interface(
    recognize_digit,
    inputs=gr.Sketchpad(),
    outputs=gr.Label(),
    title="Predict from 0 to 9",
).launch()