Skip to content

docker镜像子项目《deepstream_yolov5》两种引擎(engine)生成方式

jianyang edited this page Feb 10, 2022 · 1 revision

子项目《deepstream_yolov5》两种引擎(engine)生成方式

方式一、通过cfg和wts文件在deepstream中直接生成trt引擎

1.对于CDR-jetson镜像,在root目录下有yolov5源码项目,yolov5文件夹内有gen_wts_yoloV5.py文件,执行如下命令可生成yolov5s.cfgyolov5s.wts两个文件:

python3 gen_wts_yoloV5.py -w yolov5s.pt

2.将以上生成的两个文件yolov5s.cfgyolov5s.wts复制到/opt/nvidia/deepstream/deepstream-6.0/sources/deepstream_python_apps/apps/deepstream-yolov5文件夹下,该文件夹下config_infer_primary.txt文件内容改成如下所示:

[property]
gpu-id=0
net-scale-factor=0.0039215697906911373
model-color-format=0
custom-network-config=yolov5s.cfg
model-file=yolov5s.wts
model-engine-file=model_b1_gpu0_fp32.engine
labelfile-path=labels.txt
batch-size=1
network-mode=0
num-detected-classes=80
interval=0
gie-unique-id=1
process-mode=1
network-type=0
cluster-mode=4
maintain-aspect-ratio=1
parse-bbox-func-name=NvDsInferParseYolo
custom-lib-path=nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so
engine-create-func-name=NvDsInferYoloCudaEngineGet

[class-attrs-all]
pre-cluster-threshold=0.25

3.运行视频文件检测程序并同时生成trt引擎文件(需要几分钟时间):

python3 deepstream_yolov5_file.py file:///opt/nvidia/deepstream/deepstream-6.0/samples/streams/sample_qHD.h264

方式二、通过tensorrtx项目生成trt文件,具体实现方式可参照项目内README.md文件