运行YOLOv5检测模型识别出现的问题

一、下载YOLOv5源码
网址:https://github.com/ultralytics/yolov5/tree/v5.0
下载的版本:V5.0
问题1:要把配置好的pytorch环境用上
描述:主要是配置环境为:在这里插入图片描述
操作步骤:file->settings->project->python interpreter
在这里插入图片描述
然后点击apply->ok.

问题2:发现安装库的时候pip指令不行
解决方法:https://zhuanlan.zhihu.com/p/126669852
参考以上博主的解决方法就可以解决了,要下载一个离线的VS tools

问题3:package requirement 'opencv-4.1.2’is not satisfied
解决方法:pip install python-opencv
原因:pycharm库里OpenCV不叫cv2

问题4:package requirement ‘pycocotools’ is not satisfied
解决方法:pip install pycocotools

问题5:ERROR: Invalid requirement: “'colorama”
解决方法:pip install colorama

问题6:AttributeError: Can’t get attribute ‘SPPF’ on <module ‘models.common’ from ’
解决方法:https://blog.csdn.net/inaner/article/details/121177939

import warnings
class SPPF(nn.Module):
    # Spatial Pyramid Pooling - Fast (SPPF) layer for YOLOv5 by Glenn Jocher
    def __init__(self, c1, c2, k=5):  # equivalent to SPP(k=(5, 9, 13))
        super().__init__()
        c_ = c1 // 2  # hidden channels
        self.cv1 = Conv(c1, c_, 1, 1)
        self.cv2 = Conv(c_ * 4, c2, 1, 1)
        self.m = nn.MaxPool2d(kernel_size=k, stride=1, padding=k // 2)
 
    def forward(self, x):
        x = self.cv1(x)
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')  # suppress torch 1.9.0 max_pool2d() warning
            y1 = self.m(x)
            y2 = self.m(y1)
            return self.cv2(torch.cat([x, y1, y2, self.m(y2)], 1))

在moudle得到commom.py里修改

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值