Metric Learning TF 2.0+Keras Algorithm Implementations for Facial Recognition
- Python 3.6+
- pip install -r requirements.txt
- If GPU is available, pip install tensorflow-gpu==2.0.0 (highly recommended)
These steps will download the VGGFace2 dataset (caution: ~40GB of disk space is required)
- Create an account at http://zeus.robots.ox.ac.uk/vgg_face2/login/
- Run the dataset download scripts (metric_learning/utils/vggface2_train_download.py and metric_learning/utils/vggface2_test_download.py)
- Unzip the resutling "vggface2_train.tar.gz" and "vggface2_test.tar.gz" files into the metric_learning/data directory
- Run python utils/create_dataset.py in order to create "vggface2_train_dataset" and "vggface2_test_dataset" directories of preprocessed images
These are the steps to pretrain a softmax loss-based model on the preprocessed "train_dataset"
- cd metric_learning
- python pretrain_softmax_model.py
Finetune softmax model using metric learning on vggface2_test_dataset (preprocessed VGG2Face test set):
These are the steps to finetune a pretrained model using a metric learning and the preprocessed "test_dataset"
- cd metric_learning
- python finetune_softmax_model.py -m ["softmax", "contrastive", "triplet", "lmcl", "aaml"]