[NOT ACTIVELY MAINTAINED] A light weight face recognition implementation using a pre-trained facenet model. Most of the code is taken from David Sandberg's facenet repository.
-
Make the following changes : In lib/src/create_face_embeddings.py replace the data and pb file paths by your owns (you can also optionally turn on your GPU : with tf.Session(config=tf.ConfigProto(device_count={'GPU': 0})) as sess: ) In server/rest-server.py modify the paths
-
Create a dataset of faces for each person and arrange them in below order
root folder
│
└───Person 1
│ │───IMG1
│ │───IMG2
│ │ ....
└───Person 2
| │───IMG1
| │───IMG2
| | ....
- Align the faces using MTCNN or dllib. Please use the scripts available in lib/src/align. For this project i aligned faces using MTCNN.(Please have a look at aligning faces if you need any clarifications)
[Before alignment] [After alignment]
- Download pre-trained-weight ,extract and keep it in lib/src/ckpt folder (for detailed info about availabe weights: available-weights)
- Create face embeddings using pre-trained facenet model. Run the below scripts by changing the folder paths.(edit paths in lines)
python lib/src/create_face_embeddings.py
Once you run the script succesfully, a pickle file with name face_embeddings.pickle will be generated inside lib/src folder
- Start the server by running the command
python server/rest-server.py
access the UI using url https://127.0.0.1:5000. It will show a button with face recognition as label. Once you click on it, automatically your primary camera will get turned on and start recognizing the faces.
for more information, please go through my blog
NOTE: The faces are identified using retrievel method, instead if you have enough data, you can train a classifier on top of face embeddings (Train-a-classifier-on-own-images)
References:
- Deepface paper https://www.cs.toronto.edu/~ranzato/publications/taigman_cvpr14.pdf
- Facenet paper https://arxiv.org/pdf/1503.03832.pdf
- Pre-trained facenet model https://github.com/davidsandberg/facenet