Coder Social home page Coder Social logo

richardomrmu / yolov5-deepsort-tensorrt Goto Github PK

View Code? Open in Web Editor NEW
428.0 6.0 102.0 3.22 MB

A c++ implementation of yolov5 and deepsort

License: GNU General Public License v3.0

CMake 1.20% C++ 91.19% C 0.28% Cuda 7.32%
jetson-nano jetson-xavier jetson-xavier-nx yolov5 deepsort tensorrt nvidia camera class head

yolov5-deepsort-tensorrt's Introduction

A C++ implementation of Yolov5 and Deepsort in Jetson Xavier nx and Jetson nano

MIT License GitHub stars

This repository uses yolov5 and deepsort to follow human heads which can run in Jetson Xavier nx and Jetson nano. In Jetson Xavier Nx, it can achieve 10 FPS when images contain heads about 70+(you can try python version, when you use python version, you can find it very slow in Jetson Xavier nx , and Deepsort can cost nearly 1s).

Thanks for B.Q Long, offer the windows cmakelists.txt. If you want run this rep in windows, you can use CMakeLists_deepsort-tensorrt_win10.txt and CMakeLists_yolov5-deepsort-tensorrt_win10.txt.

You can see video play in BILIBILI, or YOUTUBE and YOUTUBE.

Requirement

  1. Jetson nano or Jetson Xavier nx
  2. Jetpack 4.5.1
  3. python3 with default(jetson nano or jetson xavier nx has default python3 with tensorrt 7.1.3.0 )
  4. tensorrt 7.1.3.0
  5. torch 1.8.0
  6. torchvision 0.9.0
  7. torch2trt 0.3.0
  8. onnx 1.4.1
  9. opencv-python 4.5.3.56
  10. protobuf 3.17.3
  11. scipy 1.5.4

if you have problem in this project, you can see this artical.

Comming soon

  • Int8 .
  • IOU Tracking.
  • Faster and use less memory.

Speed

Whole process time from read image to finished deepsort (include every img preprocess and postprocess) and attention!!! the number of deepsort tracking is 70+, not single or 10-20 persons, is 70+. And all results can get in Jetson Xavier nx.

Backbone before TensorRT without tracking before TensorRT with tracking TensortRT(detection) TensorRT(detection + tracking) FPS(detection + tracking)
Yolov5s_416 100ms 0.9s 10-15ms 100-150ms 8 ~ 9
Yolov5s-640 120ms 1s 18-20ms 100-150ms 8 ~ 9

Build and Run

git clone https://github.com/RichardoMrMu/yolov5-deepsort-tensorrt.git
cd yolov5-deepsort-tensorrt
// before you cmake and make, please change ./src/main.cpp char* yolo_engine = ""; char* sort_engine = ""; to your own path
mkdir build 
cmake ..
make 

if you meet some errors in cmake and make, please see this artical or see Attention.

DataSet

If you need to train your own model with head detection, you can use this SCUT-HEAD, this dataset has bbox with head and can download freely.

Model

You need two model, one is yolov5 model, for detection, generating from tensorrtx. And the other is deepsort model, for tracking. You should generate the model the same way.

Generate yolov5 model

For yolov5 detection model, I choose yolov5s, and choose yolov5s.pt->yolov5s.wts->yolov5s.engine Note that, used models can get from yolov5 and deepsort, and if you need to use your own model, you can follow the Run Your Custom Model. You can also see tensorrtx official readme The following is deepsort.onnx and deesort.engine files, you can find in baiduyun and https://github.com/RichardoMrMu/yolov5-deepsort-tensorrt/releases/tag/yolosort

Model Url
百度云 BaiduYun url passwd:z68e
  1. Get yolov5 repository

Note that, here uses the official pertained model.And I use yolov5-5, v5.0. So if you train your own model, please be sure your yolov5 code is v5.0.

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
  1. Get tensorrtx.

