File size: 554 Bytes
f1d1c42
1215df2
 
 
 
 
 
f1d1c42
1215df2
 
f1d1c42
1215df2
 
 
2f62705
1215df2
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
from fastai.vision.widgets import *
# def greet(name):
#     return "Hello " + name + "!!"
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ['grizzly-bear.jpg', 'black-bear.jpg', 'teddy-bear.jpg']

path = Path()
learn = load_learner(path/'model.pkl')

def classify_image(img):
  pred,pred_idx,probs = learn.predict(img)
  return {'Type': pred, 'Probability': f'{probs[pred_idx]:.04f}'}


iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
iface.launch(inline=False)