marii/study_group_example
0
1# AUTOGENERATED! DO NOT EDIT! File to edit: 00_app.ipynb (unless otherwise specified).2 3__all__ = ['learn', 'predict', 'labels']4 5# Cell6from fastai.vision.all import *7 8# Cell9learn = load_learner('export.pkl')10 11# Cell12labels = learn.dls.vocab13def predict(img):14 img = PILImage.create(img)15 pred,pred_idx,probs = learn.predict(img)16 17 return {labels[i]: float(probs[i]) for i in range(len(labels))}18 19# Cell20import gradio as gr21 22 23title = "Pet Breed Classifier"24description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."25article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"26examples = ['siamese.jpg']27interpretation='default'28enable_queue=True29 30gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()31 