Update app.py
Browse files
app.py
CHANGED
@@ -171,14 +171,19 @@ def image_inference(image):
|
|
171 |
# faces = [ image[top:bottom, left:right].copy() for (top, left, bottom, right) in rawfaces ]
|
172 |
# faces = RetinaFace.extract_faces( image, align = True)
|
173 |
# faces_mean = [ x.mean() for x in faces ]
|
174 |
-
|
|
|
175 |
# faces = [ image[x:w+x, y:h+y].copy() for (x, y, w, h) in rawfaces ]
|
176 |
faces = [ Image.fromarray(x, mode = 'RGB') for x in faces ]
|
177 |
ages, genders, beards, blurs, ethncities, masks = AnalysisFeatures( faces )
|
178 |
|
179 |
annotatedImage = image.copy()
|
180 |
-
for
|
181 |
-
|
|
|
|
|
|
|
|
|
182 |
|
183 |
return Image.fromarray(annotatedImage, mode = 'RGB'), {'facesLength':len(faces), 'faceMean':faces_mean }#frameWrapper( rawfaces, ages, genders, beards, blurs, ethncities, masks )
|
184 |
# return frameWrapper( rawfaces, ages, genders, beards, blurs, ethncities, masks )
|
|
|
171 |
# faces = [ image[top:bottom, left:right].copy() for (top, left, bottom, right) in rawfaces ]
|
172 |
# faces = RetinaFace.extract_faces( image, align = True)
|
173 |
# faces_mean = [ x.mean() for x in faces ]
|
174 |
+
rawfaces = DeepFace.extract_faces( image )
|
175 |
+
faces = [ x['face'] for x in rawfaces]
|
176 |
# faces = [ image[x:w+x, y:h+y].copy() for (x, y, w, h) in rawfaces ]
|
177 |
faces = [ Image.fromarray(x, mode = 'RGB') for x in faces ]
|
178 |
ages, genders, beards, blurs, ethncities, masks = AnalysisFeatures( faces )
|
179 |
|
180 |
annotatedImage = image.copy()
|
181 |
+
for x in rawfaces:
|
182 |
+
x = x['facial_area']
|
183 |
+
top, left, bottom, right = x['x'], x['y'], x['w'], x['h']
|
184 |
+
bottom += top
|
185 |
+
right += left
|
186 |
+
cv2.rectangle(annotatedImage, (top, bottom), (left, right), (255, 0, 0), 5)
|
187 |
|
188 |
return Image.fromarray(annotatedImage, mode = 'RGB'), {'facesLength':len(faces), 'faceMean':faces_mean }#frameWrapper( rawfaces, ages, genders, beards, blurs, ethncities, masks )
|
189 |
# return frameWrapper( rawfaces, ages, genders, beards, blurs, ethncities, masks )
|