File size: 498 Bytes
7593d97
398e7c5
7593d97
 
398e7c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from fastai.vision.all import load_learner


learn = load_learner("export.pkl")
categories = ("black", "grizzly", "teddy")


def classify_image(img):
    _, _, probs = learn.predict(img)
    return dict(zip(categories, map(float, probs)))


image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ["black.jpg", "grizzly.jpg", "teddy.jpg"]


iface = gr.Interface(
    fn=classify_image, inputs="image", outputs="text", examples=examples
)

iface.launch()