Spaces:
Runtime error
Runtime error
| # AUTOGENERATED! DO NOT EDIT! File to edit: ../fire_detector_gradio.ipynb. | |
| # %% auto 0 | |
| __all__ = ['learner', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image'] | |
| # %% ../fire_detector_gradio.ipynb 1 | |
| from fastai.vision.all import load_learner | |
| import gradio as gr | |
| # %% ../fire_detector_gradio.ipynb 3 | |
| learner = load_learner("model.pkl") | |
| # %% ../fire_detector_gradio.ipynb 4 | |
| categories = ('fireplace fire', "building fire", "wild fire", "lithium battery fire", "bonfire") | |
| def classify_image(im): | |
| pred, idx, probs = learner.predict(im) | |
| return dict(zip(categories, map(float, probs))) | |
| # %% ../fire_detector_gradio.ipynb 6 | |
| image = gr.inputs.Image(shape=(256, 256)) | |
| label = gr.outputs.Label() | |
| examples = ["wildfire.jpg", "bonfire.jpg", "fireplace.jpg", "lithium.jpg"] | |
| intf = gr.Interface(fn=classify_image, inputs=image, | |
| outputs=label, examples=examples) | |
| intf.launch(inline=False) |