Skip to content

sainimohit23/FaceNet-Real-Time-face-recognition

Repository files navigation

FaceNet-with-TripletLoss

My implementation for face recognition using FaceNet model and Triplet Loss. I like to implement different deep learning models architectures. I also like to read about applications and implementations of deep learning models. I have typed this code in my free time as a self learning exercise. So, if you run into some performane issue, i am not an expert , i won't be able to help you. I also don't have hardware to extensively test a heavy model like FaceNet. So, hyperparameters are not tuned at all. Only thing I can assure you is that this implementation works.

Medium post

Dependencies

  • python 3.6
  • tensorflow v1.11
  • keras
  • openCV

Usage

  1. Create a dataset of faces for each person and arrange them in below order.
root folder 
│
└───Person 1
│   │───IMG1
│   │───IMG2
│   │   ....
└───Person 2
|   │───IMG1
|   │───IMG2
|   |   ....
  1. Use align_dataset_mtcnn.py to prepare our dataset for training. Run the following command:

python align_dataset_mtcnn.py ./YOUR_DIRECTIORY_CONTAINING_DATA ./cropped

example:

Screenshot_99

  1. Run train_triplet.py to train the model. Make changes (if you want) in parameters.py to adjust training parameters.

  2. Run webcamFaceRecoMulti.py to recognize faces in real time. Note- Our dataset must have some images for this script to work.

Known issues/limitations:

  • The dataset must contain the images of atleast two different people to train the model. You can define your own generator function to train it for single person
  • Generator function might be slow when dataset has images of fewer number of people.
  • Code needs some refactoring.

Note:

  • It is not state of the art technique. So, dont't expect much from it.

  • Model is trained using triplet loss. According to experiments it is recommended to chose positive, negative and anchor images carefully/manually for better results. Here I used a generator which selects images for positive, negative and anchor randomly (I'm Lazy af). To know more about this I recommend you to watch this video.

Refrences

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages