Jetpack4.6+Deepstream6.0+Yolov5安装

1 安装Deepstream

  • 安装DeepStream 6.0.1【官方教程】:https://docs.nvidia.com/metropolis/deepstream/6.0.1/dev-guide/text/DS_Quickstart.html

2 yolov5转换

2.1 编译插件DeepStream-Yolo

  • DeepStream-Yol项目地址:https://github.com/marcoslucianops/DeepStream-Yolo.git
  • 注意修改nvdsinfer_custom_impl_Yolo/Makefile中的CUDA_VER?=10.2。或者执行CUDA_VER=10.2 make -c nvdsinfer_custom_impl_Yolo

2.2 yolov5转换成wts

  • 下载yolov5项目:https://github.com/ultralytics/yolov5
  • 将DeepStream-Yolo项目中utils/gen_wts_yoloV5.py拷贝到yolov5项目目录下,因为该脚本依赖了yolov5中utils中的内容
  • 执行python3 gen_wts_yoloV5.py -w WEIGHT -s SIZE生成cfg和wts文件【一定要在这一步指定模型的输入尺寸】

2.3 配置config_infer_primary_yoloV5.txt

[property]
gpu-id=0
net-scale-factor=0.0039215697906911373
model-color-format=0
custom-network-config=yolov5s.cfg  # cfg文件路径
model-file=yolov5s.wts  # wts文件路径
model-engine-file=model_b1_gpu0_fp32.engine
#int8-calib-file=calib.table
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=2
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]
nms-iou-threshold=0.45
pre-cluster-threshold=0.25
topk=300
  • custom-network-config=yolov5s.cfg # cfg文件路径
  • model-file=yolov5s.wts # wts文件路径
  • model-engine-file=model_b1_gpu0_fp32.engine,可以默认不修改,若无该文件将在第一期deepstream启动时自动根据wts和cfg生成model_b1_gpu0_fp32.engine。

2.4 执行deepsteam-app命令,生成engine文件并开始推理。

3 PythonSDK调用

问题1:执行deepstream-test1时出现下面错误

File "deepstream_test_1.py", line 55, in osd_sink_pad_buffer_probe
    batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(gst_buffer))
AttributeError: module 'pyds' has no attribute 'gst_buffer_get_nvds_batch_meta

参考解决方案1:

  • https://forums.developer.nvidia.com/t/no-module-named-pyds/123722/6
  • https://chowdera.com/2022/04/202204091852306627.html

Pyds In the use of probe extract Metadata Key information in , To use NVIDIA Compiled package , Not directly pip install The way , Otherwise, the corresponding method file will be missing , If the report is wrong :

AttributeError: module 'pyds' has no attribute 'gst_buffer_get_nvds_batch_meta'

The correct way is to download the compiled compressed package file , Download after decompression and download after decompression python/bindings In the path , According to their own platform , Such as jetson Copied to the /home//.local/lib/python/site-packages/pyds.so In the path

此处pyds不是通过 pip3 install pyds安装的,它是nvidia提供的捆绑软件中的一个库deepstream_python_v0.9.tbz2下载地址。解压并安装。

tar jxvf deepstream_python_v0.9.tbz2
mkdir -p /home//.local/lib/python3.6/site-packages/
cp deepstream_python_v0.9/python/bindings/jetson/pyds.so  ~/.local/lib/python3.6/site-packages

你可能感兴趣的:(Jetpack4.6+Deepstream6.0+Yolov5安装)