Spaces:
Runtime error
Runtime error
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) | |