This repository contains code to perform face recognition using deep learning with the Labeled Faces in the Wild dataset and MobileNetV2 architecture. It includes a Colab notebook for training the model and a Python script for testing the model with a webcam.
The project aims to demonstrate face recognition using deep learning techniques. The MobileNetV2 architecture is used for feature extraction, and the model is trained on the Labeled Faces in the Wild dataset. The trained model can then be used to predict the identity of faces captured from a webcam.
-
Face_Recognition_MobileNetV2.ipynb: A Jupyter Notebook hosted on Google Colab for training the face recognition model using the MobileNetV2 architecture. The notebook covers dataset loading, model building, training, evaluation, and visualization of results. -
Face_Recognition_Webcam.py: A Python script that uses the trained model to perform real-time face recognition using a webcam. Detected faces are labeled with predicted identities and confidence scores.
- Open the
Face_Recognition_MobileNetV2.ipynbnotebook in Google Colab. - Run the notebook cells sequentially to train the face recognition model.
- The notebook will provide training accuracy, loss, and a confusion matrix for evaluation.
- Trained weights will be saved as
weights.h5.
- Ensure you have the required packages installed by running
pip install opencv-python keras scikit-learn imbalanced-learnin your environment. - Save the
Face_Recognition_Webcam.pyscript in your local directory. - Download the trained
weights.h5file from the Colab notebook and place it in the same directory. - Run the script using
python Face_Recognition_Webcam.py. - The webcam feed will display with predicted identities and confidence scores for detected faces.
The Colab notebook provides training history graphs, a confusion matrix, and a classification report for evaluation. Here are some key metrics from the training:
- Test Loss: 0.2032
- Test Accuracy: 0.9504
A normalized confusion matrix and a classification report with precision, recall, and F1-score for each class are also included.
The code in this repository is based on the Labeled Faces in the Wild dataset and MobileNetV2 architecture. The implementation leverages the capabilities of Keras, OpenCV, and scikit-learn.
This project is intended for educational purposes and demonstrates the use of deep learning for face recognition. It's important to respect privacy and ethical considerations when applying face recognition technology.