【计算机视觉】YOLOv5s目标检测深度学习模型搭建中所遇到的问题

目录

1、pip install -r requirements.txt问题

 2、错误:pycharm终端提示"无法加载文件 C:\xxxx\profile.ps1,因为在此系统上禁止运行脚本......"

3、错误:RuntimeError: result type Float can‘t be cast to the desired output type __int64

 4、错误:RuntimeError:CUDA out of memory

 5、错误:OSError:[WinError 1455]页面文件太小,无法完成操作。

6、错误:YOLO UserWarning: torch.meshgrid: in an upcoming release,return _VF.meshgrid(tensors, **kwargs) #type: ignore[attr-defined]......

7、pycharm找不到conda可执行文件怎么办

 8、YOLOv5连接摄像头失败


1、pip install -r requirements.txt问题

 解决方法:修改镜像源为国内,eg:清华/阿里云/豆瓣,以清华镜像为例, 临时修改:加参数-i和镜像地址

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/

 相关资料:

1、requirements.txt文件

     python项目中必须包含一个 requirements.txt 文件,用于记录所有依赖包及其精确的版本号。以便新环境部署。requirements.txt可以通过pip命令自动生成和安装。

2、生成requirements.txt文件

     PyCharm的Terminal端生成requirements.txt文件

pip freeze > requirements.txt

3、安装requirements.txt文件中的依赖包

     PyCharm的Terminal安装requirements.txt依赖包:

pip install -r requirements.txt

 2、错误:pycharm终端提示"无法加载文件 C:\xxxx\profile.ps1,因为在此系统上禁止运行脚本......"

  解决方法:使用管理远打开 windows powershell,运行以下内容

Set-ExecutionPolicy -ExecutionPolicy

RemoteSigned -Scope CurrentUser

 采用此方案后,可能会对本地某些脚本放行,存在安全问题,所以,运行此内容后,日常使用电脑浏览网页时需更加谨慎

3、错误:RuntimeError: result type Float can‘t be cast to the desired output type __int64

 在使用YOLOv5训练自己的数据集时,运行train.py时出现上述问题

  解决方法:因为新版本的torch无法自动执行此转换,故:

将loss.py中

gain = torch.ones(7, device=targets.device)

 更改为

gain = torch.ones(7, device=targets.device).long()

 4、错误:RuntimeError:CUDA out of memory

 由于每个人的电脑性能不同,所以输入图片的数量和工作的核心数也会不同,需要根据自身设备的实际情况进行配置,否则就会出现GPU显存溢出的报错如上图所示

 解决方法:修改train.py中的参数

parser.add_argument('--batch-size', type=int, default=8, help='total batch size for all GPUs')

parser.add_argument('--workers', type=int, default=8, help='maximum number of dataloader workers')

 5、错误:OSError:[WinError 1455]页面文件太小,无法完成操作。

 解决方法:可以根据如下的操作来修改,在utils路径下找到datasets.py这个文件,将里面的第81行里面的参数nw改完0就可以了

 

6、错误:YOLO UserWarning: torch.meshgrid: in an upcoming release,return _VF.meshgrid(tensors, **kwargs) #type: ignore[attr-defined]......

 解决方法:找到pyCharm所用的虚拟环境下的functional.py文件

根据具体错误情况找到functional的504行

return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]

 然后修改此代码为:

return _VF.meshgrid(tensors, **kwargs, indexing = 'ij') # type: ignore[attr-defined]

7、pycharm找不到conda可执行文件怎么办

  解决方法:找到conda/bin文件下面的conda.bt文件,把路径复制下来,粘贴到Conda可执行文件,点击加载环境,如下图所示:

 8、YOLOv5连接摄像头失败

 default值为0表示启用摄像头

parser.add_argument('--source', type=str, default='0', help='source')  # file/folder, 0 for webcam

 解决方法:修改代码

源代码:

if 'youtube.com/' in url or 'youtu.be/' in url:  # if source is YouTube video

修改后:

 if 'youtube.com/' in str(url) or 'youtu.be/' in str(url):  # if source is YouTube video

【纯小白】本文为本人搭建YOLOv5目标检测模型中所遇到的一系列问题及最终的解决方法的学习记录总结

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值