[jetson浅试] yolov5+deepsort+Tensorrt C++部署(Xavier AGX)

1.简介:

这学期刚开学的时候搞的,空下来整理一些(以后还是应该养成边搞边写博客的好习惯)

本文主要是对yolov5-deepsort-tensorrt: A c++ implementation of yolov5 and deepsort (gitee.com)中的内容进行复现,熟悉xavier的配置流程,以及对xavier算力有一个相对直观的认识

2.使用平台介绍:

使用的平台是天准的Xavier AGX,出厂包含了opencv和tensorRT,nv自带的工具也可以安装,这部分还是比较方便的。

3.流程介绍:

3.1 clone yolov5

git clone -b v5.0 https://github.com/ultralytics/yolov5.git
cd yolov5
mkdir weights
cd weights
// download https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt
wget https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt

3.2 clone tensorrtx

git clone https://github.com/wang-xinyu/tensorrtx

3.3 使用tensorrtx将转换模型为wts

cp tensorrtx/gen_wts.py yolov5/
cd yolov5 
python3 gen_wts.py -w ./weights/yolov5s.pt -o ./weights/yolov5s.wts
// a file 'yolov5s.wts' will be generated.

3.4 项目编译

cd tensorrtx/yolov5
// update CLASS_NUM in yololayer.h if your model is trained on custom dataset
mkdir build
cd build
cp {ultralytics}/yolov5/yolov5s.wts {tensorrtx}/yolov5/build
cmake ..
make -j8

3.5 转换权重为 engine文件

// yolov5s
sudo ./yolov5 -s yolov5s.wts yolov5s.engine s
// test your engine file
sudo ./yolov5 -d yolov5s.engine ../samples

[jetson浅试] yolov5+deepsort+Tensorrt C++部署(Xavier AGX)_第1张图片

 

记住engine位置或者放入项目中指定位置

3.6 修改engine位置,测试demo

git clone https://github.com/RichardoMrMu/deepsort-tensorrt.git
// 根据github的说明
cp {deepsort-tensorrt}/exportOnnx.py {deep_sort_pytorch}/
python3 exportOnnx.py
mv {deep_sort_pytorch}/deepsort.onnx {deepsort-tensorrt}/resources
cd {deepsort-tensorrt}
mkdir build
cd build
cmake ..
make 
./onnx2engine ../resources/deepsort.onnx ../resources/deepsort.engine
// test
./demo ../resource/deepsort.engine ../resources/track.txt

3.7 运行结果

我测试比作者给出来的结果高不少(毕竟他用的nx,而且我测试的场景中,目标数量相对较少)

[jetson浅试] yolov5+deepsort+Tensorrt C++部署(Xavier AGX)_第2张图片

 [jetson浅试] yolov5+deepsort+Tensorrt C++部署(Xavier AGX)_第3张图片

 

你可能感兴趣的:(多目标追踪,MOT,计算机视觉,深度学习,人工智能)