先给结论:
检测代码:
启动cmd
cd 到 yolov5 文件夹中的detect.py 文件夹内执行代码
python detect.py --source E:\word\pythonProject\yolov5-label-xml-main\inference\images --weights runs\train\exp\weights\best.pt --conf 0.3 --save-txt
检测代码说明:
python detect.py –source E:\word\pythonProject\yolov5-label-xml-main\inference\images –weights runs\train\exp\weights\best.pt –conf 0.3 –save-txt
detect.py 为推理检测的脚本代码,
–source 为检测的图片所在的目录,
–weights为所用到的模型文件,根据前面算法训练,此处用到的模型文件即为大家训练好的。
–conf 为自信度,0.25表示只采用0.25以上的
-save–txt
图像识别教程
第一步 训练模型
完成之后会在最新的exp下有个 weights \ bast.pt 文件,这个就是我们训练出来的模型
(CPU训练大概需要十七个小时左右,作者是使用GPU训练)
(1060显卡训练大概需要两小时,时间关系就没有完全训练)
第二步 使用训练完成的模型进行图像识别
检测代码:
python detect.py --source E:\word\pythonProject\yolov5-label-xml-main\inference\images --weights runs\train\exp\weights\best.pt --conf 0.3 --save-txt
推理命令说明:
detect.py 为推理检测的脚本代码,一般在yolov5的文件夹下
–source 为需要检测的图片所在的目录,
–weights为所用到的模型文件,根据前面算法训练,此处用到的模型文件即为大家训练好的。
–conf 为自信度,0.25表示只采用0.25以上的
-save--txt 保存识别位置
这里必须严格按照以上格式自己修改,每个人的文件目录都不相同!
完成后就可以在
yolov5-master\runs\detect 文件夹下看见识别效果
Original: https://blog.csdn.net/qq_42368762/article/details/122769145
Author: 顽童任逍遥
Title: 基于yolov5模型训练之后的图像识别
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/680869/
转载文章受原作者版权保护。转载请注明原作者出处!