yolov5-6.0调测记录

2024-04-20 19:52
文章标签 记录 yolov5 6.0 调测

本文主要是介绍yolov5-6.0调测记录,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

  直接运行yolov5-6.0/detect.py,输出如下:

image 1/2 C:\Users\dun\Downloads\yolov5-6.0\data\images\bus.jpg: 640x480 4 persons, 1 bus, Done. (0.216s)
image 2/2 C:\Users\dun\Downloads\yolov5-6.0\data\images\zidane.jpg: 384x640 2 persons, 2 ties, Done. (0.166s)
Speed: 1.5ms pre-process, 191.0ms inference, 1.5ms NMS per image at shape (1, 3, 640, 640)
Results saved to runs\detect\exp3

  待检测的图像保存在yolov5-6.0\data\images 目录下,bus.jpgzidane.jpg 是项目自带的图像,检测结果保存在runs\detect\exp3 目录下,检测结果如下:
在这里插入图片描述
在这里插入图片描述
  检测涉及到的参数如下,后面会逐一解释和测试:

def parse_opt():parser = argparse.ArgumentParser()parser.add_argument('--weights', nargs='+', type=str, default=ROOT / 'yolov5s.pt', help='model path(s)')parser.add_argument('--source', type=str, default=ROOT / 'data/images', help='file/dir/URL/glob, 0 for webcam')parser.add_argument('--imgsz', '--img', '--img-size', nargs='+', type=int, default=[640], help='inference size h,w')parser.add_argument('--conf-thres', type=float, default=0.25, help='confidence threshold')parser.add_argument('--iou-thres', type=float, default=0.45, help='NMS IoU threshold')parser.add_argument('--max-det', type=int, default=1000, help='maximum detections per image')parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')parser.add_argument('--view-img', action='store_true', help='show results')parser.add_argument('--save-txt', action='store_true', help='save results to *.txt')parser.add_argument('--save-conf', action='store_true', help='save confidences in --save-txt labels')parser.add_argument('--save-crop', action='store_true', help='save cropped prediction boxes')parser.add_argument('--nosave', action='store_true', help='do not save images/videos')parser.add_argument('--classes', nargs='+', type=int, help='filter by class: --classes 0, or --classes 0 2 3')parser.add_argument('--agnostic-nms', action='store_true', help='class-agnostic NMS')parser.add_argument('--augment', action='store_true', help='augmented inference')parser.add_argument('--visualize', action='store_true', help='visualize features')parser.add_argument('--update', action='store_true', help='update all models')parser.add_argument('--project', default=ROOT / 'runs/detect', help='save results to project/name')parser.add_argument('--name', default='exp', help='save results to project/name')parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')parser.add_argument('--line-thickness', default=3, type=int, help='bounding box thickness (pixels)')parser.add_argument('--hide-labels', default=False, action='store_true', help='hide labels')parser.add_argument('--hide-conf', default=False, action='store_true', help='hide confidences')parser.add_argument('--half', action='store_true', help='use FP16 half-precision inference')parser.add_argument('--dnn', action='store_true', help='use OpenCV DNN for ONNX inference')opt = parser.parse_args()opt.imgsz *= 2 if len(opt.imgsz) == 1 else 1  # expandprint_args(FILE.stem, opt)return opt
  • weights:type=str 表示参数类型为字符串;default=ROOT / 'yolov5s.pt' 表示默认值为ROOT / 'yolov5s.pt' ;根据help='model path(s)' 可知,该参数表示模型权重文件的路径。
parser.add_argument('--weights', nargs='+', type=str, default=ROOT / 'yolov5s.pt', help='model path(s)')
  • source:指定输入的路径,默认值为ROOT / 'data/images'
parser.add_argument('--source', type=str, default=ROOT / 'data/images', help='file/dir/URL/glob, 0 for webcam')

  如执行python detect.py --source data/images/bus.jpg 只会检测bus.jpg

  • imgsz:模型在detect前,会把图像resize成640×640再进行检测,该尺寸需要和训练模型时使用的尺寸保持一致。在640×640的尺寸上得到检测框以后,再将640×640的图像连同检测框一起变换回原来的尺寸。
