File size: 1,289 Bytes
c0b535e
be5d1c1
 
5e82ea1
 
 
c0b535e
 
5e82ea1
c0b535e
 
 
 
 
eb08ed4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dec6748
 
 
eb08ed4
 
c7fc8ea
c0b535e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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)