Facial recognition with machine learning - Degree Final Project
These projecte uses machine learning to solve facial recognition in real time. Models are trained using the FaceNet CNN architecture and the triplet loss function. Input images needs to be 224 x 244 pixels size and the resulting output embeddings are 128. To extract and align faces from original images MTCNN is used. A SVC is used to classify embeddings for each class.
Multiple programs are served to train, validate, and use the trained model. Note that all these programs are optimized to validate a train a model on 9 users.
ALIGN IMAGES for N in {1..4}; do python align_dataset_mtcnn.py /home/Desktop/project/datasets/wild /home/Desktop/project/datasets/wildaligned --image_size 224 --margin 44 --gpu_memory_fraction 0.25 & done
CSV GENERATION (used to load faces) python write_csv_for_making_dataset.py --root-dir= /home/Desktop/project/datasets/wildalignedtrain --final-file= /home/Desktop/project/datasets/wildaligned/oficinaaligneddatasettrain.csv
TRIPLET LOSS TRAINING python train.py --train-root-dir /home/Desktop/project/datasets/wildalignedtrain --train-csv-name /home/Desktop/project/datasets/wildalignedtrain.csv --valid-root-dir /home/Desktop/project/datasets/wildalignedval --valid-csv-name /home/Desktop/project/datasets/wildalignedval.csv --num-epochs 400 --pretrain --margin 0.5
TRAINING PLOT python plottrainresults.py --root-dir /home/Desktop/project/log/modeloriginal
EMBEDDINGS DISTANCES PLOT python distancies.py --test-root-dir /home/Desktop/project/datasets/wildalignedtrain --test-csv-name /home/Desktop/project/datasets/wildalignedtest.csv --pretrain
EMBEDDINGS VALUES PLOT python embeddingsPlot.py --pretrain --path-dataset /home/Desktop/project/datasets/wildalignedtest
EUCLIDIAN THRESHOLD TEST python thresholdtest.py --test-root-dir /home/Desktop/project/datasets/wildalignedtest --test-csv-name /home/Desktop/project/datasets/wildalignedtest.csv --pretrain --num-classif 1000
COSINE SIMILARITY TEST python cosinetest.py --test-root-dir /home/Desktop/project/datasets/wildalignedtest --test-csv-name /home/Desktop/project/datasets/wildalignedtest.csv --pretrain --num-classif 1000
CLASSIFICATION PLOT python classify.py --test-root-dir /home/Desktop/project/datasets/wildalignedtest --test-csv-name /home/Desktop/project/datasets/wildalignedtest.csv --use-euclidian --threshold 9.0
CONFUSION MATRIX (usine minium embeddings, mean embedding, or SVC) python modelAccuracy.py --path-dataset /home/Desktop/project/datasets/wildalignedtrain --path-dataset-testing /home/Desktop/project/datasets/wildalignedtest --use-euclidian --euclidianThresh 9.0
REAL TIME RECOGNITION python realTimeRecognition.py --pretrain --load-last './log/modelx/last_checkpoint.pth' --path-dataset /home/Desktop/project/datasets/wildalignedtrain --use-euclidian --euclidianThresh 8.0