File size: 505 Bytes
914a1aa
25aaf07
914a1aa
25aaf07
914a1aa
25aaf07
 
 
 
 
 
 
 
 
 
 
 
914a1aa
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 load_learner

learn_inf = load_learner('export.pkl')

categories = ['black', 'grizzly', 'teddy']

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

def classify_img(img):
  pred, idx, probs = learn_inf.predict(img)
  return dict(zip(categories, map(float, probs)))


iface = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples)
iface.launch()