Spaces:
Sleeping
Sleeping
| # AUTOGENERATED! DO NOT EDIT! File to edit: fish_or_shark.ipynb. | |
| # %% auto 0 | |
| __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_fish', 'classify_image'] | |
| # %% fish_or_shark.ipynb 1 | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| def is_fish(x): return x[0].isupper() | |
| # %% fish_or_shark.ipynb 3 | |
| learn = load_learner('fish_or_shark_model.pkl') | |
| # %% fish_or_shark.ipynb 5 | |
| categories = ('Fish', 'Shark') | |
| def classify_image(img): | |
| pred,idx,probs = learn.predict(img) | |
| return dict(zip(categories, map(float,probs))) | |
| # %% fish_or_shark.ipynb 7 | |
| image = gr.Image() | |
| label = gr.Label() | |
| examples = ['fish_example.jpg', 'shark_example.jpg'] | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| intf.launch(inline=False) | |