Spaces:
Runtime error
Runtime error
| from fastai.vision.all import * | |
| import gradio as gr | |
| import skimage | |
| import os | |
| from pathlib import Path | |
| learn = load_learner('puppy.pkl') | |
| labels = learn.dls.vocab | |
| def predict(img): | |
| img = PILImage.create(img) | |
| pred,pred_idx,probs = learn.predict(img) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| title = "Puppy Breed Classifier" | |
| description = "A puppy breed classifier trained on a custom dataset from DDG images with fastai. Created as a demo for Gradio and HuggingFace Spaces." | |
| image = gr.Image(height=215, width=215) | |
| label = gr.Label() | |
| examples = [['corgi puppy.jfif'], ['golden retriever.jfif'], ['husky bear.jfif']] | |
| intf = gr.Interface(fn=predict, inputs=image, outputs=label, title=title, description=description,examples=examples) | |
| intf.launch(inline=False) | |