Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from fastai.vision.all import * | |
| import skimage | |
| def is_cat(x): | |
| return x[0].isupper() | |
| learn = load_learner('model.pkl') | |
| categories = ('Dog', 'Cat') | |
| def predict(img): | |
| img = PILImage.create(img) | |
| pred,pred_idx,probs = learn.predict(img) | |
| return dict(zip(categories, map(float,probs))) | |
| title = "Pet Breed Classifier" | |
| description = "A pet breed classifier trained on the Oxford Pets dataset with fastai." | |
| examples = [['cat.jpeg'], | |
| ['dog.jpeg'], | |
| ['cat2.jpeg'], | |
| ['dog2.jpeg'], | |
| ['cat3.jpeg'], | |
| ['dog3.jpeg'], | |
| ['cat4.jpeg'], | |
| ['dog4.jpeg']] | |
| interpretation='default' | |
| enable_queue=True | |
| gr.Interface( | |
| fn=predict, | |
| inputs=gr.inputs.Image(shape=(512, 512)), | |
| outputs=gr.outputs.Label(), | |
| title=title, | |
| description=description, | |
| examples=examples, | |
| interpretation=interpretation, | |
| enable_queue=enable_queue).launch() |