farid678's picture
Update app.py
0ff21d8 verified
raw
history blame
546 Bytes
import gradio as gr
from model import model
import numpy as np
def predict_age_gender(image):
img_pixels = np.expand_dims(image, axis=0)
img_pixels = image.astype('float')
img_pixels = img_pixels.reshape((1, 128, 128, 3))
img_pixels /= 255
predict = model.predict(img_pixels)
gender_predict = predict[0]
age_predict = predict[1]
return {'Gender': ['Fmale' if gender_predict > 0.5 else 'Male'], 'Age': age_predict[0][0]}
iface = gr.Interface(predict_age_gender, gr.Image(), gr.Text())
iface.launch(share=True)