Update app.py
Browse files
app.py
CHANGED
@@ -15,8 +15,10 @@ def predict_age_gender(image):
|
|
15 |
|
16 |
model = model_from_json(loaded_file_json)
|
17 |
model.load_weights('xception_modelv2.h5')
|
18 |
-
|
19 |
-
|
|
|
|
|
20 |
img_pixels = img_pixels.reshape((1, 128, 128, 3))
|
21 |
img_pixels /= 255
|
22 |
|
@@ -26,5 +28,5 @@ def predict_age_gender(image):
|
|
26 |
return {'Gender': ['Fmale' if gender_predict > 0.5 else 'Male'], 'Age': age_predict[0][0]}
|
27 |
|
28 |
|
29 |
-
iface = gr.Interface(predict_age_gender, gr.Image(
|
30 |
iface.launch()
|
|
|
15 |
|
16 |
model = model_from_json(loaded_file_json)
|
17 |
model.load_weights('xception_modelv2.h5')
|
18 |
+
|
19 |
+
images = np.resize(image, new_shape=(1, 128, 128, 3))
|
20 |
+
img_pixels = np.expand_dims(images, axis=0)
|
21 |
+
img_pixels = images.astype('float')
|
22 |
img_pixels = img_pixels.reshape((1, 128, 128, 3))
|
23 |
img_pixels /= 255
|
24 |
|
|
|
28 |
return {'Gender': ['Fmale' if gender_predict > 0.5 else 'Male'], 'Age': age_predict[0][0]}
|
29 |
|
30 |
|
31 |
+
iface = gr.Interface(predict_age_gender, gr.Image(), gr.Text())
|
32 |
iface.launch()
|