Inspiration
- OpenFace
- I refer to the facenet repository of davidsandberg.
- also, shanren7 repository was a great help in implementing.
Dependencies
Install the dependencies first for running the code.
- Tensorflow 1.2.1 - gpu
- Python 3.5
- Same as requirement.txt in davidsandberg repository.
Pre-trained models
- Inception_ResNet_v1 CASIA-WebFace-> 20170511-185253
Face alignment using MTCNN
- You need det1.npy, det2.npy, and det3.npy in the davidsandberg repository.
How to use
- First, we need align face data. So, if you need to run the script 'raw_faces_to_aligned_faces.py' first, the face data that is aligned in the 'faces/group_photos' folder will be saved.
- Secord, we will cluster the same photos together by running the clustering_faces.py and delete the noise manually and combine the clustered faces again using combine_cluster_folder.py
- Third, we need to create our own classifier with the face data we created. First we will rename the folder name with the name of the person.
(In the case of me, I had a high recognition rate when I made 30 pictures for each person.) Your own classifier is a ~.pkl file that loads the previously mentioned pre-trained model ('20170511-185253.pb') and embeds the face for each person.All of these can be obtained by running 'making_classifier.py'.
- Finally, we load our own 'my_classifier.pkl' obtained above and then open the sensor and start recognition by running labeling_faces.py
(Note that, look carefully at the paths of files and folders in all .py)
Result
Directory Strcuture
âââ 20170511-185253
â âââ 20170511-185253.pb
â âââ model-20170511-185253.ckpt-80000.data-00000-of-00001
â âââ model-20170511-185253.ckpt-80000.index
â âââ model-20170511-185253.meta
âââ cls
â âââ my_classifier.pkl
âââ data
â âââ det1.npy
â âââ det2.npy
â âââ det3.npy
âââ faces
â âââ aligned photos atomatically generated from raw_photos
âââ labelled_faces
â âââ folder cointaining name of that person
âââ raw_faces
â âââ Add your group photos here
âââ face_recognition
â âââ __init__.py
â âââ detect_face.py
â âââ model_management.py
â âââ facenet.py
âââ raw_faces_to_aligned_faces.py
âââ making_classifier.py
âââ ModelManagement.py
âââ labeling_faces.py
âââ detect_face.py
âââ facenet.py
âââ classifying_static_image.py
âââ clustering_faces.py
âââ combine_cluster_folder.py
Development
Want to contribute? Great! Contribute using PR Contact me in LinkedIn!