Spaces:
Sleeping
Sleeping
| # AUTOGENERATED! DO NOT EDIT! File to edit: ../toad_frog_testing.ipynb. | |
| # %% auto 0 | |
| __all__ = ['toad_frog_model', 'categories', 'image', 'label', 'examples', 'gradio_interface', 'classify_image'] | |
| # %% ../toad_frog_testing.ipynb 3 | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| # %% ../toad_frog_testing.ipynb 7 | |
| toad_frog_model = load_learner("toadfrog.pkl") | |
| # %% ../toad_frog_testing.ipynb 11 | |
| categories = ('Frog', 'Toad') | |
| def classify_image(img_path: str): | |
| prediction, index, probabilities = toad_frog_model.predict(img_path) | |
| return dict(zip(categories, map(float, probabilities))) | |
| # %% ../toad_frog_testing.ipynb 14 | |
| image = gr.inputs.Image(shape=(192,192)) | |
| label = gr.outputs.Label() | |
| examples = ["testing/sample_toad.jpg", "testing/sample_frog.jpg"] | |
| gradio_interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| gradio_interface.launch(inline=False) | |