Spaces:
Runtime error
Runtime error
marufc36
commited on
Commit
·
cc966a6
1
Parent(s):
be83f1c
add app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import load_learner
|
2 |
+
import gradio as gr
|
3 |
+
labels=(
|
4 |
+
'African people picture',
|
5 |
+
'British people picture',
|
6 |
+
'East Asain people picture',
|
7 |
+
'Eskimo people picture',
|
8 |
+
'European people picture',
|
9 |
+
'Indigenous American people picture',
|
10 |
+
'Indigenous Australians people picture',
|
11 |
+
'Indigenous people picture',
|
12 |
+
'Negrito people picture',
|
13 |
+
'Semitic people picture'
|
14 |
+
)
|
15 |
+
model=load_learner(f'models/humanRace-v11.pkl')
|
16 |
+
def recognize_image(image):
|
17 |
+
pred, idx, probs=model.predict(image)
|
18 |
+
print(pred)
|
19 |
+
return dict(zip(labels, map(float, probs)))
|
20 |
+
|
21 |
+
image = gr.Image(image_mode="RGB")
|
22 |
+
label=gr.Label()
|
23 |
+
example=['test_images/th(11).jpeg']
|
24 |
+
iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label,examples=example )
|
25 |
+
iface.launch(inline=False, share=True)
|
26 |
+
|