This project aims to develop a face recognition model capable of predicting the identity of a person based on an input image. Utilizing advanced techniques like transfer learning with pre-trained models, we ensure high accuracy and robust performance. The project is implemented using TensorFlow and leverages state-of-the-art models such as Facenet and OpenFace.
Here's the revised table with icons included in the Technology section:
1. 📄 Data Preparation view notebook
- Libraries: MTCNN, PIL, Pandas, NumPy
- Steps:
- Load and inspect the dataset.
- Use MTCNN to detect and extract faces from images.
- Split the dataset into training, validation, and test sets.
- Address class imbalance through data augmentation.
- Reasoning: MTCNN is chosen for its accuracy and reliability in face detection, ensuring high-quality face extraction for subsequent recognition tasks.
2. 🤖⚙️ Model Training view notebook
- Libraries: TensorFlow, Keras, DeepFace
- Steps:
- Load and preprocess images using
ImageDataGenerator
. - Utilize transfer learning models Facenet and OpenFace for feature extraction.
- Ensemble these models using stacking by adding a meta-learner on top of the predictions of these two models.
- This will learn the optimal way to combine the predictions from FaceNet and OpenFace Models.
- Train the model with early stopping, l2 regularization, Dropout to prevent overfitting.
- Load and preprocess images using
- Reasoning: Transfer learning with Facenet and OpenFace leverages pre-trained models known for excellent face recognition performance, thus reducing training time and improving accuracy.
- Libraries: Scikit-learn, Matplotlib, Seaborn
- Steps:
- Evaluate the model on the test set.
- Generate and visualize the confusion matrix.
- Produce a classification report detailing precision, recall, and F1-score.
- Reasoning: Using comprehensive evaluation metrics and visualizations helps in understanding the model's performance and areas of improvement.
As discussed in the Implementation Overview, we have developed a face recognition model by leveraging transfer learning and ensemble techniques using state-of-the-art pretrained models like FaceNet and OpenFace. This model is trained to identify 31 different celebrities.
We have a meta-learner that can take features from FaceNet and OpenFace to effectively identify celebrities. To use it for an application, we need to design a clear pipeline that:
- Predicts Celebrity Identity:
- Takes an input image
- Extracts features
- Returns predictions
Our application must also facilitate adding an image of a new person for future recognition. The pipeline should: 2. Store Embeddings for New Users:
- Take an input image
- Extract features
- Store embeddings
- Recognize Persons Based on Stored Embeddings:
- Take an input image
- Extract features
- Recognize the person based on stored embeddings
We have implemented a FaceRecognizer
class to handle all these tasks. 🧩 View Code
- 📥 Upload Images of New Users: Store their embeddings for future recognition.
- 🔍 Recognize Persons: Identify persons based on stored embeddings.
- 🌟 User celebrity Match: Our meta-learner, trained to classify given images among 31 celebrities, can predict the celebrity that the user's facial features most closely resemble. This is a fun feature to enhance user interaction with the application.
To handle backend routes, we have used the Flask framework. 🧩 View Code
My.Movie.3-720p30.mov
git clone https://github.com/uvaishnav/face-recognition-mele-assignment.git
conda create -n faceenv python=3.11 -y
conda activate faceenv
pip install -r requirements.txt
python app.py
open up you local host and port
This project demonstrates the effectiveness of using transfer learning for face recognition tasks. The use of advanced pre-trained models and robust data handling techniques ensures high accuracy and reliable performance.
Feel free to contribute or raise issues if you encounter any problems or have suggestions for improvements. Happy coding!