Rank Consistent Ordinal Regression for Neural Networks with Application to Age Estimation
This repository contains the PyTorch model code for the paper
This GitHub repository contains the code files and training logs used in the paper. If you are primarily interested in using CORAL, a PyTorch library with Tutorials can be found here:
Note that the model code across datasets is identical for the different datasets, however, we hard coded the file paths to the datasets at the top of the file and using dataloaders specific to the corresponding dataset organization. You likely need to change the file paths in the scripts depending on where you save the image datasets and label files if you wish to run the code.
All code was run on PyTorch 1.5 and Python 3.7, and we do not guarantee upward and downward compatibility to other PyTorch and Python versions.
The model code can be found in the
[./model-code](./model-code)subdirectory, and the code files are labeled using the scheme
afad), MORPH-2 (
morph), or CACD (
coral), ordinal regression as in Niu et al. (
ordinal), or cross-entropy (
The following code trains
python afad-coral.py --seed 1 --cuda 0 --outpath afad-model1
--seed: Integer for the random seed; used for training set shuffling and the model weight initialization (note that CUDA convolutions are not fully deterministic).
--cuda: The CUDA device number of the GPU to be used for training (
--cuda 0refers to the 1st GPU).
--outpath: Path for saving the training log (
training.log) and the parameters of the trained model (
Here is an overview of the differences between a regular CNN and a CORAL-CNN:
We share all training logs in this GitHub repository under the ./experiment-logs subdirectory. Due to the large file-size (85 Mb per model), we could not share the trained models on GitHub; however, all trained models can be downloaded from Google Drive via the following link: https://drive.google.com/drive/folders/168ijUQyvGLhHoQUQMlFS2fVt2p5ZV2bD?usp=sharing.
The image files of the face image datasets are available from the following websites:
Data preprocessing code
We provide the dataset preprocessing code that we used to prepare the CACD and MORPH-2 datasets as described in the paper. The code is located in the
[./datasets/image-preprocessing-code](./datasets/image-preprocessing-code)subdirectory. AFAD did not need further preprocessing.
Labels and train/test splits
We provide the age labels (obtained from the orginal dataset resources) and train/test splits we used in CSV format located in the
We share the pre-trained models from the paper that can be used to make predictions on AFAD, MORPH-2, or CACD images. Please see the README in the single-image-prediction__w-pretrained-models subdirectory for details.
Our models were originally implemented in PyTorch 1.5. We provide a recipe for porting the code is provided at coral-implementation-recipe.ipynb. Also see the the file-diff comparing CORAL with regular CNN.
A Keras port of this code was recently developed and made available at https://github.com/ck37/coral-ordinal.