Home

Awesome

pl_gaze_estimation

MIT License GitHub stars

Training code for gaze estimation models using MPIIGaze, MPIIFaceGaze, and ETH-XGaze.

https://user-images.githubusercontent.com/25161192/143683988-06ab6495-ae97-4201-b3f1-39dacf4bc69c.mp4

A demo is available in this repo.

Installation

pip install -r requirements.txt

For docker environment, see here.

Usage

The basic usage is as follows:

python train.py --configs /path/to/your/config.yaml

Multiple config files can be specified to set new variables or overwrite previously defined values. You can also overwrite previously defined values by listing the key/value pairs after the --options flags.

usage: train.py [-h] --configs [CONFIGS ...] [--options ...]

optional arguments:
  -h, --help            show this help message and exit
  --configs [CONFIGS ...]
                        Paths to config files.
  --options ...         Variables to overwrite. (optional)

MPIIGaze

test_id=0
python train.py --configs configs/examples/mpiigaze_lenet.yaml \
                --options EXPERIMENT.TEST_ID ${test_id} \
                          EXPERIMENT.OUTPUT_DIR exp0000/$(printf %02d ${test_id})

You need to download and preprocess the dataset before training by running the following commands:

bash scripts/download_mpiigaze_dataset.sh
python scripts/preprocess_mpiigaze.py --dataset datasets/MPIIGaze -o datasets/

(Additional packages are required to preprocess the dataset. See the code.)

MPIIFaceGaze

test_id=0
python train.py --configs configs/examples/mpiifacegaze.yaml \
                --options SCHEDULER.WARMUP.EPOCHS 3 \
                          EXPERIMENT.TEST_ID ${test_id} \
                          EXPERIMENT.OUTPUT_DIR exp0000/$(printf %02d ${test_id})

You need to download and preprocess the dataset before training by running the following commands:

bash scripts/download_mpiifacegaze_dataset.sh
python scripts/preprocess_mpiifacegaze.py --dataset datasets/MPIIFaceGaze_normalized -o datasets/

(Additional packages are required to preprocess the dataset. See the code.)

ETH-XGaze

python train.py \
    --config configs/examples/eth_xgaze.yaml \
    --options \
        VAL.VAL_INDICES "[1, 23, 24, 35, 38, 46, 58, 63, 70, 78]" \
        SCHEDULER.EPOCHS 15 \
        SCHEDULER.MULTISTEP.MILESTONES "[10, 13, 14]" \
        DATASET.TRANSFORM.TRAIN.HORIZONTAL_FLIP true \
        EXPERIMENT.OUTPUT_DIR exp0000

Docker Environment

docker-compose 1.29.2 is required.

Build

docker-compose build train

Train

docker-compose run --rm -u $(id -u):$(id -g) -v /path/to/datasets:/datasets train python train.py --configs /path/to/your/config.yaml

Results on ETH-XGaze dataset

All the results in the table below are of a single run. In these experiments, the data of subjects with id 1, 23, 24, 35, 38, 46, 58, 63, 70, and 78 were used as the validation data. The models were trained for 15 epochs with a multi-step learning rate schedule. The learning rate was multiplied by 0.1 at epochs 10, 13, and 14.

ModelhflipGPUprecisionbatch sizeoptimizerlrweight decaytraining timeval angle errorval loss
EfficientNet-lite0yesV1003264Adam0.000104h42m5.3300.06970
EfficientNet-b0yesV1003264Adam0.000105h58m5.1390.06672
ResNet18yesV1003264Adam0.000104h04m4.8780.06427
ResNet50yesV1003264Adam0.000108h42m4.7200.06087
HRNet-18yesV1003264Adam0.0001021h56m4.6570.05937
ResNeSt26dyesV1003264Adam0.000108h02m4.4090.05678
RegNetY160yesV1003264Adam0.000101d05h30m4.3770.05638
Swin-SyesV1003264Adam0.000101d00h08m4.3180.05629
HRNet-64yesV100x81664AdamW0.00080.053h11m4.3020.05523
ResNeSt269eyesV100x81656AdamW0.00080.055h31m4.0450.05200

Related repos

References