jkjung-avt / tensorrt_demos

TensorRT MODNet, YOLOv4, YOLOv3, SSD, MTCNN, and GoogLeNet
https://jkjung-avt.github.io/
MIT License
1.74k stars 545 forks source link

Add LFFD int8 calibration #565

Closed dexception closed 2 years ago

dexception commented 2 years ago

You might be interested in the following repository for face detection.

https://github.com/YonghaoHe/LFFD-A-Light-and-Fast-Face-Detector-for-Edge-Devices/tree/master/face_detection

I am trying to use your int8 calibration code for the above repository and not able to get any results.

Steps:

  1. Run the https://github.com/YonghaoHe/LFFD-A-Light-and-Fast-Face-Detector-for-Edge-Devices/blob/master/face_detection/deploy_tensorrt/to_onnx.py
  2. Replaced code in 127-128 line with following code:
            logging.info('Create TensorRT builder.')
            builder = trt.Builder(TRT_LOGGER)
            builder.int8_mode = True
            net_h = 480
            net_w = 640
            model_name = "fd_int8"
            builder.int8_calibrator = YOLOEntropyCalibrator('calib_images', (net_h, net_w), 'calib_%s.bin' % model_name)

https://github.com/YonghaoHe/LFFD-A-Light-and-Fast-Face-Detector-for-Edge-Devices/blob/master/face_detection/deploy_tensorrt/predict_tensorrt.py

  1. But while inferencing I am not able to see any results. I am not sure if I need to change the code in int8 calibration or not but I think it should be common. Right ? Not sure.

I am currently using the following environment. Using ubuntu 18.04 Onnx 1.4.1 Cuda 10.1 TensorRT 6.0.1

jkjung-avt commented 2 years ago

Please review/revise the image preprocess function. You need to make sure it does "exactly how you'd preprocess the image before you feed it to the TensorRT engine".

https://github.com/jkjung-avt/tensorrt_demos/blob/a061e44a82e1ca097f57e5a32f20daf5bebe7ade/yolo/calibrator.py#L136

https://github.com/jkjung-avt/tensorrt_demos/blob/a061e44a82e1ca097f57e5a32f20daf5bebe7ade/yolo/calibrator.py#L67