当前位置:网站首页>yolov5训练自己的数据集报错记录

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

2022-06-21 17:51:00 Scarlett2025

        AttributeError: Can't get attribute 'SPPF' on <module 'models.common' from 'E:\\my_yolov5-5.0\\models\\common.py'>

在项目的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))

 

         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

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

        AssertionError: Image Not Found 

 修改utils/datasets.py
按住ctrl+g快速定位到124行,
把p = str(Path(path).absolute())改成p = str(Path(path))

        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]

 按照提示的路径打开functional.py,Ctrl+G快速定位到568行,修改为下图所示。

 

原网站

版权声明
本文为[Scarlett2025]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Scarlett2025/article/details/125368930