Spaces:
Runtime error
Runtime error
sasidhar6493
commited on
Commit
·
cb89fdc
1
Parent(s):
47b950c
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
learn = load_learner('nationalflagidentifier.pkl')
|
5 |
+
|
6 |
+
def predict(image):
|
7 |
+
img = PILImage.create(image)
|
8 |
+
country, idx, probs = learn.predict(img)
|
9 |
+
return f'This is the national flag of {country}------------ Probability: {probs[idx]:.4f}'
|
10 |
+
|
11 |
+
title = 'National Flag Classifier'
|
12 |
+
description = """Upload a flag photo and get to know to which country or dependency it belongs to.
|
13 |
+
267 countries or dependencies supported."""
|
14 |
+
interpretation = 'default'
|
15 |
+
|
16 |
+
infer = gr.Interface(
|
17 |
+
fn = predict,
|
18 |
+
inputs = gr.inputs.Image(shape = (256, 256)),
|
19 |
+
outputs = gr.outputs.Label(num_top_classes = len(learn.dls.vocab)),
|
20 |
+
title = title,
|
21 |
+
description = description,
|
22 |
+
interpretation = interpretation,
|
23 |
+
enble_queue = True
|
24 |
+
)
|
25 |
+
|
26 |
+
infer.launch(share = True)
|