Closed gilviegas closed 1 year ago
This happens when we have a photo stored in the folder /Faces that the module Face_recognition fails to detect a face.
This means that the face_recognition module couldn't find any faces in the image. face_recognition.face_encodings(known_image) basically returns a list of all the faces found in the photo. Now, you are using the index [0] to get the first found face. However, when there is no face in the image, you are trying to get a non-existent index, hence the IndexError.
FIXED!
Added Condition to skip picture.
# Get encoding
if len(face_recognition.face_encodings(rgb_img)) == 0:
continue