File size: 825 Bytes
b293739
dcdd6b6
b293739
dcdd6b6
b293739
dcdd6b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr
from fastai.vision.all import *

learn = load_learner("model.pkl")

categories = learn.dls.vocab


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


title = "Bear Classifier"
description = "A bear classifier trained on the images downloaded from bing serach with fastai."

image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ["black_bear.jpg", "brizzly_bear.jpg", "teddy_bear.jpg"]
interpretation = "default"
enable_queue = True

itf = gr.Interface(fn=predict,
                   inputs=image,
                   outputs=label,
                   title=title,
                   examples=examples,
                   interpretation=interpretation,
                   enable_queue=enable_queue)

itf.launch()