mtcnn icon indicating copy to clipboard operation
mtcnn copied to clipboard

How to get face embedding / encoding?

Open josephernest opened this issue 5 years ago • 6 comments

Congrats for this nice project @ipazc! I see the output of your algorithm is something like:

[
    {
        'box': [277, 90, 48, 63],
        'keypoints':
        {
            'nose': (303, 131),
            'mouth_right': (313, 141),
            'right_eye': (314, 114),
            'left_eye': (291, 117),
            'mouth_left': (296, 143)
        },
        'confidence': 0.99851983785629272
    }
]

i.e. it gives the bounding box, the keypoints (nose, mouth, eye, etc.).

But how to get an face embedding / face encoding, to be able to do face identification?

josephernest avatar Oct 30 '20 13:10 josephernest

I may have misunderstood what you are asking, but this project isn't about getting face encodings for recognition purposes. For that, you will need something else, such as https://github.com/ageitgey/face_recognition.

MattyB95 avatar Oct 30 '20 17:10 MattyB95

@MattyB95 Maybe I misunderstood this project, but I thought MTCNN + FaceNet not only allows face detection, but also recognition / identification, by assigning a 128D vector embedding to each face.

https://github.com/davidsandberg/facenet

Is it correct @ipazc?

josephernest avatar Oct 30 '20 17:10 josephernest

@josephernest I'm not completely familiar with FaceNet but wouldn't that be providing the face recognition/identification encodings. This project would be more about cropping the image to the facial region for that purpose, but I will let @ipazc give his verdict :)

MattyB95 avatar Oct 30 '20 17:10 MattyB95

MTCNN is only used to detect faces in an image, The value in the the "box" are the corners for the face box in an image To get the face encoding you will need to pass the the pixels resulted from cropping the image to a face corners to one of the models that are used for face encoding, as facenet, deepface,....

imnimn avatar Nov 03 '20 17:11 imnimn

@imnimn Is there a Python implementation that packs together: MTCNN to get the face box + facenet or deepface for the encoding?

josephernest avatar Nov 08 '20 21:11 josephernest

@imnimn Is there a Python implementation that packs together: MTCNN to get the face box + facenet or deepface for the encoding?

@josephernest please check this article: https://arsfutura.com/magazine/face-recognition-with-facenet-and-mtcnn/, It is implementation is in this repository https://github.com/arsfutura/face-recognition

imnimn avatar Nov 09 '20 11:11 imnimn