Spaces:
Paused
Paused
import gradio as gr | |
from fastai.vision.all import * | |
import skimage | |
learn = load_learner("model/model.pkl") | |
labels = learn.dls.vocab | |
def predict(img): | |
img = PILImage.create(img) | |
pred, pred_idx, probs = learn.predict(img) | |
return dict(zip(labels, map(float, probs))) | |
title = "Pet Breed Classifier" | |
description = "A pet breed classifier trained on the Oxford Pets dataset with fastai." | |
article = "<p style='text-align: center'><a href='https://github.com/mchen50' target='_blank'>My Github</a></p>" | |
examples = [ | |
"examples/siamese.jpg", | |
"examples/leonberger.jpg", | |
"examples/leonberger.jpg", | |
] | |
interpretation = "default" | |
app = gr.Interface( | |
fn=predict, | |
inputs=gr.Image(shape=(512, 512)), | |
outputs=gr.Label(num_top_classes=3), | |
title=title, | |
description=description, | |
article=article, | |
examples=examples, | |
interpretation=interpretation, | |
) | |
app.queue() | |
app.launch() | |