Skip to content

Commit f0f9a79

Browse files
committed
Prevent no attribute error when using Mtcnn
1 parent 0833da1 commit f0f9a79

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

deepface/detectors/FastMtCnn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def detect_faces(
4444
detections = self.model.detect(
4545
img_rgb, landmarks=True
4646
) # returns boundingbox, prob, landmark
47-
if len(detections[0]) > 0:
47+
if detections is not None and len(detections) > 0:
4848

4949
for current_detection in zip(*detections):
5050
x, y, w, h = xyxy_to_xywh(current_detection[0])

deepface/detectors/MtCnn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def detect_faces(
4646
img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # mtcnn expects RGB but OpenCV read BGR
4747
detections = self.model.detect_faces(img_rgb)
4848

49-
if len(detections) > 0:
49+
if detections is not None and len(detections) > 0:
5050

5151
for current_detection in detections:
5252
x, y, w, h = current_detection["box"]

0 commit comments

Comments
 (0)