Spaces:
Sleeping
Sleeping
#!/usr/bin/env python | |
# coding: utf-8 | |
#!export | |
from fastai.vision.all import * | |
from fastai.vision.widgets import * | |
import gradio as gr | |
#!export | |
categories = ("black","grizzly", "teddy") | |
def classify_image(img): | |
path = Path() | |
path.ls(file_exts='.pkl') | |
learn_inf = load_learner(path/'modlbear.pkl') | |
pred, idx, probs = learn_inf.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
image = gr.Image(height=192, width=192) | |
label = gr.Label() | |
examples = ['black_bear.jpeg','grizzly_bear.jpeg', 'teddy_bear.jpeg'] | |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title="Bear Classifier") | |
intf.launch(inline=False, share=True) | |