Face Attention Network

Pytorch implementation of face attention network as described in Face Attention Network: An Effective Face Detector for the Occluded Faces. The baseline is RetinaNet followed by this repo.

Requirements

  • Python3
  • Pytorch0.4
  • torchvision
  • tensorboardX

Installation

Install packages.

sudo apt-get install tk-dev python-tk

pip install cffi

pip install cython

pip install pandas

pip install tensorboardX

Build NMS.

cd Face_Attention_Network/lib
sh build.sh

Create folders.

cd Face_Attention_Network/
mkdir ckpt mAP_txt summary weight

Datasets

You should prepare three CSV or TXT files including train annotations file, valid annotations file and label encoding file.

Annotations format

Two examples are as follows:

$image_path/img_1.jpg x1 y1 x2 y2 label
$image_path/img_2.jpg . . . . .

Images with more than one bounding box should use one row per box. When an image does not contain any bounding box, we use ' ' separated with '.'.

Label encoding file

A TXT file is needed to map label to ID. Each line means one label name and its ID. One example is as follows:

face 0

Pretrained Model

We use resnet18, 34, 50, 101, 152 as the backbone. You should download them and put them to '/weight'.

Training

python train.py --csv_train <$path/train.txt> --csv_val <$path/val.txt> --csv_classes <$path/classes.txt> --depth <50> --pretrained resnet50-19c8e357.pth --model_name <model name to save>

Visualization Result

Detection result

2
Attention map at different level (P3~P7)

3

GitHub