farid678 commited on
Commit
9831883
1 Parent(s): 6b37d39

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
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
- img_pixels = np.expand_dims(image, axis=0)
19
- img_pixels = image.astype('float')
 
 
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(shape=(128, 128)), gr.Text())
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()