[Python] IndexError: list index out of range (face_image)[0]

Discussão em 'Python' iniciado por Stack, Maio 17, 2025.

  1. Stack

    Stack Membro Participativo

    known_faces = []
    ROOT_FOLDER =""MYpartfile

    known_faces_names = []
    known_faces_encodings = []
    for path in glob.iglob(os.path.join(ROOT_FOLDER, "**", "*.jpg")):
    path = path.replace("\\","/")
    person = path.split("/")[-2]
    known_faces.append([person,path])
    print(known_faces)
    for face in known_faces:
    known_faces_names.append(face[0])
    face_image = face_recognition.load_image_file(face[1])
    face_encoding = face_recognition.face_encodings(face_image)[0]
    known_faces_encodings.append(face_encoding)


    error face_encoding = face_recognition.face_encodings(face_image)[0] IndexError: list index out of range

    i try

    face_encoding = face_recognition.face_encodings(face_image[0])


    but the data is not stored in the array

    print(known_faces_encodings)


    This out put

    [[], [], [], []]

    Continue reading...

Compartilhe esta Página