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

相关文章

Python获取中国节假日数据记录入JSON文件

《Python获取中国节假日数据记录入JSON文件》项目系统内置的日历应用为了提升用户体验,特别设置了在调休日期显示“休”的UI图标功能,那么问题是这些调休数据从哪里来呢?我尝试一种更为智能的方法:P... 目录节假日数据获取存入jsON文件节假日数据读取封装完整代码项目系统内置的日历应用为了提升用户体验,

Spring Boot 配置文件之类型、加载顺序与最佳实践记录

《SpringBoot配置文件之类型、加载顺序与最佳实践记录》SpringBoot的配置文件是灵活且强大的工具,通过合理的配置管理,可以让应用开发和部署更加高效,无论是简单的属性配置,还是复杂... 目录Spring Boot 配置文件详解一、Spring Boot 配置文件类型1.1 applicatio

MySQL INSERT语句实现当记录不存在时插入的几种方法

《MySQLINSERT语句实现当记录不存在时插入的几种方法》MySQL的INSERT语句是用于向数据库表中插入新记录的关键命令,下面:本文主要介绍MySQLINSERT语句实现当记录不存在时... 目录使用 INSERT IGNORE使用 ON DUPLICATE KEY UPDATE使用 REPLACE

Python 中的异步与同步深度解析(实践记录)

《Python中的异步与同步深度解析(实践记录)》在Python编程世界里,异步和同步的概念是理解程序执行流程和性能优化的关键,这篇文章将带你深入了解它们的差异,以及阻塞和非阻塞的特性,同时通过实际... 目录python中的异步与同步:深度解析与实践异步与同步的定义异步同步阻塞与非阻塞的概念阻塞非阻塞同步

Python Dash框架在数据可视化仪表板中的应用与实践记录

《PythonDash框架在数据可视化仪表板中的应用与实践记录》Python的PlotlyDash库提供了一种简便且强大的方式来构建和展示互动式数据仪表板,本篇文章将深入探讨如何使用Dash设计一... 目录python Dash框架在数据可视化仪表板中的应用与实践1. 什么是Plotly Dash?1.1

Spring Boot中定时任务Cron表达式的终极指南最佳实践记录

《SpringBoot中定时任务Cron表达式的终极指南最佳实践记录》本文详细介绍了SpringBoot中定时任务的实现方法,特别是Cron表达式的使用技巧和高级用法,从基础语法到复杂场景,从快速启... 目录一、Cron表达式基础1.1 Cron表达式结构1.2 核心语法规则二、Spring Boot中定

国内环境搭建私有知识问答库踩坑记录(ollama+deepseek+ragflow)

《国内环境搭建私有知识问答库踩坑记录(ollama+deepseek+ragflow)》本文给大家利用deepseek模型搭建私有知识问答库的详细步骤和遇到的问题及解决办法,感兴趣的朋友一起看看吧... 目录1. 第1步大家在安装完ollama后,需要到系统环境变量中添加两个变量2. 第3步 “在cmd中

Spring Retry 实现乐观锁重试实践记录

《SpringRetry实现乐观锁重试实践记录》本文介绍了在秒杀商品SKU表中使用乐观锁和MybatisPlus配置乐观锁的方法,并分析了测试环境和生产环境的隔离级别对乐观锁的影响,通过简单验证,... 目录一、场景分析 二、简单验证 2.1、可重复读 2.2、读已提交 三、最佳实践 3.1、配置重试模板

在 Spring Boot 中使用异步线程时的 HttpServletRequest 复用问题记录

《在SpringBoot中使用异步线程时的HttpServletRequest复用问题记录》文章讨论了在SpringBoot中使用异步线程时,由于HttpServletRequest复用导致... 目录一、问题描述:异步线程操作导致请求复用时 Cookie 解析失败1. 场景背景2. 问题根源二、问题详细分

关于Spring @Bean 相同加载顺序不同结果不同的问题记录

《关于Spring@Bean相同加载顺序不同结果不同的问题记录》本文主要探讨了在Spring5.1.3.RELEASE版本下,当有两个全注解类定义相同类型的Bean时,由于加载顺序不同,最终生成的... 目录问题说明测试输出1测试输出2@Bean注解的BeanDefiChina编程nition加入时机总结问题说明