Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,14 +2,18 @@ import gradio as gr
|
|
| 2 |
from huggingface_hub import from_pretrained_keras
|
| 3 |
import numpy as np
|
| 4 |
import logging
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
def fun(a):
|
|
|
|
|
|
|
| 10 |
reloaded_model = from_pretrained_keras('jmparejaz/Facial_Age-gender-eth_Recognition')
|
| 11 |
reloaded_model_eth = from_pretrained_keras('jmparejaz/Facial_eth_recognition')
|
| 12 |
#img=load_img(a, grayscale=True)
|
|
|
|
| 13 |
a=a.reshape(1, 48, 48, 1)
|
| 14 |
#reshape((-1,48,48,1))
|
| 15 |
pred=reloaded_model.predict(a)
|
|
@@ -17,4 +21,4 @@ def fun(a):
|
|
| 17 |
return pred[0][0][0],pred[1][0][0],np.argmax(pred_eth)
|
| 18 |
|
| 19 |
|
| 20 |
-
gr.Interface(fn=fun, inputs=gr.inputs.Image(
|
|
|
|
| 2 |
from huggingface_hub import from_pretrained_keras
|
| 3 |
import numpy as np
|
| 4 |
import logging
|
| 5 |
+
from PIL import Image
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
def fun(a):
|
| 11 |
+
Im=Image.fromarray(a).resize(48,48)
|
| 12 |
+
|
| 13 |
reloaded_model = from_pretrained_keras('jmparejaz/Facial_Age-gender-eth_Recognition')
|
| 14 |
reloaded_model_eth = from_pretrained_keras('jmparejaz/Facial_eth_recognition')
|
| 15 |
#img=load_img(a, grayscale=True)
|
| 16 |
+
a=asarray(Im)
|
| 17 |
a=a.reshape(1, 48, 48, 1)
|
| 18 |
#reshape((-1,48,48,1))
|
| 19 |
pred=reloaded_model.predict(a)
|
|
|
|
| 21 |
return pred[0][0][0],pred[1][0][0],np.argmax(pred_eth)
|
| 22 |
|
| 23 |
|
| 24 |
+
gr.Interface(fn=fun, inputs=gr.inputs.Image(image_mode='L',type='numpy',invert_colors=False), outputs=["text","text","text"]).launch()
|