duan8/retinaface
LiberiFatali 569cc4a438 Attach the decode kernel to the same CUDA stream
fix to load engine file in DeepStream 6.1.1
2022-10-08 21:41:35 +07:00
..
calibrator.cpp give retinaface TRT8 support (#698) 2021-08-31 19:05:43 +08:00
calibrator.h give retinaface TRT8 support (#698) 2021-08-31 19:05:43 +08:00
CMakeLists.txt Fix a bug(wrong CMakeLists syntax) (#377) 2021-01-28 12:58:42 +08:00
common.hpp retinaface int8 2020-11-06 23:41:52 +08:00
decode.cu Attach the decode kernel to the same CUDA stream 2022-10-08 21:41:35 +07:00
decode.h give retinaface TRT8 support (#698) 2021-08-31 19:05:43 +08:00
logging.h give retinaface TRT8 support (#698) 2021-08-31 19:05:43 +08:00
macros.h give retinaface TRT8 support (#698) 2021-08-31 19:05:43 +08:00
README.md update readme 2021-04-02 09:44:28 +08:00
retina_mnet.cpp Update retina_r50.cpp and retina_nmt.cpp (#546) 2021-05-16 11:31:33 +08:00
retina_r50.cpp Update retina_r50.cpp and retina_nmt.cpp (#546) 2021-05-16 11:31:33 +08:00
retinaface_trt.py Update retinaface_trt.py, preprocess_image code (#703) 2021-09-01 14:29:55 +08:00

RetinaFace

The pytorch implementation is biubug6/Pytorch_Retinaface, I forked it into wang-xinyu/Pytorch_Retinaface and add genwts.py

This branch is using TensorRT 7 API, branch trt4->retinaface is using TensorRT 4.

Config

  • Input shape INPUT_H, INPUT_W defined in decode.h
  • INT8/FP16/FP32 can be selected by the macro USE_FP16 or USE_INT8 or USE_FP32 in retina_r50.cpp
  • GPU id can be selected by the macro DEVICE in retina_r50.cpp
  • Batchsize can be selected by the macro BATCHSIZE in retina_r50.cpp

Run

The following described how to run retina_r50. While retina_mnet is nearly the same, just generate retinaface.wts with mobilenet0.25_Final.pth and run retina_mnet.

  1. generate retinaface.wts from pytorch implementation https://github.com/wang-xinyu/Pytorch_Retinaface
git clone https://github.com/wang-xinyu/Pytorch_Retinaface.git
// download its weights 'Resnet50_Final.pth', put it in Pytorch_Retinaface/weights
cd Pytorch_Retinaface
python detect.py --save_model
python genwts.py
// a file 'retinaface.wts' will be generated.
  1. put retinaface.wts into tensorrtx/retinaface, build and run
git clone https://github.com/wang-xinyu/tensorrtx.git
cd tensorrtx/retinaface
// put retinaface.wts here
mkdir build
cd build
cmake ..
make
sudo ./retina_r50 -s  // build and serialize model to file i.e. 'retina_r50.engine'
wget https://github.com/Tencent/FaceDetection-DSFD/raw/master/data/worlds-largest-selfie.jpg
sudo ./retina_r50 -d  // deserialize model file and run inference.
  1. check the images generated, as follows. 0_result.jpg

  2. we also provide a python wrapper

// install python-tensorrt, pycuda, etc.
// ensure the retina_r50.engine and libdecodeplugin.so have been built
python retinaface_trt.py

INT8 Quantization

  1. Prepare calibration images, you can randomly select 1000s images from your train set. For widerface, you can also download my calibration images widerface_calib from GoogleDrive or BaiduPan pwd: a9wh

  2. unzip it in retinaface/build

  3. set the macro USE_INT8 in retina_r50.cpp and make

  4. serialize the model and test

More Information

Check the readme in home page.