handle no-face cases

This commit is contained in:
Somdev Sangwan 2023-05-29 17:50:26 +05:30 committed by GitHub
parent 9aa6803c12
commit b6efc0bed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,4 +7,7 @@ face_analyser.prepare(ctx_id=0, det_size=(640, 640))
def get_face(img_data): def get_face(img_data):
analysed = face_analyser.get(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