Spaces:
Sleeping
Sleeping
| from fastai.vision.all import * | |
| import gradio as gr | |
| learn = load_learner("model.pkl") | |
| labels = learn.dls.vocab | |
| def classify_image(img): | |
| pred, idx, probs = learn.predict(img) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| image = gr.inputs.Image(shape=(192,192)) | |
| label = gr.outputs.Label() | |
| examples = ['flag_australia.jpg', 'flag_chad.jpg', 'flag_ecuador.jpg', 'flag_monaco.jpg'] | |
| title = "Confusing flags" | |
| description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces." | |
| description = """ | |
| There are too many countries in the world, and even though it'd be interesting to cover all of them, there are a few sets of flags \[0] that look _very_ similar. Namely: | |
| * Chad and Romania | |
| * Senegal and Mali | |
| * Indoneasia and Monaco | |
| * New Zealand and Australia | |
| * Ireland and Côte d’Ivoire | |
| * Norway and Iceland | |
| * Venezuela, Ecuador, and Colombia | |
| * Luxembourg and the Netherlands | |
| * Slovenia, Russia, and Slovakia | |
| This is where this space helps. | |
| \[0]: https://www.britannica.com/list/flags-that-look-alike | |
| """ | |
| iface = gr.Interface(fn=classify_image, inputs=image, outputs=gr.outputs.Label(num_top_classes=3), examples=examples, title=title, description=description) | |
| iface.launch(inline=False) | |