当前位置:网站首页>目标检测yolov5开源项目调试
目标检测yolov5开源项目调试
2022-06-30 09:32:00 【Stephen_Tao】
一、开源代码下载
项目地址:https://github.com/ultralytics/yolov5
二、环境配置
1.加载项目
下载后的文件进行解压,打开PyCharm,通过File-Open,选择项目路径加载项目。
2.创建虚拟环境
- 首先需要安装Anaconda,并完成所需的一些环境变量的配置。然后打开Anocanda Prompt,通过
conda create -n “name” python=“version”创建虚拟环境(虚拟环境默认安装到C盘中,修改默认路径的方式可以参考基于Anaconda的模块安装与注意事项)。 - 在当前虚拟环境下安装对应模块,模块的信息在
requirement.txt文件中。在Pycharm中打开Terminal,通过pip intall -r requirement.txt安装。
- 进入Pycharm,通过
File-Settings-Project:yolov5-5.0-Python Interpreter进入Python解释器配置(我这里选择的是yolov5的5.0版本,根据需要可以下载不同的版本,目前已经到了6.1版本),添加虚拟环境的Python解释器路径,至此环境配置完成。
三、基于yolov5的预测
1.基于终端命令行的预测
- 从 https://github.com/ultralytics/yolov5/releases/tag/v6.1中下载一个网络的权重文件,并放在项目的目录下,本项目下载的是
yolo5x.pt。 - 在Terminal中键入python detect.py --weights yolo5x.pt会出现报错的情况,报错信息如下。

具体解决方案可以参考yolov5–Can’t get attribute ‘SPPF’ on - 但是解决了上述问题后,运行又会出现报错信息,报错信息如下。

具体解决方案可以参考YOLOV5 训练好模型测试时出现问题:AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘的解决方法 - 解决上述问题后代码能正常运行,终端显示如下。

2.基于Pycharm集成开发环境的预测
步骤1、2、3都与基于终端命令行的预测的相同。不同的操作如下.
- 点击右上角的detect图标,并选择
Edit Configurations。
- 在Parameters选项中键入
--weights yolov5x.pt并应用。
- 运行detect.py后显示结果。

3.预测结果


四、代码相关解释

'--weights':用于指定网络的权重参数,默认是yolov5s.pt(上述项目所采用的是yolov5x.pt,所以需要重新指定)。'--source':图片或者视频的路径,也就是网络输入的路径。'--img-size':指定输入网络的图片大小。'--conf-thres':物体的置信度阈值,小于该阈值的目标框不进行显示。'--iou-thres':IOU阈值,用于非极大值抑制。如果两个检测框的IOU大于阈值,则保留置信度更高的检测框。反之则两个检测框都保留。'--device':采用CPU还是GPU运算。'--view-img':运行代码的时候显示结果,其中action参数设置为store_true表示指定了该参数则显示结果(后面也有action参数,就不赘述了)。如在终端输入python detect.py --weights yolov5x.pt --view-img就会在运行过程中实时显示运行结果。'--save-txt':将运行结果写入txt文件中。'--save-conf':保存置信度。'--nosave':是否保存运行的结果。'--classes':可用于类别的过滤,只显示特定类别的目标。'--agnostic-nms':增强的非极大值抑制。'--augment':对结果的增强推断。'--project':网络输入结果的保存路径。'--name':保存结果的名称。'--exist-ok':下一次运行结果是否覆盖上一次的结果。
边栏推荐
- Cb/s Architecture - Implementation Based on cef3+mfc
- Esp32 things (V): analysis of common API of esp32 of Swiss Army knife
- Deep understanding of kotlin collaboration context coroutinecontext
- Opencv learning notes -day 11 (split() channel separation function and merge() channel merge function)
- Mysq database remote connection error, remote connection is not allowed
- Tclistener server and tcpclient client use -- socket listening server and socketclient use
- Initialize static resource demo
- Idea shortcut key settings
- Talk about how the kotlin collaboration process establishes structured concurrency
- Reading notes of "Introduction to deep learning: pytoch"
猜你喜欢

(zero) most complete JVM knowledge points

Couldn't load this key (openssh ssh-2 private key (old PEM format))

Duplicate entry '2' for key 'primary appears in JPA‘

小程序手持弹幕的原理及实现(uni-app)

float

Express の Hello World

Solution to pychart's failure in importing torch package

Acquisition de 100% des actions de Guilin latex par Guilin Robust Medical pour combler le vide de la gamme de produits Latex

Using appbarlayout to realize secondary ceiling function

Opencv learning notes -day 12 (ROI region extraction and inrange() function operation)
随机推荐
Solution to the eighth training competition of 2020 Provincial Games
MySQL directory
Handwriting sorter component
Esp32 things (3): overview of the overall system design
[JPEG] how to compile JPEG turbo library files on different platforms
Opencv learning notes -day 12 (ROI region extraction and inrange() function operation)
JVM family
Cronexpression expression explanation and cases
Opencv learning notes-day5 (arithmetic operation of image pixels, add() addition function, subtract() subtraction function, divide() division function, multiply() multiplication function
Deep Learning with Pytorch- A 60 Minute Blitz
银河麒麟server-V10配置镜像源
Couldn't load this key (openssh ssh-2 private key (old PEM format))
Row column (vertical and horizontal table) conversion of SQL
小程序手持弹幕的原理及实现(uni-app)
Cftpconnection:: getfile() download FTP server files and related parameter descriptions
What kind of experience is it to develop a "grandson" who will call himself "Grandpa"?
2021-10-20
Opencv learning notes-day6-7 (scroll bar operation demonstration is used to adjust image brightness and contrast, and createtrackbar() creates a scroll bar function)
Golang magic code
Research on lg1403 divisor