From b08695ac39ad837176583537d412fdacf2c57087 Mon Sep 17 00:00:00 2001 From: Vincent STRAGIER Date: Tue, 23 May 2023 20:53:29 +0200 Subject: [PATCH] Clean the new wrapper. --- deepface/detectors/Yolov8nfaceWrapper.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/deepface/detectors/Yolov8nfaceWrapper.py b/deepface/detectors/Yolov8nfaceWrapper.py index 1ff7909..29e0d60 100644 --- a/deepface/detectors/Yolov8nfaceWrapper.py +++ b/deepface/detectors/Yolov8nfaceWrapper.py @@ -28,30 +28,18 @@ def detect_face(face_detector, img, align=False): for result in results: x, y, w, h = result.boxes.xywh.tolist()[0] confidence = result.boxes.conf.tolist()[0] - # print(f"Confidence: {confidence}, x: {x}, y: {y}, w: {w}, h: {h}") - # print landmarks - - # print(result.keypoints.tolist()) - # print(f"Left eye: {left_eye}, right eye: {right_eye}") - - # add eyes landmarks to img - # import cv2 - - # img = cv2.circle(img, (int(left_eye[0]), int(left_eye[1])), 2, (0, 0, 255), 2) - # img = cv2.circle(img, (int(right_eye[0]), int(right_eye[1])), 2, (0, 255, 0), 2) - # change to top left corner, width, height x, y, w, h = int(x - w / 2), int(y - h / 2), int(w), int(h) detected_face = img[y : y + h, x : x + w].copy() if align: + # Extract landmarks left_eye, right_eye, _, _, _ = result.keypoints.tolist() # Check the landmarks confidence before alignment - # print(f"Left eye: {left_eye[2]}, right eye: {right_eye[2]}") if left_eye[2] > 0.5 and right_eye[2] > 0.5: - # print("Aligning face") - # print(left_eye[:2], right_eye[:2]) - detected_face = FaceDetector.alignment_procedure(detected_face, left_eye[:2], right_eye[:2]) + detected_face = FaceDetector.alignment_procedure( + detected_face, left_eye[:2], right_eye[:2] + ) resp.append((detected_face, [x, y, w, h], confidence))