python-3.xopencvface-recognition

Compare two face embeddings


I went through Pyimagesearch face Recognition tutorial, but my application need to compare two faces only, I have embedding of two faces, how to compare them using opencv ? about the trained model which is use to extract embedding from face is mentioned in link, I want to know that what methods I should try to compare two face embedding.


Solution

  • Based on the article you mentioned, you can actually compare if two faces are the same using only the face_recognition library.

    You can use the compare faces to determine if two pictures have the same face

    import face_recognition
    known_image = face_recognition.load_image_file("biden.jpg")
    unknown_image = face_recognition.load_image_file("unknown.jpg")
    
    biden_encoding = face_recognition.face_encodings(known_image)[0]
    unknown_encoding = face_recognition.face_encodings(unknown_image)[0]
    
    results = face_recognition.compare_faces([biden_encoding], unknown_encoding)