This is a repository for Face_Recognition using FaceNet Inception Resnet (V1) model in pytorch and using state of the art Face Detection model called Retina Faces
Started with Simple Face Recognition model to understand.
FaceNet: A Unified Embedding for Face Recognition and Clustering: link
RetinaFace: Single-stage Dense Face Localisation in the Wild : link
Github Repositorys
FaceNet Implementation : link
FaceNet PyTorch Implementation : link
RetinaFace PyTorch Implementation : link
We are stating with pre-trained FaceNet model implemented in PyTorch link
From this repo, we download pre-trained weights and models.
ModelName : VGGFace2 link
Weights : link
Face Recognition there are mainly three challenges.
- Detecting Faces
- Get Embeddings for faces
- Train model Clustering/Classification/Similarly to recognize the Face
1. Detecting Faces:
The first main challenge is Detecting Faces from a given image, there are many models to detect faces in an image
- The first main challenge is Detecting Faces from a given image.
- There are so many models to detect faces in this link
- We are using RetinaFace (sota) Face Detection model
2. Get Embeddings for faces
The second challenge is getting embedding for the detected faces, we are using FaceNet Model for getting Embeddings for faces.
- Trine a model using FaceNet architecture / Download pre-train model and train.
- FaceNet Implementation :link
- Pretrained Model :link
- Pretrainde Weights :link
3. Train model Clustering/Classification/Similarly to recognize the Face
There are three many ways to train a model to recognize the face
- Using Clustering
- Using Classification
- Using Similarity Matrix
We are build simple model form this [link](https://www.pyimagesearch.com/2018/09/24/opencv-face-recognition/)
- For more detailed understanding and code : simple_EDA.ipynb
- TSNE Visulization for Embeddings
Observe TSNE Visulization of 512-d Embeddings those are well clustered
- Distance (Best threshold for the verification
Using this Distance threshold we can easily desided threshold to Recognize faces
Observe Distance threshold is 0.74 and it gives 0.98 Accuracy, to recognize faces using simple Euclident distance
- Distance distributions of positive and negative pairs
Observe distributions of positive and negative pairs, almost well separated using threshold 0.74 wich gives high Accuracy
Run this files
1. Extract Embeddings: $python3 Simple_extractEmbeddings.py
2. Train Model: $python3 Simple_trainModel.py
3. Recognize Face: $python3 Simple_recognize.py --image kohili-sachin-dhoni.jpg
Input Image | Output Image |
- For accurate face detection, we are using Retina Face model to detect faces.
- Retina Faces is state of the art model to detect faces
- For more detailed understanding and code : retinaface.ipynb
Face Detection Outputs: