Spaces:
Sleeping
Sleeping
Download app.py from tuffi67/ScaninavianFlags: direct link, hf CLI and curl.
- Browser
- Download file 570 Bytes
-
https://huggingface.co/spaces/tuffi67/ScaninavianFlags/resolve/main/app.py
- Command line
-
hf download hf://spaces/tuffi67/ScaninavianFlags/app.py
-
curl -L -o app.py https://huggingface.co/spaces/tuffi67/ScaninavianFlags/resolve/main/app.py
570 Bytes
| from fastai.vision.all import * | |
| import gradio as gr | |
| # Cell | |
| learn = load_learner('nordic_flags.pkl') | |
| # Cell | |
| categories = ('Denmark', 'Finland', 'Iceland', 'Norway', 'Other', 'Sweden') | |
| 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 = ['denmark.jpg', 'finland.jpg', 'iceland.jpg', 'norway.jpg', 'sweden.jpg', 'usa.jpg'] | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| intf.launch(inline=False, share=True) | |