ResNet-Pytorch-Face-Recognition
Using Pytorch to implement a ResNet50 for Cross-Age Face Recognition
Generally speaking, Pytorch is much more user-friendly than Tensorflow for academic purpose.
Prepare Dataset and Environment
Trainable ResNet50 using Python3.5 + Pytorch
DataSet: Cross-Age Celebrity Dataset(CACD)
By default, you should put all the CACD images under "./CACD2000/". If your dataset is in another place, add "--root-path your_path" when you run main.py.
You don't need to crop image into 2242243 size anymore, pytorchvision provide convenient "transforms" to do so.
Explanation of Each File
- main.py is just used to control parameters, it doesn't contains any useful details.
- ResNet.py & VGG.py are the cores of the project, they have the implementation of Networks.
- train.py contains the details of training process.
- data.py maintains a Class to generate CACD data class, which is very different with Tensorflow and quite useful.
- In /model/params.pkl, we give a pretrained model learnt through default setting (change number of epoch to 30)
Training Part
- Run main.py directly, there are some options and parameters you can modify, pleace check the details of main.py.
- About "--model", there are 3 options: resnet50, resnet101, vgg16. Although I also implemented VGG class, but I didn't check whether it's working or not, so the default option is resnet50.
- Labels and Image names are loaded from "./data/label.npy" and "./data/name.npy".
Pytorch provide a very useful approach to create datasets. Please check data.py - Label is range from [1, LABELSNUM], to make correct classification, we should change it to [0, LABELNUM-1]
- If you want to load a existing model, you should run the following "python main.py --model-path your_path --pretrained 1".
Evaluation
Since I just want to get used to Pytorch. I didn't prepare a evaluation method, you can make your own if you like.