yolov5报错:AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘E:\\All_in\\

解决办法:根据报错信息,找到common.py

AttributeError: Can't get attribute 'SPPF' on <module 'models.common' from 'E:\\All_in\\新建文件夹\\yolo_double\\yolov5_stereo_Pro\\models\\common.py'>

在spp上面添加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)

之后warnings会被标红,选中点击  导入‘warnings’

继续报错:

RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton dimension 3

解决方案:

下载:
https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt
替换默认下载的yolov5s.pt,因为默认下载的是V6.1的
替换后,在运行 detect.py就OK了

猜你喜欢

转载自blog.csdn.net/qq_53545309/article/details/130046717
今日推荐