This software recognizes people in a video or in an image. It uses MTCNN for detection/alignment of faces and FaceNet based model to recognise people. It also used the SVM model to classify people.
Star the repository if you want me to improve this code and optimise for better results
this code is improvement over the project created by ArunMandal53
There was no documentation and no video recognition as well as a feature to save embeddings and compare them with other images.
- Clone this repository.
- Install these in a virtualenv created in the repository. a. tensorflow 1.7 b. numpy 1.16.1 c. opencv-python d. imutils
- In /dataset create a folder for each person you wish to recognise and add pictures of that person in the folder.
- execute extract_embeddings.py
- execute train_model.py
- execute Face_recognition_app.py
Your webcam should start in a few seconds and classify the faces by bounding boxes.
If you face any issue please contact me and also take a screenshot of the error.
What things I have tried?
FACNET
=> I tried to use facenet library directly but could not find proper documentation or API for it.
=> There was no code available that provided me basic building block for code.
=> FaceNet by David Sandberg-- project looks mature, although at the time of writing does not provide a library-based installation nor clean API.
FACEMATCHER
PROS
It can detect similar faces even if the images compared have 10+ years of difference in ages. e.g is given below.
I have intentionally chosen pictures which are a little difficult to recognize but the result is astonishing
OUTPUT
- This model provides good implementation of MTCNN because of which the detection is accurate. => This code only provided basics for face detection and face matching.
CONS
-
the speed seems to be a little low, though on an average I am getting 20 fps + while the video implementation is in beta stage.
-
It uses old libraries. i.e. TensorFlow 1.7 and numpy 1.16.1
What problems did I face? There were a lot of library issue with the code I discovered and there was no requirement.txt available.
Solution => using virtualenv I created a new environment =>tensor-flow has no Session error. This occurs in 16.04 not in 18.04.
This error solved by downgrading to "tf 1.7.1" This resulted in another error related to numpy. I again downgraded numpy to numpy-1.16.1
Steps:
- follow above steps and get the libraries and virtualenv.
- Detect faces in an image or video using MTCNN and align them.
- extract embedding from it.
- match the embedding with image(euclidean distance is used as a parameter, if the threshold value generated is greater than 1.10 then the person are different and if less then the person is same.).
- display whether the persons are same or not.
TO DOs
Implement a SVM based classifier to classify people.Implement video based face recognition.add GitLab link for code.- Implement a DNN based classifier to classify.
- Compare SVN with DNN. Check Speeds.
Basic documentation for the code.
- SVM based classifier implemented.
- Video based recognition implemented.
- Local repository pushed to GitLab
- Note: The repository is 700+ MBs.
Some Working Sample.
** Since I usually get confused between these two, I tried to recognize them using this model.