Spaces:
Sleeping
Sleeping
File size: 527 Bytes
b71c515 c8932d6 b71c515 c8932d6 b71c515 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from fastai.vision.all import load_learner, Path
import gradio as gr
path = Path()
path.ls(file_exts='.pkl')
learn_inf = load_learner(path/'export.pkl')
categories = ('black', 'grizzly', 'teddy')
def classify_image(img):
pred, idx, probs = learn_inf.predict(img)
return dict(zip(categories, map(float, probs)))
image = gr.Image()
label = gr.Label()
examples = ['grizzly.jpg', 'black.jpg', 'teddy.jpg']
iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
iface.launch(inline=False) |