From 733b8feeba3fa6195f1c7a42156de67903e3cfdb Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Sun, 1 Jan 2023 15:08:36 -0800 Subject: [PATCH] Working! Signed-off-by: James Ketrenos --- test/detect.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/detect.py b/test/detect.py index eef7644..58c6579 100644 --- a/test/detect.py +++ b/test/detect.py @@ -55,24 +55,27 @@ def extract_faces(img_path, threshold=0.9, model = None, align = True, allow_ups nose[0] -= x nose[1] -= y - width *= 0.25 - height *= 0.25 + width *= 1.25 + height *= 1.25 left = round(x - width * 0.5) right = round(left + width) top = round(y - height * 0.5) bottom = round(top + height) - facial_img = img[left: right, top: bottom] + facial_img = img[top: bottom, left: right] - print(left, right, top, bottom, left_eye, right_eye, nose) - aligned = RetinaFace.postprocess.alignment_procedure(facial_img, left_eye, right_eye, nose) + # Eye order is reversed as the routine does them backwards + aligned = RetinaFace.postprocess.alignment_procedure(facial_img, right_eye, left_eye, nose) image = Image.fromarray(aligned) - image.resize(size = (224,224), resample = Image.ANTIALIAS) + image = image.resize(size = (224,224), resample = Image.LANCZOS) resized = np.asarray(image) else: - facial_img = img[facial_area[1]: facial_area[3], facial_area[0]: facial_area[2]] + facial_img = img[ + facial_area[1]: facial_area[3], + facial_area[0]: facial_area[2] + ] resized = facial_img identity['vector'] = DeepFace.represent(img_path = resized, model_name = 'ArcFace', detector_backend = 'opencv', enforce_detection = False)