Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LFW Evaluation Example #1529

Open
aidansmyth95 opened this issue Aug 30, 2023 · 0 comments
Open

LFW Evaluation Example #1529

aidansmyth95 opened this issue Aug 30, 2023 · 0 comments

Comments

@aidansmyth95
Copy link

face_recognition version: Latest Version
Python version: 3.8
Operating System: Windows

Description

LFW evaluation is essential for evaluating whether or not we are using the model correctly. Can you please provide an example of how to call the model for LFW evaluation (image loading to encoding comparison at least), and state what the LFW accuracy of the model is?

What I Did

This is how I run the model when calculating tp, fp, tn for LFW evaluation. I am getting an average over the 10 k_folds of about 96.6% accuracy.

        # load the input image and convert it from BGR (OpenCV ordering)
        # to dlib ordering (RGB)
        rgb_a = cv2.cvtColor(cv2.imread(img_a), cv2.COLOR_BGR2RGB)
        rgb_b = cv2.cvtColor(cv2.imread(img_b), cv2.COLOR_BGR2RGB)

        # detect the (x, y)-coordinates of the bounding boxes
        # corresponding to each face in the input image
        boxes_a = face_recognition.face_locations(rgb_a, model=args["detection_method"])
        boxes_b = face_recognition.face_locations(rgb_b, model=args["detection_method"])

        # compute the facial embedding for the face
        encodings_a = face_recognition.face_encodings(rgb_a, boxes_a)
        encodings_b = face_recognition.face_encodings(rgb_b, boxes_b)

...

        for encoding in encodings_b:
            matches = face_recognition.compare_faces(encodings_a, encoding, tolerance=th) # check encodings_a for each encoding in encodings_b
            is_match = True in matches
            if is_match:
                # stop early if a match is found
                break

Thanks in advance, love the repo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant