Update app.py
Browse files
app.py
CHANGED
@@ -157,8 +157,9 @@ def image_inference(image):
|
|
157 |
# Draw rectangle around the faces
|
158 |
# rawfaces = postProcessed( rawfaces, image.shape[:2] )
|
159 |
|
160 |
-
rawfaces = face_recognition.face_locations( image, number_of_times_to_upsample =
|
161 |
faces = [ image[top:bottom, left:right].copy() for (top, left, bottom, right) in rawfaces ]
|
|
|
162 |
# faces = [ image[x:w+x, y:h+y].copy() for (x, y, w, h) in rawfaces ]
|
163 |
faces = [ Image.fromarray(x, mode = 'RGB') for x in faces ]
|
164 |
ages, genders, beards, blurs, ethncities, masks = AnalysisFeatures( faces )
|
@@ -167,7 +168,7 @@ def image_inference(image):
|
|
167 |
for (top, left, bottom, right) in rawfaces:
|
168 |
cv2.rectangle(annotatedImage, (top, left), (left, right), (255, 0, 0), 5)
|
169 |
|
170 |
-
return Image.fromarray(annotatedImage, mode = 'RGB'), frameWrapper( rawfaces, ages, genders, beards, blurs, ethncities, masks )
|
171 |
# return frameWrapper( rawfaces, ages, genders, beards, blurs, ethncities, masks )
|
172 |
def video_inference(video_path):
|
173 |
|
@@ -191,7 +192,7 @@ def video_inference(video_path):
|
|
191 |
except:
|
192 |
break
|
193 |
# rawfaces = postProcessed( rawfaces, image.shape[:2] )
|
194 |
-
rawfaces = face_recognition.face_locations( image, number_of_times_to_upsample =
|
195 |
# Draw rectangle around the faces
|
196 |
# https://stackoverflow.com/questions/15589517/how-to-crop-an-image-in-opencv-using-python for fliping axis
|
197 |
global_facesCo.append( rawfaces )
|
|
|
157 |
# Draw rectangle around the faces
|
158 |
# rawfaces = postProcessed( rawfaces, image.shape[:2] )
|
159 |
|
160 |
+
rawfaces = face_recognition.face_locations( image, number_of_times_to_upsample = 1 , model="hog")
|
161 |
faces = [ image[top:bottom, left:right].copy() for (top, left, bottom, right) in rawfaces ]
|
162 |
+
faces_mean = [ x.mean() for x in faces ]
|
163 |
# faces = [ image[x:w+x, y:h+y].copy() for (x, y, w, h) in rawfaces ]
|
164 |
faces = [ Image.fromarray(x, mode = 'RGB') for x in faces ]
|
165 |
ages, genders, beards, blurs, ethncities, masks = AnalysisFeatures( faces )
|
|
|
168 |
for (top, left, bottom, right) in rawfaces:
|
169 |
cv2.rectangle(annotatedImage, (top, left), (left, right), (255, 0, 0), 5)
|
170 |
|
171 |
+
return Image.fromarray(annotatedImage, mode = 'RGB'), {'facesLength':len(faces), 'faceMean':faces_mean }#frameWrapper( rawfaces, ages, genders, beards, blurs, ethncities, masks )
|
172 |
# return frameWrapper( rawfaces, ages, genders, beards, blurs, ethncities, masks )
|
173 |
def video_inference(video_path):
|
174 |
|
|
|
192 |
except:
|
193 |
break
|
194 |
# rawfaces = postProcessed( rawfaces, image.shape[:2] )
|
195 |
+
rawfaces = face_recognition.face_locations( image, number_of_times_to_upsample = 1 , model="hog")
|
196 |
# Draw rectangle around the faces
|
197 |
# https://stackoverflow.com/questions/15589517/how-to-crop-an-image-in-opencv-using-python for fliping axis
|
198 |
global_facesCo.append( rawfaces )
|