parser.add_argument('--imgsz', '--img', '--img-size', nargs='+', type=int, default=[640], help='inference size h,w')
  • –conf-thres:置信度阈值,只有置信度大于该阈值时,我们才认为这是一个物体。
parser.add_argument('--conf-thres', type=float, default=0.25, help='confidence threshold')

  执行python detect.py --conf-thres 0.25 ,检测结果如下。注意右边的tie 的置信度为0.26。
在这里插入图片描述
  执行python detect.py --conf-thres 0.27 ,检测结果如下,右边的tie已经没有了。
在这里插入图片描述

  • iou-thres:iou阈值,若两个检测框的iou大于该阈值,则根据NMS简化为一个框。
parser.add_argument('--iou-thres', type=float, default=0.45, help='NMS IoU threshold')

  执行python detect.py --iou-thres 0.45 ,结果如下:
在这里插入图片描述
  执行python detect.py --iou-thres 1 ,结果如下,可以看到同一个人对应了多个检测框。
在这里插入图片描述
  执行python detect.py --iou-thres 0 ,结果如下:
在这里插入图片描述

  • max-det:检测到的物体的最大数量。
parser.add_argument('--max-det', type=int, default=1000, help='maximum detections per image')

  执行python detect.py --max-det 4 ,结果如下:
在这里插入图片描述
  执行python detect.py --max-det 3 ,结果如下:
在这里插入图片描述
  执行python detect.py --max-det 2 ,结果如下:
在这里插入图片描述

  • view-img:设置该参数时,将会自动显示结果图像。
parser.add_argument('--view-img', action='store_true', help='show results')

  执行python detect.py --view-img ,将自动显示结果图像。

  • save-txt
  • save-conf
  • save-crop
parser.add_argument('--save-txt', action='store_true', help='save results to *.txt')
parser.add_argument('--save-conf', action='store_true', help='save confidences in --save-txt labels')
parser.add_argument('--save-crop', action='store_true', help='save cropped prediction boxes')

  执行python detect.py --save-txt --save-conf --save-crop ,结果如下:
在这里插入图片描述
  runs/detect/exp29/zidane.jpg 内容如下:
在这里插入图片描述
  runs/detect/exp29/labels/zidane.txt 内容如下:

27 0.782812 0.506944 0.0359375 0.141667 0.261517
0 0.327344 0.634028 0.4625 0.731944 0.666693
27 0.366797 0.796528 0.0429688 0.379167 0.675119
0 0.736328 0.533333 0.311719 0.933333 0.879861

  runs/detect/exp29/crops/person/zidane.jpg
  runs/detect/exp29/crops/person/zidane2.jpg
  runs/detect/exp29/crops/tie/zidane.jpg
  runs/detect/exp29/crops/tie/zidane2.jpg
  内容分别如下:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • nosave:若设置该参数,表示不保存结果图像。
parser.add_argument('--nosave', action='store_true', help='do not save images/videos')
  • classes
parser.add_argument('--classes', nargs='+', type=int, help='filter by class: --classes 0, or --classes 0 2 3')

  执行python detect.py --classes 27 ,27表示tie,结果如下:
在这里插入图片描述

  • project
  • name
  • exist-ok
parser.add_argument('--project', default=ROOT / 'runs/detect', help='save results to project/name')
parser.add_argument('--name', default='exp', help='save results to project/name')
parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')
  • line-thickness
  • hide-labels
  • hide-conf
parser.add_argument('--line-thickness', default=3, type=int, help='bounding box thickness (pixels)')
parser.add_argument('--hide-labels', default=False, action='store_true', help='hide labels')
parser.add_argument('--hide-conf', default=False, action='store_true', help='hide confidences')

  执行python detect.py --line-thickness 12 --hide-labels --hide-conf ,结果如下:
