File size: 496 Bytes
77a5b6f
b838192
77a5b6f
9107495
21c7ff6
853b0b0
9107495
853b0b0
 
 
9107495
853b0b0
e9533e2
853b0b0
9107495
853b0b0
9107495
8cee1e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
from fastai.vision.all import *

title = "Grizzly/Black/Teddy bear classifier."

learn = load_learner('export.pkl')
labels = learn.dls.vocab

def classify_image(img):
    pred, idx, probs = learn.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

gr.HTML(title)
image = gr.inputs.Image(shape=(224, 224))
label = gr.outputs.Label(num_top_classes=3)

iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, title=title)
iface.launch()