Yolov3/Yolov4
  • 09 Nov 2023
  • 1 Minute to read
  • Contributors
  • Dark
    Light

Yolov3/Yolov4

  • Dark
    Light

Article Summary

NetworkTensorRTOpenVINOOnnxRuntimeTranslator PluginMinimum required EVAReference link

Yolov3

Tested 

Tested 

Tested 

adtrans_yolo

2.0+

AlexeyAB/darknet

yolov3_onnx

TensorRT convert :

Original model : https://github.com/AlexeyAB/darknet

Convert Darknet model to ONNX format

https://github.com/jkjung-avt/tensorrt_demos/tree/c6afc40082da72397b2b0ad91eb6f32acf3b731d#yolov3

  • FP32 batchsize =1 

        trtexec --onnx=yolov3.onnx --buildOnly --saveEngine=YOUR_MODEL_NAME.engine

  • FP16 batchsize =1 

        trtexec --onnx=yolov3.onnx --buildOnly --saveEngine=YOUR_MODEL_NAME.engine --fp16

OpenVINO convert :

https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_prepare_model_convert_model_tf_specific_Convert_YOLO_From_Tensorflow.html

Note : YOLO family models have different input dimensions like 288 ( 32*9 ), 416 ( 32*13 ), 608 ( 32*,19). When convert, please pay attention to which input dimension of your model

NetworkTensorRTOpenVINOOnnxRuntimeTranslator PluginMinimum required EVAReference link

Yolov4

Tested 

Tested 

Tested 

adtrans_yolo

3.5.3+

AlexeyAB/darknet

yolov4_onnx

TensorRT convert :

Original model : https://github.com/AlexeyAB/darknet

Convert Darknet model to ONNX format

https://github.com/jkjung-avt/tensorrt_demos/tree/c6afc40082da72397b2b0ad91eb6f32acf3b731d#yolov4

  • FP32 batchsize =1 

        trtexec --onnx=yolov4.onnx --buildOnly --saveEngine=YOUR_MODEL_NAME.engine 

  • FP16 batchsize =1 

        trtexec --onnx=yolov4.onnx --buildOnly --saveEngine=YOUR_MODEL_NAME.engine --fp16

OpenVINO convert :

https://docs.openvino.ai/2021.2/omz_models_public_yolo_v4_tf_yolo_v4_tf.html

Note : YOLO family models have different input dimensions like 288 ( 32*9 ), 416 ( 32*13 ), 608 ( 32*,19). When convert, please pay attention to which input dimension of your model

Sample command line launch for TensorRT :

gst-launch-1.0 filesrc location=street.mp4 ! decodebin ! videoconvert ! adrt model=yolov3.engine scale=0.0039 rgbconv=True mean="0 0 0" ! adtrans_yolo blob-size=13,26,52 label="files/yolo.txt" input-height=416 input-width=416 mask="(6,7,8),(3,4,5),(0,1,2)" ! admetadrawer ! videoconvert ! ximagesink

Explanation of some plugins parameters :

adrt model=yolov3.engine scale=0.0039 rgbconv=True mean="0 0 0"
  • model=yolov3.engine : Path to the location of the model used by plugin to inference
  • scale=0.0039 : Scale to be multiply with pixel RGB values to normalize pixel values to desired range. 0.0039 mean convert the input from range of (0 ~ 255) to (0 ~ 1)
  • rgbconv=True : Convert the input image to RGB format from default BGR if set to True. False keep it as BGR
  • mean="0 0 0" : Mean value ( Average over sum ) of all pixel value in RGB or BGR order, to be subtracted to input image corresponding RBG/BGR channel. In this example, "0 0 0" means input image pixel value is not changed
adtrans_yolo blob-size=13,26,52 label="files/yolo.txt" input-height=416 input-width=416 mask="(6,7,8),(3,4,5),(0,1,2)" use-sigmoid=true
  • blob-size=13,26,52 : The output dimension of model. See How to get information from DL model
  • label="files/yolo.txt" : Path to label file of Yolo model
  • input-height=416 input-width=416 : Height and Width of input node of Yolo model
  • mask="(6,7,8),(3,4,5),(0,1,2)" : Mask string of Yolo output nodes, which will match with blob-size. See How to get information from DL model 
  • use-sigmoid=true : If using with adrt and adonnx , we need to set this to True. This will apply sigmoid on output of model. For OpenVINO model from Intel tutorial, output layers are already included sigmoid function so set this to false.

Was this article helpful?