For yolov5 v5.0, download .pt from yolov5 release v5.0, git clone -b v5.0 https://github.com/ultralytics/yolov5.git and git clone -b yolov5-v5.0 https://github.com/wang-xinyu/tensorrtx.git, then follow how-to-run in tensorrtx/yolov5-v5.0.

  1. Get xxx.wst model
cp {tensorrtx}/yolov5/gen_wts.py {ultralytics}/yolov5/
cd yolov5 
python3 gen_wts.py -w ./weights/yolov5s.pt -o ./weights/yolov5s.wts
// a file 'yolov5s.wts' will be generated.

You can get yolov5s.wts model in yolov5/weights/

  1. Build tensorrtx/yolov5 and get tensorrt engine
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
// yolov5s
sudo ./yolov5 -s yolov5s.wts yolov5s.engine s
// test your engine file
sudo ./yolov5 -d yolov5s.engine ../samples

Then you get the yolov5s.engine, and you can put yolov5s.engine in My project. For example

cd {yolov5-deepsort-tensorrt}
mkdir resources
cp {tensorrtx}/yolov5/build/yolov5s.engine {yolov5-deepsort-tensorrt}/resources
  1. Get deepsort engine file You can get deepsort pretrained model in this drive url and ckpt.t7 is ok.
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

After all 5 step, you can get the yolov5s.engine and deepsort.engine.

You may face some problems in getting yolov5s.engine and deepsort.engine, you can upload your issue in github or csdn artical.

Different versions of yolov5

Currently, tensorrt support yolov5 v1.0(yolov5s only), v2.0, v3.0, v3.1, v4.0 and v5.0.

  • For yolov5 v5.0, download .pt from yolov5 release v5.0, git clone -b v5.0 https://github.com/ultralytics/yolov5.git and git clone https://github.com/wang-xinyu/tensorrtx.git, then follow how-to-run in current page.
  • For yolov5 v4.0, download .pt from yolov5 release v4.0, git clone -b v4.0 https://github.com/ultralytics/yolov5.git and git clone -b yolov5-v4.0 https://github.com/wang-xinyu/tensorrtx.git, then follow how-to-run in tensorrtx/yolov5-v4.0.
  • For yolov5 v3.1, download .pt from yolov5 release v3.1, git clone -b v3.1 https://github.com/ultralytics/yolov5.git and git clone -b yolov5-v3.1 https://github.com/wang-xinyu/tensorrtx.git, then follow how-to-run in tensorrtx/yolov5-v3.1.
  • For yolov5 v3.0, download .pt from yolov5 release v3.0, git clone -b v3.0 https://github.com/ultralytics/yolov5.git and git clone -b yolov5-v3.0 https://github.com/wang-xinyu/tensorrtx.git, then follow how-to-run in tensorrtx/yolov5-v3.0.
  • For yolov5 v2.0, download .pt from yolov5 release v2.0, git clone -b v2.0 https://github.com/ultralytics/yolov5.git and git clone -b yolov5-v2.0 https://github.com/wang-xinyu/tensorrtx.git, then follow how-to-run in tensorrtx/yolov5-v2.0.
  • For yolov5 v1.0, download .pt from yolov5 release v1.0, git clone -b v1.0 https://github.com/ultralytics/yolov5.git and git clone -b yolov5-v1.0 https://github.com/wang-xinyu/tensorrtx.git, then follow how-to-run in tensorrtx/yolov5-v1.0.
Config
  • Choose the model s/m/l/x/s6/m6/l6/x6 from command line arguments.
  • Input shape defined in yololayer.h
  • Number of classes defined in yololayer.h, DO NOT FORGET TO ADAPT THIS, If using your own model
  • INT8/FP16/FP32 can be selected by the macro in yolov5.cpp, INT8 need more steps, pls follow How to Run first and then go the INT8 Quantization below
  • GPU id can be selected by the macro in yolov5.cpp
  • NMS thresh in yolov5.cpp
  • BBox confidence thresh in yolov5.cpp
  • Batch size in yolov5.cpp

Run Your Custom Model

