当前位置:网站首页>目标检测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'
:下一次运行结果是否覆盖上一次的结果。
边栏推荐
- Distributed things
- Do you want the dialog box that pops up from the click?
- Solution to the eighth training competition of 2020 Provincial Games
- Flutter 0001, environment configuration
- Terminal -- Zsh of terminal three swordsmen
- Cronexpression expression explanation and cases
- 桂林 稳健医疗收购桂林乳胶100%股权 填补乳胶产品线空白
- Deep Learning with Pytorch- A 60 Minute Blitz
- [cmake] make command cannot be executed normally
- 2020-11-02
猜你喜欢
Mysq database remote connection error, remote connection is not allowed
小程序手持弹幕的原理及实现(uni-app)
Numpy (data type)
Microsoft. Bcl. Async usage summary -- in Net framework 4.5 project Net framework version 4.5 and above can use async/await asynchronous feature in C 5
Applet learning path 2 - event binding
Find the number that appears only once in the array
Using appbarlayout to realize secondary ceiling function
Abstract factory pattern
Tutorial for beginners of small programs day01
仿照微信Oauth2.0接入方案
随机推荐
Why won't gold depreciate???
Express の post request
asdsadadsad
Tclistener server and tcpclient client
Cb/s Architecture - Implementation Based on cef3+mfc
Dart asynchronous task
Duplicate entry '2' for key 'primary appears in JPA‘
Use V-IF with V-for
Deep Learning with Pytorch- neural network
4. use ibinder interface flexibly for short-range communication
MySQL-- Entity Framework Code First(EF Code First)
Flutter 0001, environment configuration
List set export excel table
Distributed session
Metasploit practice - SSH brute force cracking process
Small program learning path 1 - getting to know small programs
Opencv learning notes-day5 (arithmetic operation of image pixels, add() addition function, subtract() subtraction function, divide() division function, multiply() multiplication function
Talk about the job experience of kotlin cooperation process
Applet learning path 2 - event binding
Talk about how the kotlin collaboration process establishes structured concurrency