Spaces:
Runtime error
Runtime error
from fastai.vision.all import * | |
import gradio as gr | |
# pretrained model | |
learn = load_learner('model.pkl') | |
# The categories | |
categories = ('Katy', 'Zooey') | |
# Define the prediction function | |
def classify_image(img): | |
pred, idx, probs = learn.predict(img) | |
return {categories[i]: float(probs[i]) for i in range(len(categories))} | |
# Gradio interface | |
image = gr.Image(type="pil") | |
label = gr.Label() | |
examples = ['katy.jpg', 'katy2.jpg', 'zooey1.jpg', 'zooey2.jpg'] | |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
intf.launch(inline=False) | |