在这里插入图片描述

这篇关于yolov5-6.0调测记录的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/921177

相关文章

SpringBoot3应用中集成和使用Spring Retry的实践记录

《SpringBoot3应用中集成和使用SpringRetry的实践记录》SpringRetry为SpringBoot3提供重试机制,支持注解和编程式两种方式,可配置重试策略与监听器,适用于临时性故... 目录1. 简介2. 环境准备3. 使用方式3.1 注解方式 基础使用自定义重试策略失败恢复机制注意事项

Python UV安装、升级、卸载详细步骤记录

《PythonUV安装、升级、卸载详细步骤记录》:本文主要介绍PythonUV安装、升级、卸载的详细步骤,uv是Astral推出的下一代Python包与项目管理器,主打单一可执行文件、极致性能... 目录安装检查升级设置自动补全卸载UV 命令总结 官方文档详见:https://docs.astral.sh/

统一返回JsonResult踩坑的记录

《统一返回JsonResult踩坑的记录》:本文主要介绍统一返回JsonResult踩坑的记录,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录统一返回jsonResult踩坑定义了一个统一返回类在使用时,JsonResult没有get/set方法时响应总结统一返回

Go学习记录之runtime包深入解析

《Go学习记录之runtime包深入解析》Go语言runtime包管理运行时环境,涵盖goroutine调度、内存分配、垃圾回收、类型信息等核心功能,:本文主要介绍Go学习记录之runtime包的... 目录前言:一、runtime包内容学习1、作用:① Goroutine和并发控制:② 垃圾回收:③ 栈和

java对接海康摄像头的完整步骤记录

《java对接海康摄像头的完整步骤记录》在Java中调用海康威视摄像头通常需要使用海康威视提供的SDK,下面这篇文章主要给大家介绍了关于java对接海康摄像头的完整步骤,文中通过代码介绍的非常详细,需... 目录一、开发环境准备二、实现Java调用设备接口(一)加载动态链接库(二)结构体、接口重定义1.类型

apache的commons-pool2原理与使用实践记录

《apache的commons-pool2原理与使用实践记录》ApacheCommonsPool2是一个高效的对象池化框架,通过复用昂贵资源(如数据库连接、线程、网络连接)优化系统性能,这篇文章主... 目录一、核心原理与组件二、使用步骤详解(以数据库连接池为例)三、高级配置与优化四、典型应用场景五、注意事

SpringBoot实现文件记录日志及日志文件自动归档和压缩

《SpringBoot实现文件记录日志及日志文件自动归档和压缩》Logback是Java日志框架,通过Logger收集日志并经Appender输出至控制台、文件等,SpringBoot配置logbac... 目录1、什么是Logback2、SpringBoot实现文件记录日志,日志文件自动归档和压缩2.1、

qtcreater配置opencv遇到的坑及实践记录

《qtcreater配置opencv遇到的坑及实践记录》我配置opencv不管是按照网上的教程还是deepseek发现都有些问题,下面是我的配置方法以及实践成功的心得,感兴趣的朋友跟随小编一起看看吧... 目录电脑环境下载环境变量配置qmake加入外部库测试配置我配置opencv不管是按照网上的教程还是de

使用nohup和--remove-source-files在后台运行rsync并记录日志方式

《使用nohup和--remove-source-files在后台运行rsync并记录日志方式》:本文主要介绍使用nohup和--remove-source-files在后台运行rsync并记录日... 目录一、什么是 --remove-source-files?二、示例命令三、命令详解1. nohup2.

Java使用SLF4J记录不同级别日志的示例详解

《Java使用SLF4J记录不同级别日志的示例详解》SLF4J是一个简单的日志门面,它允许在运行时选择不同的日志实现,这篇文章主要为大家详细介绍了如何使用SLF4J记录不同级别日志,感兴趣的可以了解下... 目录一、SLF4J简介二、添加依赖三、配置Logback四、记录不同级别的日志五、总结一、SLF4J