You may need train your own model and transfer your trained-model to tensorRT. So you can follow the following steps.

  1. Train Custom Model You can follow the official wiki to train your own model on your dataset. For example, I choose yolov5-s to train my model.
  2. Transfer Custom Model Just like tensorRT official guideline.When your follow Generate yolov5 model to get yolov5 and tensorrt rep, next step is to transfer your pytorch model to tensorrt. Before this, you need to change yololayer.h file 20,21 and 22 line(CLASS_NUM,INPUT_H,INPUT_W) to your own parameters.
// before 
static constexpr int CLASS_NUM = 80; // 20
static constexpr int INPUT_H = 640;  // 21  yolov5's input height and width must be divisible by 32.
static constexpr int INPUT_W = 640; // 22

// after 
// if your model is 2 classfication and image size is 416*416
static constexpr int CLASS_NUM = 2; // 20
static constexpr int INPUT_H = 416;  // 21  yolov5's input height and width must be divisible by 32.
static constexpr int INPUT_W = 416; // 22
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
sudo ./yolov5 -s [.wts] [.engine] [s/m/l/x/s6/m6/l6/x6 or c/c6 gd gw]  // serialize model to plan file
sudo ./yolov5 -d [.engine] [image folder]  // deserialize and run inference, the images in [image folder] will be processed.
// For example yolov5s
sudo ./yolov5 -s yolov5s.wts yolov5s.engine s
sudo ./yolov5 -d yolov5s.engine ../samples
// For example Custom model with depth_multiple=0.17, width_multiple=0.25 in yolov5.yaml
sudo ./yolov5 -s yolov5_custom.wts yolov5.engine c 0.17 0.25
sudo ./yolov5 -d yolov5.engine ../samples

In this way, you can get your own tensorrt yolov5 model. Enjoy it!

Other Project

yolov5-deepsort-tensorrt's People

Contributors

dzy176 avatar lbq779660843 avatar richardomrmu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

yolov5-deepsort-tensorrt's Issues

Deserialize the cuda engine failed.

你好,我是在win10下进行工程部署,成功编译后,将自己序列化生成的yolov5和deepsort的engine文件写到main.cpp中对应接口后,运行yolosort.exe时报错结果如下:
[E] [TRT] C:\source\rtSafe\coreReadArchive.cpp (58) - Serialization Error in nvinfer1::rt::CoreReadArchive::verifyHeader: 0 (Length in header does not match remaining archive length)。
想知道报错原因及解决办法,非常期待您的回复!

Deserialize the cuda engine failed.

when i run the command line of ./demo ../resource/deepsort.engine ../resources/track.txt
but, show below
[10/31/2021-21:09:01] [E] [TRT] INVALID_ARGUMENT: Cannot deserialize with an empty memory buffer.
[10/31/2021-21:09:01] [E] [TRT] INVALID_CONFIG: Deserialize the cuda engine failed.
Segmentation fault (core dumped)

I can't complete step 5.

I can't complete step 5.

When I run python exportOnnx.py, it says fastreid is not compatible.

Right now, my PyTorch version is above 2.2.1, but fastreid seems to be compatible up to PyTorch 1.13.1.

Out of necessity, I tried to install PyTorch 1.13.1 using pip install torch==1.13.1, but it says that version is not available.

What should I do??

运行yolosort时发生错误

在jetson nano上运行时
nano@nano-desktop:~/yolov5-deepsort-tensorrt-main/build$ ./yolosort
yolov5_trt_create ...
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted (core dumped)

