This code is for face recognition system that allows to add new faces to face base in real time.
This system consists of 3 major modules:
- Face Detector
- Face Tracker
- Face Recognizer
For each module could be extended by adding new better algorithm.
For face detection two models are provided: SSD (with ResNet as backbone) and MTCNN.
For face tracking centroid tracker was used. Future updates: add kalman tracker
Face recognition module utilizes Facenet-based model with embedding size 512.
Facenet model was quantize to make it run on smaller devices like phone. On top of facent simple NN (embedding model) was trained on known images using triplet loss for better embeddings. For face classification KNN or SVM are used.
Module allows to register new face if model understands it doesn't know it. It will ask to enter a new name and will retrain model to classify new person
-
You need to train embedding model and classifier before starting face recognition: run
python train_facenet.py --data_path {your_path to folder} --tflite {it to use tflite facenet} --classifier_type{'KNN'/'SVC'}see all parameters in train_facenet.py -
Run
python detect.pyto start tracking and recognizing faces from webcam.Arguments
- --mode [0, 1, 2] // mode of detection 0 - detect&track faces, 1 - same as 2 + save faces,' ' 2 - detect&track®ister'
- --tracker ['centroid'] // tracking algorithm
- --detector ['ssd', 'mtcnn'] // face detection model (TODO MTCNN)
- --recognizer ['facenet'] // which model to use to recognize faces from base
- --detection_rate // frame period between running face detection for more accurate face tracking
- --face_size. // size of face crop to store in .jpg file
- --detecttion_conf // minimum probability (from face detector) to consider object a face
- --classifier_type [KNN, SVC] // type of classifier to use for face recognition
-
Florian Schroff, Dmitry Kalenichenko, James Philbin (2015): FaceNet: A Unified Embedding for Face Recognition and Clustering
-
Facenet quantization: Facenet on mobile
-
Triplet loss: Tensorflow triplet loss
-
Kaipeng Zhang, Zhanpeng Zhang, Zhifeng Li (2016): Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks

