ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
52.84k stars 13.43k forks source link

face verification #1022

Closed flyingmrwang closed 4 years ago

flyingmrwang commented 4 years ago

Description

This work is very helpful to check if two images come from the same person. But my case is I have a pool of faces of same person. How can I improve the accuracy by comparing my probe image with the pool rather than random chosen one? Can I get one embedding with a pool of same person face images?

alessiosavi commented 4 years ago

This packages is a wrapper for the dlib library. It use some mathematical method in order to compare the result of the face_embedding (the vector that contains the point of the face) such as euclideian distance. What you are trying to do, is something that is solved by a neural network. You need to collect some faces for the target person, let the neural network "study" the face points extracted and then predict the faces accordlying to a threshold. You can rely on my little tool PyRecognizer. It use face_recognition package in order to extract the points related to the face, than feed a neural network in order to "save" the data of the person. After the train/tune process, you can predict a new photos of the same people(s) that the network was trained against. The tool rely on a MLP network. You can find more information (such as train with your dataset or use the predict method) in the repository pages. https://github.com/alessiosavi/PyRecognizer

flyingmrwang commented 4 years ago

This packages is a wrapper for the dlib library. It use some mathematical method in order to compare the result of the face_embedding (the vector that contains the point of the face) such as euclideian distance. What you are trying to do, is something that is solved by a neural network. You need to collect some faces for the target person, let the neural network "study" the face points extracted and then predict the faces accordlying to a threshold. You can rely on my little tool PyRecognizer. It use face_recognition package in order to extract the points related to the face, than feed a neural network in order to "save" the data of the person. After the train/tune process, you can predict a new photos of the same people(s) that the network was trained against. The tool rely on a MLP network. You can find more information (such as train with your dataset or use the predict method) in the repository pages. https://github.com/alessiosavi/PyRecognizer

Thanks for your hint. From my current understanding, your work is to extract pattern of target face with input of batch of key points and with the tool of MLP. But what I am wondering is if there is a way to merge the face_embeddings of a batch of target face. Cuz in this way, the merging part can be done offline, and the verification part could be very light weight and fast.

alessiosavi commented 4 years ago

From my current understanding, your work is to extract pattern of target face with input of batch of key points and with the tool of MLP. You are quite right. PyRecognizer use the face_recognition package in order to extract the faces encodings. Instead of save this array, i extract all the encodings related to a particular person in batch, something like this:

encodings = []
for photo in folder_person:
encodings.append(extract_face_point(photo)

Now that i have an array with the different encodings of the same person, i train a neural network (MLP in my case) in order to "understand how is" the face of the target person. By this way, you haven't to save the encodings related to the person in order to iterate among the different encodings each time you need to recognize the person, cause they are saved in the NN internally. The time to predict the face is instant (few milliseconds) with a dataset of 311 people (celebrities), and a total of 5425 photos.

flyingmrwang commented 4 years ago

@alessiosavi So, you are merging the encodings with MLP. This is how most face recognition NNs work, right? But the problem of this topology is we cannot verify the unseen face. I believe that your work can have a great accuracy for test set. But my challenge is I not only have so many ids, but also an increasing number of ids, which means my model should work good for ids which are out side of training set. Correct me if I am wrong :)

alessiosavi commented 4 years ago

So, you are merging the encodings with MLP.

Quite right, the MLP is able to "understand" (=math magic on arrays) the encoding related to the people, but it does not applicate any merge between data.

But the problem of this topology is we cannot verify the unseen face. I believe that your work can have a great accuracy for test set.

Have a try, it's tuned among some celebrities. Try to download a photo related to a person that have few photo (you can see the list on the Readme of the project) and use the threshold parameter to verify how much is accurate. Some celebs have only 6-10 photos. He perform very well with multi faces and with never seen photos.

I think that we can move the issue on the project, cause your questions start to be not related to the face_recognition tool (:

flyingmrwang commented 4 years ago

@alessiosavi Ok, I will have a try of your tool in these days. Thanks for your kind explanations!

alessiosavi commented 4 years ago

It's a pleasure. Do not hesitate to open issue in order to ask how the tool work internally. Cheers (: