andyz245 / DAN

Official implementation of DAN

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Distract Your Attention: Multi-head Cross Attention Network for Facial Expression Recognition

overview

A PyTorch implementation of the DAN, pre-trained models are available for deployment.

Preparation

  • Download pre-trained model of MSCeleb and move the file to ./models
  • Download RAF-DB dataset and extract the raf-basic dir to ./datasets
  • Download AffectNet dataset and extract the AffectNet dir to ./datasets
  • Run python ./utils/convert_affectnet.py to store a split version of AffectNet dataset.

Training

We provide the training code for AffectNet and RAF-DB.

For AffectNet-8 dataset, run:

CUDA_VISIBLE_DEVICES=0 python affectnet.py --epochs 10 --num_class 8

For AffectNet-7 dataset, run:

CUDA_VISIBLE_DEVICES=0 python affectnet.py --epochs 10 --num_class 7

For RAF-DB dataset, run:

CUDA_VISIBLE_DEVICES=0 python rafdb.py

Models

Pre-trained models can be downloaded for evaluation as following:

task epochs accuracy link
AffectNet-8 5 62.09 download
AffectNet-7 6 65.69 download
RAF-DB 21 89.70 download

Also, you can find these files on Baidu Driver with key 0000

Grad CAM++ Reproduction

Our experiment of grad cam++ was based on the package grad-cam 1.3.1, which could be pulled by:

pip install grad-cam==1.3.1

Then, run the following code to dump the visual results. (Need to replace several variables manually.)

python run_grad_cam.py

Deployment

There is a simple demo to invoke DAN model for a emotion inference:

CUDA_VISIBLE_DEVICES=0 python demo.py --image test_image_path

About

Official implementation of DAN

License:MIT License


Languages

Language:Python 100.0%