FaceNet directly learns a mapping from face images to a compact Euclidean space where distances directly correspond to a measure of face similarity. The model does not use the traditional softmax method for classification learning, but extracts a layer as a feature, maps the face image to a coding method of Euclidean multidimensional space, and expresses the similarity of the face through the spatial distance. The smaller the distance between the same person and the greater the distance between different people. Finally, based on this code, various applications such as face recognition, face verification, and face grouping are performed.
Its main core is to propose an architecture for a convolutional neural network and use triplet loss as the loss function.
This solution includes FaceNet. Users can complete pre-processing, training, classification, instant image face recognition, etc. by clicking the mouse.
The entire process is:
1. Preparing pictures => pre-processing uses MTCNN to achieve face detection and alignment, cut out the face area (preprocess.py) => training (2_train_softmax.py or 2_train_tripletloss.py)
=> Use the model trained above 2_train_tripletloss.py (or directly use the supplied model) to calculate the Euclidean distance of the two images to determine whether the same person (3_compare.py)
=> Input a folder containing multiple face images and output the folder with the face classified (3_clustering.py)
2. Use the model trained by 2_train_tripletloss.py above (or directly use the supplied model) to calculate the eigenvectors of your own images and train those eigenvectors into an SVM classifier (4_classifier.py)
=> Enter a folder with multiple images, and the output shows that faces and names have been marked in the image (5_inference.py)
=> Use webcam to detect people in images (5_real_time_face_recognition.py)