Spaces:
Runtime error
Runtime error
import gradio as gr | |
from fastai.vision.all import * | |
from fastai.vision.widgets import * | |
from fastai.callback.preds import load_learner | |
import skimage | |
learner = load_learner('model.pkl') | |
labels = learner.dls.vocab | |
def classify_image(img): | |
pred, idx, probs = learner.predict(img) | |
return dict(zip(learner.dls.vocab, map(float, probs))) | |
title = "Pet Breed Classifier" | |
description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces." | |
article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>" | |
examples = ['siamese.jpg', 'dog.jpg'] | |
interpretation='default' | |
enable_queue=True | |
image = gr.inputs.Image(shape=(192, 192)) | |
label = gr.outputs.Label(num_top_classes=3) | |
out_pl = widgets.Output() | |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
intf.launch() |