Spaces:
Runtime error
Runtime error
Create 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'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.inputs.Image(image_mode="RGB")
|
| 22 |
+
label=gr.outputs.Label()
|
| 23 |
+
example=['th(11).jpeg']
|
| 24 |
+
iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label,examples=example )
|
| 25 |
+
iface.launch(inline=False, share=True)
|
| 26 |
+
|