tamerthamoqa / facenet-realtime-face-recognition

A small-scale flask server facial recognition system, using a pre-trained facenet model with real-time web camera face recognition functionality, and a pre-trained Multi-Task Cascading Convolutional Neural Network (MTCNN) for face detection and cropping.
MIT License
98 stars 29 forks source link

Regarding login with face recognition #12

Closed nagapoornima22 closed 4 years ago

nagapoornima22 commented 4 years ago

Hi Tamer,

      Thank you very much for your contribution of Face-Recognition project on Github. Can we use this face recognition algorithm at the login page. I am new to this Ml please suggest me how to approach for login face recognition.

Thanks.

tamerthamoqa commented 4 years ago

Hi nagapoornima22,

I am assuming a stored face image embedding would be linked to a certain username in your project.

I think implementing the facial recognition functionality (face detection and cropping then inserting the cropped image to the facial recognition model and then comparing the Euclidean distance by a distance threshold with a stored face image embedding) would be done best as an additional step in the login validation pipeline you are using, like implementing it as a function inside the pipeline that returns a boolean value of True or False: True if the euclidean distance of the input image embedding and the stored face image embedding is less or equal to the threshold which you have to fine-tune yourself (lower threshold value makes it more difficult but gives a more 'accurate' result) and False otherwise. And then would proceed or not proceed through the validation pipeline depending on the result of True or False.

How it gets its input image containing a human face for login; either from a selfie picture or from a camera stream would depend on your requirements. But, I think an image upload functionality for the selfie image in the login page would work best.

I hope this was useful.

nagapoornima22 commented 4 years ago

thank you ,

nagapoornima22 commented 4 years ago

Hi Tamer,

From the camera stream it should capture and validate. Is it possible with the embeddings? Please suggest me to follow that.

Thanks

tamerthamoqa commented 4 years ago

I was assuming you want to implement facial recognition as an extra step in a user login page with username and password login.

If you want to use a camera stream for automatic login by user faces, this repository would only return the name of the embedding which is closest to the embedding of the input face image from the camera stream, keep in mind it is best practice to have at least 3 stored face images with different perspectives as a best practice (one from the front perspective, one from a slight right perspective, one from a slight left perspectvie). However, this implementation does not support multiple face images per person, but there are implementations on GitHub that support that feature by having multiple images inside a folder containing the name of the person, unfortunately I don't remember exactly any repository that has that feature.

I would assume creating a database table associating users with the name of their stored face image(s) embedding(s) and then using that relation to login a user to your project would work best. You would need to fine-tune the euclidean distance threshold to be lower if you want it to be more 'accurate' and handle any other login attempt by the camera for the same user to be refused by the system during the same day after the first successful login, but that would depend on the requirements of your project if it has to do more than one login per day.