运行yolov5出现问题AttributeError: Cant get attribute SPPF on module models.common

运行yolov5下面Tags5的代码出现问题:
AttributeError: Cant get attribute SPPF on module models.common from e:\pyWorkSpace\yolov5-5.0\models\common.py

遇到这个问题提之后我在百度查了很久,都没找到答案。

最后我在某个地方的评论区找到了某个大佬的回复,最终得到解决方案,特此公布给遇到同样问题的人。

我这边运行的是yolov5下面Tags5的代码,出现了这个报错:
AttributeError: Cant get attribute SPPF on module models.common from e:\pyWorkSpace\yolov5-5.0\models\common.py

解决方案是:去Tags6里面的model/common.py里面去找到这个SPPF的类,把它拷过来到你这个Tags5的model/common.py里面,这样你的代码就也有这个类了,还要引入一个warnings包就行了!

有的同学找不到SPPF这个类,那我现在直接粘贴在这里,你们只需要复制到你们的common.py里面即可,记得把import warnings放在上面去:

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 = Co
评论 40
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值