Skip to content

Training

Quang Thien Nguyen edited this page Feb 11, 2021 · 7 revisions

Training

This wiki page explains how to train Facesecure's model based on "FaceNet: A Unified Embedding for Face Recognition and Clustering".

Please refer to this page for the filestructure of the training data.

Running Training Loop

  1. The backend/face_recognition/train.py script will initiate the training. Following flags are available to setup the process:
--num-epochs: Number of epochs to train (default: 200)

--num-triplets: Number of triplets for training (default: 10000)

--batch-size: Batch size (default: 256)

--num-workers: Number of worker for DataLoader (default: 0)

--learning-rate: Learning rate (default: 0.05)

--margin: Margin for TripletLoss (default: 0.02)

--train-data-dir: Path to training data

--val-data-dir: Path to validation data

--val-labels-dir: Path to pairs.txt of validation data

--model-dir: Path where model will be saved

--optimizer: Optimizer Algorithm for learning (default: adam, can also choose adagrad)

--weight-decay: Decay learning rate (default: 1e-5)

--pretrained: Will load pretrained model, if set.

--load-checkpoint: Path to checkpoint

--num-workers: Number of workers for dataloader (default: amount of cpu core)
  1. Execute the script with desired parameters, e.g.:
$ cd backend
$ python face_recognition/train.py --num-epochs 2 --batch-size 256 --learning-rate 0.001 --train-data-dir <path to training data> --num-triplets 100000 --val-data-dir <path to validation data> --val-labels-dir <path to pairs.txt>
Clone this wiki locally