Update app.py
Browse files
app.py
CHANGED
|
@@ -173,17 +173,14 @@ def image_inference(image):
|
|
| 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
|
| 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'), frameWrapper( rawfaces, ages, genders, beards, blurs, ethncities, masks )
|
| 189 |
# return frameWrapper( rawfaces, ages, genders, beards, blurs, ethncities, masks )
|
|
|
|
| 173 |
# faces_mean = [ x.mean() for x in faces ]
|
| 174 |
rawfaces = DeepFace.extract_faces( image )
|
| 175 |
faces = [ x['face'] for x in rawfaces]
|
| 176 |
+
rawfaces = [ (x['facial_area']['x'], x['facial_area']['y'], x['facial_area']['w'], x['facial_area']['h']) for x in rawfaces ]
|
| 177 |
# faces = [ image[x:w+x, y:h+y].copy() for (x, y, w, h) in rawfaces ]
|
| 178 |
faces = [ Image.fromarray(x, mode = 'RGB') for x in faces ]
|
| 179 |
ages, genders, beards, blurs, ethncities, masks = AnalysisFeatures( faces )
|
| 180 |
|
| 181 |
annotatedImage = image.copy()
|
| 182 |
+
for (x, y, w, h) in rawfaces:
|
| 183 |
+
cv2.rectangle(annotatedImage, (x, x+w), (y, y+h), (255, 0, 0), 5)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
return Image.fromarray(annotatedImage, mode = 'RGB'), frameWrapper( rawfaces, ages, genders, beards, blurs, ethncities, masks )
|
| 186 |
# return frameWrapper( rawfaces, ages, genders, beards, blurs, ethncities, masks )
|