Skip to content

A simple face recognition implementation using a pre-trained, one-shot learning model - FaceNet. Classification on custom dataset by using the WebCam to perform live face recognition.

Notifications You must be signed in to change notification settings

akshayraghavan21/Face-Recognition-Using-Facenet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebCam Face Recognition using FaceNet

A simple face recognition implementation using a pre-trained, one-shot learning model - FaceNet. Classification on custom dataset by using the WebCam to perform live face recognition. The inspiration is from the task provided by Digiledge. The code is credited to David Sandberg for his facenet repository.

Steps to follow:

Clone the repository //Insert link of my repository//. Set Python path as mentioned here.

  1. Create a folder named ~/datasets and insert images into the folder in the following format.
root folder 
    │
    └───before
        │
        └───Person 1
        │   │───IMG1
        │   │───IMG2
        │   │   ....
        └───Person 2
        |   │───IMG1
        |   │───IMG2
        |   |   ....
    │
    └───after

Eg.

datasets
    │
    └───before
        │
        └───Alice
        │   │───Alice1.jpg
        │   │───Alice2.jpg
        │   │   ....
        └───Bob
        |   │───Bob1.jpg
        |   │───Bob2.jpg
        |   |   ....
    │
    └───after

These are the images that will be used to train the classifier and perform face recognition on the dataset by using WebCam.

  1. Align the faces using MTCNN or dllib.

To extract useful information from the images in terms of bounding boxes around the face, run the script align_dataset_mtcnn.py at lib/src/align/ (sample command is given in the script) to generate the aligned images from the ~/datasets/before/ folder.

Before alignment [After alignment]

  1. Download pre-trained-weight ,extract and keep it in lib/src/ckpt folder (for detailed info about availabe weights: available-weights)

  2. Classifier Training/Testing

4.1 Train a classifier: Train a Classifier on the aligned images using the script classifier.py at lib/src/ which fill create a classifier pickle file at lib/src/ckpt/ which can be used for detection faces using custom dataset. (Refer to the sample script in the classifier.py file)

4.2 Test the classifier: Once the training is done, use aligned images, which werent provided while training, to test the classifier. Steps: Store new custom aligned images in a new folder at ~/datasets/. This folder path is provided as an argument to the Classify command sample provided in the classifier.py file.

  1. WebCam Detection of face -

Run the script to start up your webcam and detect face.

  python lib/src/liveweb.py

sample result

alt text

Loss Function Used:

FaceNet model is a deep convolutional network that employs triplet loss function. Triplet loss function minimizes the distance between a positive and an anchor while maximizing the distance between the anchor and a negative.

Taken from the original paper

References:

About

A simple face recognition implementation using a pre-trained, one-shot learning model - FaceNet. Classification on custom dataset by using the WebCam to perform live face recognition.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published