运行出错,[runtime.cpp::deserializeCudaEngine::50] Error Code 4: Internal Error (Engine deserialization failed.

错误详细信息如下:
[06/07/2023-14:22:21] [06/07/2023-14:22:21] yolov5_trt_create buffer ...
yolov5_trt_create stream ...
yolov5_trt_create done ...
create yolov5-trt , instance = 0x55604fda6400
[W] [TRT] TensorRT was linked against cuDNN 8.4.1 but loaded cuDNN 8.3.1
[W] [TRT] TensorRT was linked against cuDNN 8.4.1 but loaded cuDNN 8.3.1
[E] [TRT] 1: [stdArchiveReader.cpp::StdArchiveReader::35] Error Code 1: Serialization (Serialization assertion safeVersionRead == safeSerializationVersion failed.Version tag does not match. Note: Current Version: 0, Serialized Engine Version: 97)
[E] [TRT] 4: [runtime.cpp::deserializeCudaEngine::50] Error Code 4: Internal Error (Engine deserialization failed.)
[06/07/2023-14:22:21] [06/07/2023-14:22:21]
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

请问如何解决??????
开发环境的cuda为10.2, 开发环境的cuda的版本不能更改。

c++代码中 很多new的变量最后没释放

  • DS
    Trtyolosort::Trtyolosort(char *yolo_engine_path,char *sort_engine_path){
    sort_engine_path_ = sort_engine_path;
    yolo_engine_path_ = yolo_engine_path;
    trt_engine = yolov5_trt_create(yolo_engine_path_);
    printf("create yolov5-trt , instance = %p\n", trt_engine);
    DS = new DeepSort(sort_engine_path_, 128, 256, 0, &gLogger);
    }
  • featureExtractor
    void DeepSort::init() {
    objTracker = new tracker(maxCosineDist, maxBudget);
    featureExtractor = new FeatureTensor(batchSize, imgShape, featureDim, gpuID, gLogger);
    int ret = enginePath.find(".onnx");
    if (ret != -1)
    featureExtractor->loadOnnx(enginePath);
    else
    featureExtractor->loadEngine(enginePath);
    }
    DeepSort::~DeepSort() {
    delete objTracker;
    }
  • this->metric, this->kf
    tracker::tracker( /*NearNeighborDisMetric *metric, */
    float max_cosine_distance, int nn_budget,
    float max_iou_distance, int max_age, int n_init)
    {
    this->metric = new NearNeighborDisMetric(
    NearNeighborDisMetric::METRIC_TYPE::cosine,
    max_cosine_distance, nn_budget);
    this->max_iou_distance = max_iou_distance;
    this->max_age = max_age;
    this->n_init = n_init;
    this->kf = new KalmanFilter();
    this->tracks.clear();
    this->_next_idx = 1;
    }
  • instance
    linear_assignment *linear_assignment::getInstance()
    {
    if(instance == NULL) instance = new linear_assignment();
    return instance;
    }

./onnx2engine ../resources/deepsort.onnx ../resources/deepsort.engine

博主您好,我在onnx转engine哪一步遇到问题Network has dynamic or shape inputs, but no optimization profile has been defined. 我尝试通过将exportOnxx中的torch.onnx.export中的参数dynamic_axes={'input': {0: 'batch_size'}, 'output': {0: 'batch_size'}}删除后,发现可以生成engine并且能跑通整个流程,但是在运行./yolosort时报错Parameter check failed at: engine.cpp::setBindingDimensions::1044......(使用摄像头能运行就是会报错) 我尝试查阅tensortrt的官方文档发现有部分人存在这个问题,官方文档确实提供了一些说明,我查阅了您的代码后发现您写的代码和官方提供的代码sampleDynamicReshape.cpp都是通过定义profile的方式来实现动态推理,但是我这边仍报Error,请问您方便回复下吗

怎么使用yolov5-6.0

我需要修改一些什么呢,6.0版本在结构上有一些调整,所以我也使用了最新的版本的tensorrtx并成功生成了engine文件(顺带一提,如果使用Yolov5-5.0,需要下载对应5.0的tensorrtx),但我不知道在代码里应该修改什么部分让它能成功运行6.0版本的yolov5。

更换ReID模型之后,提示Eigen数据对齐错误

将ReID模型的输入改成 1x3x32x32大小,但是发现,Eigen一直报错

eigen/include/eigen3/Eigen/src/Core/CoreEvaluators.h:1226: Eigen::internal::block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, true>::block_evaluator(const XprType&) [with ArgType = const Eigen::Transpose<const Eigen::Matrix<float, 1, 8, 1> >; int BlockRows = 8; int BlockCols = 1; bool InnerPanel = true; Eigen::internal::block_evaluator<ArgType, BlockRows, BlockCols, InnerPanel, true>::XprType = Eigen::Block<const Eigen::Transpose<const Eigen::Matrix<float, 1, 8, 1> >, 8, 1, true>]: Assertion `((internal::UIntPtr(block.data()) % (((int)1 >= (int)evaluator::Alignment) ? (int)1 : (int)evaluator::Alignment)) == 0) && "data is not aligned"' failed.

大佬们有思路嘛?

Tensorrt 8.4.1 deepsort onnx 2 engine 报错

您好,使用tensorrt 8.4.1-1 + cuda11.4 在 Xavier NX 上,编译时报如下错误,该如何解决呢?

/usr/bin/ld: /usr/lib/aarch64-linux-gnu/tegra/libnvmedia.so: undefined reference to TVMRVideoOFSTUnRegisterSurface' /usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to nvdla::IProfile::setUseSoftMaxOptz(bool)'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to nvdla::IPoolingLayer::setPoolingPaddingInclusionType(nvdla::PoolingPaddingInclusionType)' /usr/bin/ld: /usr/lib/aarch64-linux-gnu/tegra/libnvmedia.so: undefined reference to TVMRVideoOFSTRegisterSurface'
/usr/bin/ld: /usr/lib/aarch64-linux-gnu/tegra/libnvmedia.so: undefined reference to TVMRVideoOFSTUnRegisterTaskStatus' /usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to nvdla::INetwork::addSlice(nvdla::ITensor*, nvdla::Weights, nvdla::Weights, nvdla::Weights, nvdla::Weights, nvdla::SliceLayerMode)'
/usr/bin/ld: /usr/lib/aarch64-linux-gnu/tegra/libnvmedia.so: undefined reference to TVMRVICDestroy' /usr/bin/ld: /usr/lib/aarch64-linux-gnu/tegra/libnvmedia.so: undefined reference to TVMRVideoEncoderUnRegisterSurface'
/usr/bin/ld: /usr/lib/aarch64-linux-gnu/tegra/libnvmedia.so: undefined reference to TVMRVideoEncoderRegisterSurface' /usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to nvdla::IProfile::setCanCompressStructuredSparseWeights(bool)'
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to nvdla::INetwork::addResize(nvdla::ITensor*, nvdla::ResizeMode, nvdla::Weights)' /usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libnvinfer.so: undefined reference to nvdla::ISoftMaxLayer::setAxis(int)'
/usr/bin/ld: /usr/lib/aarch64-linux-gnu/tegra/libnvmedia.so: undefined reference to TVMRVideoOFSTRegisterTaskStatus' /usr/bin/ld: /usr/lib/aarch64-linux-gnu/tegra/libnvmedia.so: undefined reference to TVMRVICCreate'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/demo.dir/build.make:149: demo] Error 1
make[1]: *** [CMakeFiles/Makefile2:80: CMakeFiles/demo.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Tensorrt信息
ii graphsurgeon-tf 8.4.1-1+cuda11.4 arm64 GraphSurgeon for TensorRT package
ii libnvinfer-bin 8.4.1-1+cuda11.4 arm64 TensorRT binaries
ii libnvinfer-dev 8.4.1-1+cuda11.4 arm64 TensorRT development libraries and headers
ii libnvinfer-plugin-dev 8.4.1-1+cuda11.4 arm64 TensorRT plugin libraries
ii libnvinfer-plugin8 8.4.1-1+cuda11.4 arm64 TensorRT plugin libraries
ii libnvinfer-samples 8.4.1-1+cuda11.4 all TensorRT samples
ii libnvinfer8 8.4.1-1+cuda11.4 arm64 TensorRT runtime libraries
ii libnvonnxparsers-dev 8.4.1-1+cuda11.4 arm64 TensorRT ONNX libraries
ii libnvonnxparsers8 8.4.1-1+cuda11.4 arm64 TensorRT ONNX libraries
ii libnvparsers-dev 8.4.1-1+cuda11.4 arm64 TensorRT parsers libraries
ii libnvparsers8 8.4.1-1+cuda11.4 arm64 TensorRT parsers libraries
ii nvidia-tensorrt 5.0.2-b222 arm64 NVIDIA TensorRT Meta Package
ii nvidia-tensorrt-dev 5.0.2-b222 arm64 NVIDIA TensorRT dev Meta Package
ii python3-libnvinfer 8.4.1-1+cuda11.4 arm64 Python 3 bindings for TensorRT
ii python3-libnvinfer-dev 8.4.1-1+cuda11.4 arm64 Python 3 development package for TensorRT
ii tensorrt 8.4.1.5-1+cuda11.4 arm64 Meta package for TensorRT
ii uff-converter-tf 8.4.1-1+cuda11.4 arm64 UFF converter for TensorRT package

c++版tensorrt在跟踪时,对镜头突然移动的情况,跟踪会掉,而python版不会掉,产生差异的原因

具体就是:python版本再镜头突然移动时能跟上,tensorrt的c++版本会掉;调试代码发现是在马氏距离那被干掉了,我把马氏距离的二次过滤代码注释掉,就不会掉。。。。。。对比代码,python和c++关于这一块应该是相同的,所以问题不在这吧应该。。然后就剩下reid特征这了,python输出的是512维的,c++好像是256维的,是这个的原因吗?(FP32和FP16都是这样,应该不是精度变化的问题)

[WARNING]::Batch size overflow, input will be truncated!

Hi, when I test the program using my own data, I meet one question that the output shows that the batch size is overflow, so I wonder whether can I change the imgShape to solve that problem? And how can I tune that parameter? The value of imgShape in deepsort.cpp is cv::Size(64, 128), and I don't know why the value is (64, 128), can you help me?

跟踪效果和python版的差距很大是什么原因?跟踪总是掉

跑自己训练的模型和视频,视频有相机突然移动的部分,然后这个版本就会丢失目标,但是python版本的不会掉.....是我哪儿设置错了吗。。。因为感觉这种情况像没用deepsort,只是用了sort。。。。因为sort对于这种相机突然移动的视频就会掉。感谢大佬们解答!

How to map from class_id to class_name?

Hi,
In this project, I saw that model return class_id of each detected object. How can I map from that class_id to class_name of objects in the right order?
Thank you!

Get the features from ReID model

How to get the feature vector from the ReID model for each id in each frame along with the classid , confidence, and bbox in order to save the data for future reference

求助

-- Generating done
-- Build files have been written to: /home/mql/work/yolov5-deepsort-tensorrt-main/build
[ 64%] Built target deepsort
[ 70%] Building NVCC (Device) object CMakeFiles/yolov5_trt.dir/yolo/include/yolov5_trt_generated_yololayer.cu.o
nvcc fatal : redefinition of argument 'std'
CMake Error at yolov5_trt_generated_yololayer.cu.o.Release.cmake:219 (message):
Error generating
/home/mql/work/yolov5-deepsort-tensorrt-main/build/CMakeFiles/yolov5_trt.dir/yolo/include/./yolov5_trt_generated_yololayer.cu.o

CMakeFiles/yolov5_trt.dir/build.make:326: recipe for target 'CMakeFiles/yolov5_trt.dir/yolo/include/yolov5_trt_generated_yololayer.cu.o' failed
make[2]: *** [CMakeFiles/yolov5_trt.dir/yolo/include/yolov5_trt_generated_yololayer.cu.o] Error 1
CMakeFiles/Makefile2:142: recipe for target 'CMakeFiles/yolov5_trt.dir/all' failed
make[1]: *** [CMakeFiles/yolov5_trt.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

make出现问题,不知道咋解决0-0

请问我在运行yolosort时遇到这个问题怎么回事

D:\srtp1\yolov5-deepsort-tensorrt-main\Release>yolosort
yolov5_trt_create ...
yolov5_trt_create cuda engine...
[04/10/2022-19:16:32] [W] [TRT] Current optimization profile is: 0. Please ensure there are no enqueued operations pending in this context prior to switching profiles
yolov5_trt_create buffer ...
yolov5_trt_create stream ...
yolov5_trt_create done ...
create yolov5-trt , instance = 000002EE1C5D80C0
[04/10/2022-19:16:32] [E] [TRT] C:\source\rtSafe\coreReadArchive.cpp (55) - Serialization Error in nvinfer1::rt::CoreReadArchive::verifyHeader: 0 (Length in header does not match remaining archive length)
[04/10/2022-19:16:32] [E] [TRT] INVALID_STATE: Unknown exception
[04/10/2022-19:16:32] [E] [TRT] INVALID_CONFIG: Deserialize the cuda engine failed.

段错误是什么情况?

很奇怪,配置和模型都是ok的,运行的时候报段错误是为啥?

yolov5_trt_create  ... 
yolov5_trt_create  cuda engine... 
[02/24/2022-16:18:59] [W] [TRT] Current optimization profile is: 0. Please ensure there are no enqueued operations pending in this context prior to switching profiles
yolov5_trt_create  buffer ... 
yolov5_trt_create  stream ... 
yolov5_trt_create  done ... 
create yolov5-trt , instance = 0x555e4d644810
[02/24/2022-16:18:59] [W] [TRT] Current optimization profile is: 0. Please ensure there are no enqueued operations pending in this context prior to switching profiles
[02/24/2022-16:18:59] [E] [TRT] INVALID_ARGUMENT: Cannot find binding of given name: input
[02/24/2022-16:18:59] [E] [TRT] INVALID_ARGUMENT: Cannot find binding of given name: output
delay_proress:3ms, delay_infer:3ms
段错误 (核心已转储)

测试长视频时,deepsort_tet会一直申请内存导致内存爆掉

运行正常的时候:
vector: 24
origin img size:960 540
yolov5_trt_detect start preprocess img
after preprocess_img pr_img size:640 640
after preprocess_img frame size:960 540
yolov5_trt_detect start convert img to float
yolov5_trt_detect start do inference
image

运行一段时间后,当显存被占满时,deepsort直接停止工作,框会一直停留在那一帧,但是yolo还在继续跑:
CUDA error 2 at F:\Detections\yolov5-deepsort-tensorrt\yolo\src\yolov5_lib.cpp:30[04/23/2022-18:43:35] [E] [TRT] C:\source\rtSafe\safeContext.cpp (133) - Cudnn Error in nvinfer1::rt::CommonContext::configure: 7 (CUDNN_STATUS_MAPPING_ERROR)
[04/23/2022-18:43:35] [E] [TRT] FAILED_EXECUTION: Unknown exception

image

我的配置:
GTX1050ti-Notebook 4GB
CUDAA10.1
cudnn-10.1-windows10-x64-v7.6.5.32
NVIDIA Drive 497.33
opencv-3.3-vc14
cmake-3.17.1-windows-x86_64
TensorRT-7.0.0.11.Windows10.x86_64.cuda-10.0.cudnn7.6

Are only tensorrtx 5.0 - yolov5s available??

Are only tensorrtx 5.0 - yolov5s available??

i created "wts" using tensorrtx lasted version not tensorrtx5.0.

I have converted the yolov5s.pt or yolov5x.pt to wts, and then transformed it into an engine file. After this conversion, I have confirmed that there are no issues with the engine.

Now, when I attempt to run a DeepSort example, an error occurs in every frame of the video. The error messages are:
[E] [TRT] 1: [context.cpp::nvinfer1::rt::CommonContext::setStream::88] Error Code 1: Cudnn (CUDNN_STATUS_MAPPING_ERROR)
CUDA error 700 at C:\Users\user\Desktop\ysw\yolov5-deepsort-tensorrt\yolo\src\yolov5_lib.cpp:33CUDA error 700 at C:\Users\user\Desktop\ysw\yolov5-deepsort-tensorrt\yolo\src\yolov5_lib.cpp

编译完成运行发现这个问题

jetson nano上运行报错

yolov5_trt_create ...
yolov5_trt_create cuda engine...
yolov5_trt_create buffer ...
yolov5_trt_create stream ...
yolov5_trt_create done ...
create yolov5-trt , instance = 0x55761cdab0
[02/12/2022-23:52:05] [W] [TRT] The logger passed into createInferRuntime differs from one already provided for an existing builder, runtime, or refitter. TensorRT maintains only a single logger pointer at any given time, so the existing value, which can be retrieved with getLogger(), will be used instead. In order to use a new logger, first destroy all existing builder, runner or refitter objects.

[02/12/2022-23:52:06] [E] [TRT] 1: [stdArchiveReader.cpp::StdArchiveReader::34] Error Code 1: Serialization (Serialization assertion safeVersionRead == safeSerializationVersion failed.Version tag does not match. Note: Current Version: 43, Serialized Engine Version: 97)
[02/12/2022-23:52:06] [E] [TRT] 4: [runtime.cpp::deserializeCudaEngine::76] Error Code 4: Internal Error (Engine deserialization failed.)
Segmentation fault (core dumped)

win10的問題

我根據CMakeLists_yolov5-deepsort-tensorrt_win10.txt編譯完成後得到
deepsort.lib, yolosort.exe, yolosort.lib and yolov5_trt.lib
請問要如何使用他們 或進一步要如何得到yolov5s.engine和deepsort.engine,才能結合main.cpp的需求?

C++ model is not good as python one

Thanks for your nice work, Your solution works but not as expected, I find that both the detection and the reID performance are not good as the original in the python environment.
I don't know whether I was wrong somewhere or c++ model drop accuracy compare to it in python is just a normal case.
Any comment is very appreciated. Thanks

python3.6无法装protobuf 3.17.3

博主,你好,我jetson上的python是3.6,对应的pytorch也是3.6的 1.8版本。。请问,你是用的python3.7的码?

Eigen报内存对齐的错误

deep_track_test: /home/liushuan/tools/eigen3/Eigen/src/Core/DenseStorage.h:109: Eigen::internal::plain_array<T, Size, MatrixOrArrayOptions, 16>::plain_array() [with T = float; int Size = 64; int MatrixOrArrayOptions = 1]: Assertion `(internal::UIntPtr(eigen_unaligned_array_assert_workaround_gcc47(array)) & (15)) == 0 && "this assertion is explained here: " "http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html" " **** READ THIS WEB PAGE !!! ****"' failed.
Aborted (core dumped)

運行的問題

我在win10上跑
char* yolo_engine = "d:/yolov5-deepsort-tensorrt_1/yolov5s.engine";
char* sort_engine = "d:/yolov5-deepsort-tensorrt_1/deepsort.engine";
float conf_thre = 0.4;
Trtyolosort yosort(yolo_engine,sort_engine);
VideoCapture capture;
cv::Mat frame;
//frame = capture.open("d:/yolov5-deepsort-tensorrt_1/test.mp4");
frame = capture.open(0);
if (!capture.isOpened()){
std::cout<<"can not open"<<std::endl;
return -1 ;
}
capture.read(frame);
結果出現
yolov5_trt_create ...
yolov5_trt_create cuda engine...
yolov5_trt_create buffer ...
yolov5_trt_create stream ...
yolov5_trt_create done ...
create yolov5-trt , instance = 000002B801D48290
delay_proress:6ms, delay_infer:2ms
delay_infer:13ms
delay_proress:7ms, delay_infer:2ms
delay_infer:13ms
delay_proress:1ms, delay_infer:2ms
...
這應該是都對的,但沒有opencv 的windows出來,請問我該加些甚麼?
謝謝

Support for TensorRT8

您好,我之前利用您分享的repo跑通了Windows端的跟踪算法,但目前的环境是TensorRT7,所以想请问一下是否有最新的TensorRT8支持的算法版本?若需在您目前分享的TensorRT7环境下的跟踪算法代码中自行修改去匹配TRT8环境,需要如何操作?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.