From b6efc0bed8d2a7050fe8fa98650fa50aeb0d8096 Mon Sep 17 00:00:00 2001 From: Somdev Sangwan Date: Mon, 29 May 2023 17:50:26 +0530 Subject: [PATCH] handle no-face cases --- core/config.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/config.py b/core/config.py index fb69913..df1c3ca 100644 --- a/core/config.py +++ b/core/config.py @@ -7,4 +7,7 @@ face_analyser.prepare(ctx_id=0, det_size=(640, 640)) def get_face(img_data): analysed = face_analyser.get(img_data) - return sorted(analysed, key=lambda x: x.bbox[0])[0] + try: + return sorted(analysed, key=lambda x: x.bbox[0])[0] + except IndexError: + return None