File size: 471 Bytes
7c310c5
 
6938305
 
7c310c5
6938305
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gradio as gr

from fastai.vision.all import *
learner = load_learner("export.pkl")

categories = ['black bear', 'grizzly bear', 'teddy bear']
def classify_image(image):
    pred, idx, prob = learner.predict(im)
    return dict(zip(categories, map(float, prob)))

image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ['test_image.jpg']

intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)

intf.launch()