This repository shows how to train ResNet models in PyTorch on publicly available face recognition datasets.
Setup
Install Anaconda if not already installed in the system.
Create an Anaconda environment: conda create -n resnet-face python=2.7 and activate it: source activate resnet-face.
Install PyTorch and TorchVision inside the Anaconda environment. First add a channel to conda: conda config --add channels soumith. Then install: conda install pytorch torchvision cuda80 -c soumith.
Install the dependencies using conda: conda install scipy Pillow tqdm scikit-learn scikit-image numpy matplotlib ipython pyyaml.
Notes:
Multiple GPUs (we used 5 GeForce GTX 1080Ti in parallel) recommended for the training to finish in reasonable time.
Demo to train a ResNet-50 model on the UMDFaces dataset.
Dataset preparation
Download the UMDFaces dataset (the 3 batches of still images), which contains 367,888 face annotations for 8,277 subjects, split into 3 batches.
The images need to be cropped into 'train' and 'val' folders. Since the UMDFaces dataset does not specify training and validation sets, by default we select two images from every subject for validation.
The cropping code is in the Python script umd-face/run_crop_face.py. It takes the following command-line arguments:
--dataset_path (-d)
--output_path (-o)
--batch (-b)
The following shell command does the cropping for each batch in parallel, using default dataset_path and output_path. for i in {0..2}; python umd-face/run_crop_face -b $i &; done.