From 0ec185721e23243fca52266537736e440897617a Mon Sep 17 00:00:00 2001 From: Sefik Ilkin Serengil Date: Sat, 5 Oct 2024 22:30:20 +0100 Subject: [PATCH] nose and mouth unavailable case covered --- deepface/models/face_detection/RetinaFace.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/deepface/models/face_detection/RetinaFace.py b/deepface/models/face_detection/RetinaFace.py index d3b81e7..c687322 100644 --- a/deepface/models/face_detection/RetinaFace.py +++ b/deepface/models/face_detection/RetinaFace.py @@ -42,16 +42,19 @@ class RetinaFaceClient(Detector): # retinaface sets left and right eyes with respect to the person left_eye = identity["landmarks"]["left_eye"] right_eye = identity["landmarks"]["right_eye"] - nose = identity["landmarks"]["nose"] - mouth_right = identity["landmarks"]["mouth_right"] - mouth_left = identity["landmarks"]["mouth_left"] + nose = identity["landmarks"].get("nose") + mouth_right = identity["landmarks"].get("mouth_right") + mouth_left = identity["landmarks"].get("mouth_left") # eyes are list of float, need to cast them tuple of int left_eye = tuple(int(i) for i in left_eye) right_eye = tuple(int(i) for i in right_eye) - nose = tuple(int(i) for i in nose) - mouth_right = tuple(int(i) for i in mouth_right) - mouth_left = tuple(int(i) for i in mouth_left) + if nose is not None: + nose = tuple(int(i) for i in nose) + if mouth_right is not None: + mouth_right = tuple(int(i) for i in mouth_right) + if mouth_left is not None: + mouth_left = tuple(int(i) for i in mouth_left) confidence = identity["score"]