VanShingel commited on
Commit
0f58034
1 Parent(s): d737fdb
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -43,7 +43,7 @@ def main_pipeline(image):
43
  #image = Image.open(image)
44
 
45
  #image = image.convert("RGB")
46
-
47
  image = np.asarray(image)
48
 
49
  gray_img = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
@@ -83,15 +83,12 @@ def main_pipeline(image):
83
  data = {}
84
  data['age'] = str(age_prds[0][0])
85
  data['gender'] = gender
86
- b_box_arr = [(x, y, w, h) for (x, y, w, h) in faces]
87
 
88
- data['left'] = str(b_box_arr[0][0])
89
- data['top'] = str(b_box_arr[0][1])
90
- data['width'] = str(b_box_arr[0][2])
91
- data['height'] = str(b_box_arr[0][3])
92
- predictions_json = json.dumps(data)
93
 
94
- return predictions_json
 
 
95
 
96
  # initializing the input component
97
  image = gr.inputs.Image(shape = (224, 224))
@@ -101,4 +98,6 @@ labels = gr.outputs.Label()
101
 
102
  # launching the interface
103
  gr.Interface(fn = main_pipeline, inputs = image,
104
- outputs = labels, capture_session = True).launch()
 
 
 
43
  #image = Image.open(image)
44
 
45
  #image = image.convert("RGB")
46
+ original_image = image
47
  image = np.asarray(image)
48
 
49
  gray_img = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
 
83
  data = {}
84
  data['age'] = str(age_prds[0][0])
85
  data['gender'] = gender
 
86
 
87
+ image_b_box = cv2.rectangle(np.asarray(original_image), (x, y), (x+w, y+h), (255, 0, 0), 2)
 
 
 
 
88
 
89
+ result_image = Image.fromarray(image_b_box)
90
+ result_image = result_image.resize((150,150))
91
+ return result_image, data['age'], data['gender']
92
 
93
  # initializing the input component
94
  image = gr.inputs.Image(shape = (224, 224))
 
98
 
99
  # launching the interface
100
  gr.Interface(fn = main_pipeline, inputs = image,
101
+ outputs = ['image',
102
+ 'text',
103
+ 'text'], capture_session = True).launch()