Skip to content

A face recognition model build with an ensemble of popular pre-trained models like FaceNet and OpenFace, on training with a dataset of 31 celebrity images. Built an application which can recognise a new person based on stored embedding of him and relate his facial features to the 31 celebrities it was trained.

Notifications You must be signed in to change notification settings

uvaishnav/face-recognition-mele-assignment

Repository files navigation

Face Recognition Model Using TensorFlow

Introduction

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:

🛠️ Technology Stack

Technology Description
Python Python Programming Language
TensorFlow TensorFlow Deep Learning Framework
MTCNN MTCNN Face Detection
Facenet Facenet Pre-trained Face Recognition
OpenFace OpenFace Pre-trained Face Recognition
Matplotlib Matplotlib & Seaborn Data Visualization
NumPy NumPy & Pandas Data Manipulation
Scikit-learn Scikit-learn Model Evaluation

📊 Implementation Overview

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.
  • Reasoning: Transfer learning with Facenet and OpenFace leverages pre-trained models known for excellent face recognition performance, thus reducing training time and improving accuracy.

3. 📈 Model Evaluation

  • 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.

🎭 Face Recognition Web Application Overview

Initial Work

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.

Building the Application

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:

  1. 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
  1. 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

Features of the Application

  • 📥 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

🎥 Demo

My.Movie.3-720p30.mov

🖥️ Run Locally

Clone the project

  git clone https://github.com/uvaishnav/face-recognition-mele-assignment.git

Create a conda environment after opening the repository

  conda create -n faceenv python=3.11 -y
  conda activate faceenv

Install requirements

  pip install -r requirements.txt

Start the server

python app.py
Now,
open up you local host and port

Conclusion

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!

TensorFlow

About

A face recognition model build with an ensemble of popular pre-trained models like FaceNet and OpenFace, on training with a dataset of 31 celebrity images. Built an application which can recognise a new person based on stored embedding of him and relate his facial features to the 31 celebrities it was trained.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages