Spaces:
Sleeping
Sleeping
| # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb. | |
| # %% auto 0 | |
| __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'bear_types', 'classify_image'] | |
| # %% app.ipynb 2 | |
| from fastbook import * | |
| from fastai.vision.widgets import * | |
| import gradio as gr | |
| def bear_types(x):return x[0].isupper() | |
| # Load the model | |
| model_path = 'model.pkl' | |
| learn = load_learner(model_path) | |
| # %% app.ipynb 7 | |
| categories = ('black', 'grizzly', 'teddy') | |
| def classify_image(img): | |
| pred,idx,probs = learn.predict(img) | |
| return dict(zip(categories,map(float,probs))) | |
| # %% app.ipynb 9 | |
| image = gr.Image() | |
| label = gr.Label() | |
| examples = ['Black.jpg', 'grizzly.jpg', 'teddy.jpg'] | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| intf.launch(inline=False) | |