Face_recognition: axis 1 is out of bounds for array of dimension 1

Created on 28 Jan 2018  路  5Comments  路  Source: ageitgey/face_recognition

  • face_recognition version: latest
  • Python version: 3.5.*
  • Operating System: Linux

Description

Getting this error when i compare using face_recognition.compare_faces(encoding,person_encoding)

What I Did

`@shared_task()
def get_encodings_and_compare_with_friends(pk):
    photo = Photo.objects.get(pk=pk)
    persons = Person.objects.all()
    image = face_recognition.load_image_file(photo.image)
    encodings = face_recognition.face_encodings(image)
    for encoding in encodings:
        for person in persons:
            person_encoding=np.loads(person.face_encodings)
            if face_recognition.compare_faces(encoding,person_encoding):
                tag = Tags(photo= photo, tag = person.pk, is_user=True)
                tag.save()
    return
`

Most helpful comment

face_recognition.compare_faces([encoding],person_encoding)

All 5 comments

face_recognition.compare_faces([encoding],person_encoding)

hello
i have the same problem
numpy.AxisError: axis2: axis 1 is out of bounds for array of dimension 1

hello
i have the same problem
numpy.AxisError: axis2: axis 1 is out of bounds for array of dimension 1

hi if u see the last comment. it adds [] to encoding on the linewhere he uses .compare_faces
example:

bad one: face_recognition.compare_faces(encoding,person_encoding):
good one: face_recognition.compare_faces([encoding],person_encoding)

NO solution for this

what is the solution then

Was this page helpful?
0 / 5 - 0 ratings