Skip to content
Reimplement RetinaFace with Pytorch
Python
Branch: master
Clone or download
yangziyang
yangziyang bug fix
Latest commit 7ad1713 Aug 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets modify Aug 16, 2019
README.md add readme Aug 6, 2019
anchors.py change the anchor size Aug 6, 2019
dataloader.py bug fix Aug 8, 2019
detect.py add image save Aug 6, 2019
eval_widerface.py nms and iou compute with torchvison Aug 6, 2019
losses.py bug fix Aug 17, 2019
model.py change losshead Aug 6, 2019
requirements.txt add requirements.txt Aug 6, 2019
torchvision_model.py add model implemented by torchvion Aug 6, 2019
train.py fix tensorboard writer Aug 15, 2019
utils.py add scale weights of offsets Aug 15, 2019

README.md

RetinaFace_Pytorch

Reimplement RetinaFace with Pytorch

Installation

Clone and install requirements
$ git clone https://github.com/supernotman/RetinaFace_Pytorch.git
$ cd RetinaFace_Pytorch/
$ sudo pip install -r requirements.txt

Pytorch version 1.1.0+ and torchvision 0.3.0+ are needed.

Data
  1. Download widerface dataset

  2. Download annotations (face bounding boxes & five facial landmarks) from baidu cloud or dropbox

  3. Organise the dataset directory as follows:

  widerface/
    train/
      images/
      label.txt
    val/
      images/
      label.txt
    test/
      images/
      label.txt

Train

$ train.py [-h] [data_path DATA_PATH] [--batch BATCH]
                [--epochs EPOCHS]
                [--shuffle SHUFFLE] [img_size IMG_SIZE]
                [--verbose VERBOSE] [--save_step SAVE_STEP]
                [--eval_step EVAL_STEP]
                [--save_path SAVE_PATH]
                [--depth DEPTH]

Example

For multi-gpus training, run:

$ CUDA_VISIBLE_DEVICES=0,1,2,3,4,5 python train.py --data_path /widerface --batch 32 --save_path ./out

Training log

---- [Epoch 39/200, Batch 400/403] ----
+----------------+-----------------------+
| loss name      | value                 |
+----------------+-----------------------+
| total_loss     | 0.09969855844974518   |
| classification | 0.09288528561592102   |
| bbox           | 0.0034053439740091562 |
| landmarks      | 0.003407923271879554  |
+----------------+-----------------------+
-------- RetinaFace Pytorch --------
Evaluating epoch 39
Recall: 0.7432201780921814
Precision: 0.906913273261629

Detect

$ python detect.py --model_path out/model_epoch_200.pt --image_path 4.jpg

Todo:

  • Wider Face mAP calculation
  • Deformable Convolution
  • More models support
  • Random crop and color distortion
  • Graph Convolution
  • Bug fix
You can’t perform that action at this time.