Spaces:
Paused
Paused
File size: 914 Bytes
46aa155 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
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()
|