Use original utralytics module for YOLO.

This commit is contained in:
Vincent STRAGIER 2023-06-28 19:53:51 +02:00
parent 0b8e5ca472
commit 80d4dbb64e
2 changed files with 11 additions and 9 deletions

View File

@ -48,15 +48,17 @@ def detect_face(face_detector, img, align=False):
detected_face = img[y: y + h, x: x + w].copy() detected_face = img[y: y + h, x: x + w].copy()
if align: if align:
# Extract landmarks # Tuple of x,y and confidence for left eye
left_eye, right_eye, _, _, _ = result.keypoints.tolist() left_eye = result.keypoints.xy[0][0], result.keypoints.conf[0][0]
# Check the landmarks confidence before alignment # Tuple of x,y and confidence for right eye
if (left_eye[2] > LANDMARKS_CONFIDENCE_THRESHOLD and right_eye = result.keypoints.xy[0][1], result.keypoints.conf[0][1]
right_eye[2] > LANDMARKS_CONFIDENCE_THRESHOLD):
detected_face = FaceDetector.alignment_procedure(
detected_face, left_eye[:2], right_eye[:2]
)
# Check the landmarks confidence before alignment
if (left_eye[1] > LANDMARKS_CONFIDENCE_THRESHOLD and
right_eye[1] > LANDMARKS_CONFIDENCE_THRESHOLD):
detected_face = FaceDetector.alignment_procedure(
detected_face, left_eye[0].cpu(), right_eye[0].cpu()
)
resp.append((detected_face, [x, y, w, h], confidence)) resp.append((detected_face, [x, y, w, h], confidence))
return resp return resp

View File

@ -1,4 +1,4 @@
opencv-contrib-python>=4.3.0.36 opencv-contrib-python>=4.3.0.36
mediapipe>=0.8.7.3 mediapipe>=0.8.7.3
dlib>=19.20.0 dlib>=19.20.0
ultralytics @ git+https://github.com/derronqi/yolov8-face.git@b623989575bdb78601b5ca717851e3d63ca9e01c ultralytics>=8.0.122