Here is a comprehensive README for the face recognition code:
This project implements a facial recognition system for identifying faces from a custom dataset. The system uses MTCNN for face detection, Facenet for facial feature extraction, SVM for classification, and PCA for dimensionality reduction and visualization.
The overall pipeline follows these key steps:
- Face Detection: MTCNN detects and extracts face regions from input images
- Feature Extraction: The detected face regions are passed through the Facenet model to generate 128-d facial embeddings
- Training: An SVM model is trained on the embeddings and labels from the training set
- Classification: For any new image, the face embedding is extracted and fed to the SVM model for prediction
- Visualization: PCA is used to reduce embeddings to 2d for visualization
Models:
- MTCNN: Face detector model
- Facenet: Inception ResNet V1 model pretrained on VGGFace2 dataset for facial feature extraction
- SVM: Support Vector Machine model for classification
Libraries:
- facenet-pytorch: Provides MTCNN and Facenet models
- sklearn: SVM, PCA, metrics
- Matplotlib: Visualization plots
Functions:
extract_features()
: Face detection and embedding extractiondataset_to_embeddings()
: Extract embeddings and labels for a datasettrain()
: Train classification SVM modelvisualize()
: Generate 2D visualization plots
Evaluation:
The model is evaluated using accuracy metric and classification report.
Usage:
Check the notebook for sample usage including training, evaluation and predictions.
Python 3.8+
See requirements.txt
file for all package dependencies.
Facenet PyTorch: https://github.com/timesler/facenet-pytorch
@Jigyansu Rout