运行YOLOv5出现报错找不到SPPF错误,进行解决AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from
yolov5
yolov5 - Ultralytics YOLOv8的前身,是一个用于目标检测、图像分割和图像分类任务的先进模型。
项目地址:https://gitcode.com/gh_mirrors/yo/yolov5
免费下载资源
·
运行YOLOv5时报错:AttributeError: Can't get attribute 'SPPF' on <module 'models.common' from 'D:\\PyCharmProject\\yolov5-5.0\\yolov5-5.0\\models\\common.py'>
解决办法如下:首先找到YOLOv5下的这个文件打开
打开文件往下翻找到class SPP这一行,我的是在166行,在这一行上面添加下面的程序添加class SPPF
class SPPF(nn.Module):
def __init__(self, c1, c2, k=5):
super().__init__()
c_ = c1 // 2
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')
y1 = self.m(x)
y2 = self.m(y1)
return self.cv2(torch.cat([x, y1, y2, self.m(y2)], 1))
如图所示:
再运行程序就不会报错啦。
GitHub 加速计划 / yo / yolov5
49.4 K
16.03 K
下载
yolov5 - Ultralytics YOLOv8的前身,是一个用于目标检测、图像分割和图像分类任务的先进模型。
最近提交(Master分支:2 个月前 )
79b7336f
* Update Integrations table
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* Update README.md
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* Update README.zh-CN.md
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
---------
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> 22 天前
94a62456
* fix: quad training
* fix: quad training in segmentation 24 天前
更多推荐
已为社区贡献4条内容
所有评论(0)