依照四部署yolo v5 环境。
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 best.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 best.pt
【错误】no module named numpy.testing.nosetester
发生这种情况的原因是numpy
和之间的版本不兼容scipy
。numpy
在其最新版本中已弃用numpy.testing.nosetester
。
尝试
pip install scipy
【报错】No lapack/blas resources found
尝试https://blog.csdn.net/liulangdeshusheng/article/details/52433075
遇到的问题:
no lapack/blas resources found
解决方法,安装lapack
sudo apt-get install liblapack-dev
然后重新安装scipy,这次遇到了不一样的问题。
遇到的问题:
error: library dfftpack has Fortran sources but no Fortran compiler found
解决方法,安装Fortran compiler:
sudo apt-get install gfortran
再次执行
python3 gen_wts.py best.pt
生成 best.wts
https://zhuanlan.zhihu.com/p/365191541
1.查看Yolo v5的训练参数:
https://www.icode9.com/content-3-774443.html
data文件夹下查看myvoc.yaml文件查找对应类别数
weights文件夹下查看预训练模型版本-比如yolov5m
2、修改yololayer.h和yolov5.cpp文件,主要修改对应的参数和我们训练时候保持一致,不然会报错
对yololayer.h修改类别数
对yolov5.cpp主要需要根据显存大小调试batchsize大小,一般设成1就可以
根据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 best.wts best.engine m
#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 ‘best.engine’ and ‘libmyplugin.so’ here for the future use.