https://github.com/Megvii-BaseDetection/YOLOX
https://github.com/nanmi/YOLOX-deepstream
https://github.com/NVIDIA-AI-IOT/yolov4_deepstream
https://github.com/DanaHan/Yolov5-in-Deepstream-5.0
https://blog.csdn.net/zong596568821xp/article/details/109444343
这里主要以yolov5为例,其他两个可以是同样的流程。
https://www.runoob.com/w3cnote/python-pip-install-usage.html
安装pip
sudo apt-get install python-pip
升级pip
pip install -U pip
ubuntu 修改python默认版本,系统级修改
https://blog.csdn.net/White_Idiot/article/details/78240298
基于软链接:
先删除默认的Python软链接:
sudo rm /usr/bin/python
然后创建一个新的软链接指向需要的Python版本:
sudo ln -s /usr/bin/python3.5 /usr/bin/python
安装requirements.txt遇到报错,重新安装pip:
sudo apt-get install python-pip
根据安装提示卸载多余包
sudo apt autoremove
再次尝试还是失败,尝试卸载pip重装:
sudo apt remove python-pip
仍然报错:
ImportError: No module named pip
尝试:
sudo apt-get install python3-pip
成功安装pip3,然后执行:
pip3 install -r requirements.txt
配置yolov5运行环境
https://github.com/marcoslucianops/DeepStream-Yolo/blob/master/YOLOv5-5.0.md
Matplotlib (for Jetson plataform)
sudo apt-get install python3-matplotlib
PyTorch (for Jetson plataform)
wget https://nvidia.box.com/shared/static/p57jwntv436lfrd78inwl7iml6p13fzh.whl -O torch-1.8.0-cp36-cp36m-linux_aarch64.whl
#如果因为网络问题无法下载,可以先下载好torch-1.8.0-cp36-cp36m-linux_aarch64.whl,然后复制过去
sudo apt-get install python3-pip libopenblas-base libopenmpi-dev
pip3 install Cython
pip3 install numpy torch-1.8.0-cp36-cp36m-linux_aarch64.whl
TorchVision (for Jetson platform)
sudo apt-get install libjpeg-dev zlib1g-dev libpython3-dev libavcodec-dev libavformat-dev libswscale-dev
git clone --branch v0.9.0 https://github.com/pytorch/vision torchvision
cd torchvision
export BUILD_VERSION=0.9.0
python3 setup.py install --user
git clone https://github.com/wang-xinyu/tensorrtx.git
git clone https://github.com/ultralytics/yolov5.git
wget https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt -P yolov5/
cp tensorrtx/yolov5/gen_wts.py yolov5/gen_wts.py
cd yolov5
python3 gen_wts.py yolov5s.pt
yolov5s.wts file will be generated in yolov5 folder
【错误】No module named tqdm
pip install tqdm
【错误】No module named seaborn
pip3 install seaborn
因matplotlib无法正常安装导致seaborn无法安装,尝试:
python --version
python -m pip install seaborn
再次因matplotlib失败
尝试:
https://toptechboy.com/
https://blog.csdn.net/LYiiiiiii/article/details/119052823
sudo apt-get install python3-seaborn
再次执行
python3 gen_wts.py yolov5s.pt
成功!
根据https://github.com/DanaHan/Yolov5-in-Deepstream-5.0的说明,在Build tensorrtx/yolov5之前还需要:
Important Note:
You should replace yololayer.cu and hardswish.cu file in tensorrtx/yolov5
cd tensorrtx/yolov5
mkdir build
cd build
cmake ..
make
cp yolov5/yolov5s.wts tensorrtx/yolov5/build/yolov5s.wts
sudo ./yolov5 -s yolov5s.wts yolov5s.engine s
mkdir /opt/nvidia/deepstream/deepstream-5.1/sources/yolo
cp yolov5s.engine /opt/nvidia/deepstream/deepstream-5.1/sources/yolo/yolov5s.engine
Note: by default, yolov5 script generate model with batch size = 1 and FP16 mode.
#define USE_FP16 // set USE_INT8 or USE_FP16 or USE_FP32
#define DEVICE 0 // GPU id
#define NMS_THRESH 0.4
#define CONF_THRESH 0.5
#define BATCH_SIZE 1
Edit yolov5.cpp file before compile if you want to change this parameters.
We can get ‘yolov5s.engine’ and ‘libmyplugin.so’ here for the future use.
【!】切换使用https://github.com/DanaHan/Yolov5-in-Deepstream-5.0的deepstream配置进行之后的nvdsinfer_custom_impl_yolo plugin等操作(也可以按https://github.com/marcoslucianops/DeepStream-Yolo/blob/master/YOLOv5-5.0.md继续)
在Yolov5-in-Deepstream-5.0/Deepstream 5.0下执行
CUDA_VER=10.2 make -C nvdsinfer_custom_impl_Yolo
并将deepstream_app_config_yoloV5.txt文件中的deepstream-5.0全部修改为deepstream-5.1
在/opt/nvidia/deepstream/deepstream-5.1/sources/objectDetector_Yolo文件夹下找到labels.txt文件复制到Yolov5-in-Deepstream-5.0/Deepstream 5.0
修改config_infer_primary_yoloV5.txt中的custom-lib-path,删除 ‘objectDetector_Yolo_V5/’
执行
deepstream-app -c deepstream_app_config_yoloV5.txt
将之前生成的yolov5s.engine文件复制到Yolov5-in-Deepstream-5.0/Deepstream 5.0
仍然报错…
未知错误,不知道如何修改,更换部署方法:
sudo chmod -R 777 /opt/nvidia/deepstream/deepstream-5.1/sources/
cd /opt/nvidia/deepstream/deepstream-5.1/sources/yolo
CUDA_VER=11.1 make -C nvdsinfer_custom_impl_Yolo
cd /opt/nvidia/deepstream/deepstream-5.1/sources/yolo
CUDA_VER=10.2 make -C nvdsinfer_custom_impl_Yolo
Testing model
Use my edited deepstream_app_config.txt and config_infer_primary.txt files available in my external/yolov5-5.0 folder
Run command
deepstream-app -c deepstream_app_config.txt
YoloV5部署成功!