Spaces:
Sleeping
Sleeping
| __all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf'] | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| learn = load_learner('beach.pkl') | |
| categories = ('Barnacles', 'Flowers', 'Grass', 'Kelp', 'Mussels', 'Primrose', 'Sage_Bush', 'SeaGull', 'Seashells') | |
| def classify_image(img): | |
| pred, idx, probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| image=gr.Image(height = 192, width = 192) | |
| label = gr.Label() | |
| examples = ['105a9dad-f329-4cfc-b3e3-52ef9334111f.jpg','095f0070-b680-4dbb-aca9-8451129a41bc.jpg', '0ecf9374-9120-4e75-9fc1-6633e61f6115.jpg', '22332b64-118f-48f5-b92b-e2f997d1a8cc.jpg', '270ab7a9-1c17-49b1-b1fe-9827b59aca9c.jpg', '061b7222-e979-4fcf-8454-78b6c879f5f0.jpg', '141747ba-db2a-4d67-af59-dccfa844ba51.jpg', '0cf94408-5399-4754-aba5-5f8bafbd71fd.jpg', '06dc143b-21b9-4dc0-979c-7b6801252cc7.jpg' ] | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| intf.launch(inline=False) |