Code Monkey home page Code Monkey logo

libfacedetection.train's Introduction

Training for libfacedetection in PyTorch

License

It is the training program for libfacedetection. The source code is based on FaceBoxes.PyTorch and ssd.pytorch.

Visualization of our network architecture: [netron].

Contents

Installation

  1. Install PyTorch >= v1.7.0 following official instruction.

  2. Clone this repository. We will call the cloned directory as $TRAIN_ROOT.

    git clone https://github.com/ShiqiYu/libfacedetection.train
  3. Install NVIDIA DALI following official instruction: https://docs.nvidia.com/deeplearning/dali/user-guide/docs/installation.html

  4. Install dependencies.

    pip install -r requirements.txt

Note: Codes are based on Python 3+.

Preparation

  1. Download the WIDER Face dataset and its evaluation tools.
  2. Extract zip files under $TRAIN_ROOT/data/widerface as follows:
    $ tree data/widerface
    data/widerface
    ├── wider_face_split
    ├── WIDER_test
    ├── WIDER_train
    ├── WIDER_val
    └── trainset.json           

NOTE:
We relabled the WIDER Face train set using RetinaFace. New labels are in $TRAIN_ROOT/data/widerface/trainset.json, which is the COCO_format annotations file used in DALI dataloader.

Training

python train.py -c ./config/yufacedet.yaml -t demo 

Detection

python detect.py -c ./config/yufacedet.yaml -m weights/yunet_final.pth --target filename.jpg 

Evaluation on WIDER Face

  1. Build NMS module.

    cd tools/widerface_eval
    python setup.py build_ext --inplace
  2. Perform evaluation. To reproduce the following performance, run on the default settings. Run python test.py --help for more options.

    python test.py -m weights/yunet_final.pth -c ./config/yufacedet.yaml

NOTE: We now use the Python version of eval_tools from here.

Performance on WIDER Face (Val): confidence_threshold=0.3, nms_threshold=0.45, in origin size:

AP_easy=0.882, AP_medium=0.871, AP_hard=0.767

Export CPP source code

The following bash code can export a CPP file for project libfacedetection

python exportcpp.py -c ./config/yufacedet.yaml -m weights/yunet_final.pth

Export to onnx model

Export to onnx model for libfacedetection/example/opencv_dnn.

python exportonnx.py -m weights/yunet_final.pth

Compare ONNX model with other works

Inference on exported ONNX models using ONNXRuntime:

python tools/compare_inference.py ./onnx/yunet_final_dynamic_simplify.onnx --mode AUTO --eval --score_thresh 0.3 --nms_thresh 0.45

Some similar approaches(e.g. SCRFD, Yolo5face, retinaface) to inference are also supported.

With Intel i7-12700K and input_size = origin size, score_thresh = 0.3, nms_thresh = 0.45, some results are list as follow:

Model AP_easy AP_medium AP_hard #Params Params Ratio MFlops Froward (ms)
SCRFD0.5(ICLR2022) 0.879 0.863 0.759 631410 7.43x 184 22.3
Retinaface0.5(CVPR2020) 0.899 0.866 0.660 426608 5.02X 245 13.9
YuNet(Ours) 0.885 0.877 0.762 85006 1.0x 136 10.6

The compared ONNX model is avaliable in https://share.weiyun.com/nEsVgJ2v Password:gydjjs

Citation

The loss used in training is EIoU, a novel extended IoU. More details can be found in:

@article{eiou,
 author={Peng, Hanyang and Yu, Shiqi},
 journal={IEEE Transactions on Image Processing}, 
 title={A Systematic IoU-Related Method: Beyond Simplified Regression for Better Localization}, 
 year={2021},
 volume={30},
 pages={5032-5044},
 doi={10.1109/TIP.2021.3077144}
 }

The paper can be open accessed at https://ieeexplore.ieee.org/document/9429909.

We also published a paper on face detection to evaluate different methods.

@article{facedetect-yu,
 author={Yuantao Feng and Shiqi Yu and Hanyang Peng and Yan-ran Li and Jianguo Zhang}
 title={Detect Faces Efficiently: A Survey and Evaluations},
 journal={IEEE Transactions on Biometrics, Behavior, and Identity Science},
 year={2021}
 }

The paper can be open accessed at https://ieeexplore.ieee.org/document/9580485

libfacedetection.train's People

Contributors

fengyuentau avatar shiqiyu avatar wwupup avatar cclauss avatar begentleman avatar eecn avatar qaz734913414 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.