From f0f9a792eccf235b8e59379dcb40bb848d62d038 Mon Sep 17 00:00:00 2001 From: MattPChoy Date: Sat, 27 Jan 2024 22:02:10 +1000 Subject: [PATCH] Prevent no attribute error when using Mtcnn --- deepface/detectors/FastMtCnn.py | 2 +- deepface/detectors/MtCnn.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deepface/detectors/FastMtCnn.py b/deepface/detectors/FastMtCnn.py index c43ed556..0b6f3a93 100644 --- a/deepface/detectors/FastMtCnn.py +++ b/deepface/detectors/FastMtCnn.py @@ -44,7 +44,7 @@ def detect_faces( detections = self.model.detect( img_rgb, landmarks=True ) # returns boundingbox, prob, landmark - if len(detections[0]) > 0: + if detections is not None and len(detections) > 0: for current_detection in zip(*detections): x, y, w, h = xyxy_to_xywh(current_detection[0]) diff --git a/deepface/detectors/MtCnn.py b/deepface/detectors/MtCnn.py index aefb5f60..66bdc076 100644 --- a/deepface/detectors/MtCnn.py +++ b/deepface/detectors/MtCnn.py @@ -46,7 +46,7 @@ def detect_faces( img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # mtcnn expects RGB but OpenCV read BGR detections = self.model.detect_faces(img_rgb) - if len(detections) > 0: + if detections is not None and len(detections) > 0: for current_detection in detections: x, y, w, h = current_detection["box"]