Spaces:
Sleeping
Sleeping
| from fastai.vision.all import * | |
| import gradio as gr | |
| learn = load_learner('model.pkl') | |
| def classify_image(img): | |
| pred, idx, probs = learn.predict(img) | |
| d = dict(zip(learn.dls.vocab, map(float,probs))) | |
| ds = sorted(d.items(), key=lambda item: item[1], reverse=True) | |
| return dict(ds[0:5]) | |
| #image = gr.Image(shape=(244, 244)) | |
| image = gr.Image() | |
| label = gr.Label() | |
| examples = ['dog1.jpg', 'dog2.jpg', 'dog3.jpg'] | |
| #demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, analytics_enabled=False) | |
| demo.launch(inline=False) | |