Spaces:
Runtime error
Runtime error
| # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb. | |
| # %% auto 0 | |
| __all__ = ['breeds', 'learn', 'examples', 'iface', 'predict'] | |
| # %% app.ipynb 1 | |
| import gradio as gr | |
| from fastai.vision.all import * | |
| from fastcore.all import * | |
| # %% app.ipynb 2 | |
| breeds = [ | |
| 'English Springer Spaniel', | |
| 'Cocker Spaniel', | |
| 'American Water Spaniel', | |
| 'Irish Water Spaniel', | |
| 'Welsh Springer Spaniel', | |
| ] | |
| learn = load_learner('springer.pkl') | |
| # %% app.ipynb 3 | |
| def predict(img): | |
| p, idx, probs = learn.predict(img) | |
| return dict(zip(learn.dls.vocab, map(float, probs))) | |
| examples = [str(i) for i in (Path('.')/'examples').iterdir()] | |
| iface = gr.Interface(fn=predict, inputs=gr.Image(type='pil'), outputs="label", examples=examples) | |
| iface.launch(inline=False) | |