File size: 940 Bytes
9380ac1
 
 
 
 
 
 
 
 
 
 
 
8fc61fc
 
 
 
 
 
 
 
 
 
 
9380ac1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
import numpy as np
from keras.models import load_model

model = load_model("QuickDraw_model.h5")

def QuickDraw(arr):
    arr = arr.reshape((1,28,28,1))
    output = model(arr)
    labels = ["Apple","Cell Phone","Chair","Hot Air Balloon","Jail","Ladder","Line","Spider","Windmill","Zigzag"]
    return {labels[idx]: float(val) for idx, val in enumerate(output[0])}

iface = gr.Interface(fn=QuickDraw, 
                     inputs=gr.Image(source="canvas",
                                    tool="sketch",
                                    brush_radius=0.7,
                                    invert_colors=True,
                                    heigt=400,
                                    width=400,
                                    shape=(28,28),
                                    image_mode="L",
                                    interactive=True),
                    outputs="label")
iface.launch()