美文网首页
YOLOv5 detect 推理测试(没有检测框)

YOLOv5 detect 推理测试(没有检测框)

作者: 小白兔555 | 来源:发表于2022-04-09 16:40 被阅读0次

环境:

Nvidia RTX 3060
Ubuntu 16.04
CUDA 11.1
cuDNN 8.2.0
torch 1.10.1+cu111
torchvision 0.11.2+cu111
YOLOv5搭建及训练自己的数据集,请参考另一篇文章:https://www.jianshu.com/p/b3fa74f6c27b
训练完毕会得到 best.pt 和 last.pt 的权重文件,权重文件在 /run/train/exp/weights 下

yolov5-detect2.png

以YOLOv5 v6.0版本为例,先使用原始权重文件及项目提供的原始图片进行detect推理一下,可以修改detect.py文件


yolov5-detect11.png

可以先使用命令查看一下正确指令

python detect.py  -h
yolov5-detect4.png

然后,使用命令

python detect.py 
yolov5-detect6.png

运行结果将被保存在 /run/detect文件夹下


yolov5-detect7.png

detect结果如下:


yolov5-detect9.png
还可以使用命令保存标注结果
python detect.py --save-txt --save-conf
yolov5-detect8.png

detect结果除了有标注的图片外,还有一个文件夹记录检测框的信息:


yolov5-detect10.png

可以根据上述自行修改,对自己的项目进行detect。
我在detect的时候,一直没有检测框,找了一天bug,原来是命令写错了,两行心酸泪==

//错误示例:
python detect.py --classes 4 

一定按照 python detect.py -h 写,不然对图片不做任何修改


yolov5-detect1.png

相关文章

网友评论

      本文标题:YOLOv5 detect 推理测试(没有检测框)

      本文链接:https://www.haomeiwen.com/subject/vlujsrtx.html