Skip to content

Face matching using deep learning (CNN embedding + triplet loss)

License

Notifications You must be signed in to change notification settings

dali92002/FaceMatching

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FaceMatching

Face matching using deep learning (CNN embedding + triplet loss)

Download Code

clone the repository:

git clone https://github.com/dali92002/FaceMatching
cd FaceMatching

Requirements

  • install requirements.txt

Prepare your Data

/lfw-deepfunneled
    ├── train
    └── test

Designed Model

The model was designed to embedd the images into a vector of 128 D and train it to make the images of the same person as close as possible and the images of different persons as far as possible using the triplet loss. This is similar to the FaceNet paper. You can check it in the file model/FaceMatch.py ..

alt text

Train

To train the model, use the following command

python main.py --batch_size 16 --path_train_set ./lfw-deepfunneled/train --path_test_set ./lfw-deepfunneled/test

Here I specified the batch_size to be 16 and I specified the paths for my training and testing data.

alt text

Test

After training, you can test the model on a pair of images (to decide whether they belong to the same person or no) you can use the folowing comand. You should simply specify the paths of the images to compare.

python test.py --path_img1 ./test/Anne_McLellan/Anne_McLellan_0001.jpg --path_img2 ./lfw-deepfunneled/test/Anne_McLellan/Anne_McLellan_0002.jpg

in testing we use the model to get the embeddings of the images (each images is mapped to a vector), then we compute an euclidian distance between the two vectors and decide basing on this distance of they are from the same person or no. I used a threshold of 1.1 (same as facenet) to make the decision of same/different.

Some Results

Image 1 Image 2 Decision Distance
1 1 Same 0.66
1 1 Different 2.81

Authors