yolov5训练自己的数据集报错记录

        AttributeError: Can't get attribute 'SPPF' on

在项目的common.py下加入以下代码

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))

 yolov5训练自己的数据集报错记录_第1张图片

         RuntimeError: Given groups=1, weight of size [512, 1024, 1, 1], expected input[1, 512, 8, 8] to have 1024 channels, but got 512 channels instead

yolov5训练自己的数据集报错记录_第2张图片

 运行train.py文件时出现上面的错误,指定默认的模型yaml文件的路径地址

        AssertionError: Image Not Found 

yolov5训练自己的数据集报错记录_第3张图片 修改utils/datasets.py
按住ctrl+g快速定位到124行,
把p = str(Path(path).absolute())改成p = str(Path(path))
yolov5训练自己的数据集报错记录_第4张图片

        UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at

C:\cb\pytorch_1000000000000\work\aten\src\ATen\native\TensorShape.cpp:2228.)  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]

yolov5训练自己的数据集报错记录_第5张图片

 按照提示的路径打开functional.py,Ctrl+G快速定位到568行,修改为下图所示。yolov5训练自己的数据集报错记录_第6张图片

 

你可能感兴趣的:(yolov5,yolov5)