Spaces:
Sleeping
Sleeping
| from fastai.vision.all import * | |
| import gradio as gr | |
| learn = load_learner('model.pkl') | |
| categories = ('Computer', 'Smartphone', 'Typewriter') | |
| def classify_image(img): | |
| pred,idx,probs = learn.predict(img) | |
| return dict(zip(categories, map(float,probs))) | |
| # Cell | |
| image = gr.Image() | |
| label = gr.Label() | |
| examples = ['computer.jpg', 'smartphone.jpg', 'typewriter.jpg'] | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, title='Is it a computer, smartphone or typewriter?', theme=gr.themes.Soft()) | |
| intf.launch(inline=False, share=True) |