I am trying to calculate cosine similarity between two face encodings returned by face_Recognition.face encoding() which 128d vector which always is above 0.8 also is the face encoding normalized already or is it not? because I feel like that might be causing the issue

this are the function I used to get

def get_encodings(face):

    return face_recognition.face_encodings(face, model="large")[0]

def cosine_similarity(encodings):
    if len(encodings) < 2:
        return 0
    normalized_encodings = [enc / np.linalg.norm(enc) for enc in encodings]
    return round(np.dot(normalized_encodings[0], normalized_encodings[1]), 2)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy