labelGo使用错误记录

labelGo使用错误记录

错误一

在这里插入图片描述

AttributeError: Can't get attribute 'SPPF' on <module 'models.common' from 'C:/Users/Gientech/Desktop/Gientech/biaozhu_tools/labelGo-Yolov5AutoLabelImg-master/libs\\models\\common.py'>

错误描述:我们的 models\common.py 文件里缺少 SPPF 属性

解决方案:model/common.py里面去找到这个SPPF的类,把它拷过来放到我们的的model/common.py里面,这样我们的代码就也有这个类了,还要引入一个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 = 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))

错误二

AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'

错误描述:属性错误,“Upsample”对象没有属性“recompute_scale_factor”

解决方案:我们找到我们出现报错路径文件,进入编辑页,找到对应的报错行(153~154行),将这两行注释掉,在后面加上如下代码:

return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners)

错误三

运行labalGo软件错误,报错内容如下:

AttributeError: partially initialized module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline' (most likely due to a circular import)

解决方案:重装cv2模块

pip uninstall opencv-python
pip uninstall opencv-contrib-python

pip install opencv-contrib-python
pip install opencv-python

错误四

在这里插入图片描述

RuntimeError: shape '[1, 3, 1, 1, 2]' is invalid for input of size 42336

这个是yolov5内容更新的问题,替换部分代码为yolov5最新的代码就可以解决了

解决方案: 将yolo.py文件重新替换为yolov5官方的yolo.py文件 。

  • ps:记得修改替换后的yolo.py文件里的包的前置文件名

错误五

在这里插入图片描述

ImportError: cannot import name 'LOGGER' from 'libs.detect_utils.general' (C:\Users\Gientech\Desktop\Gientech\biaozhu_tools\labelGo-Yolov5AutoLabelImg-master\libs\detect_utils\general.py)

这个问题是解决上一个问题后出现的,在作者的 Github 项目 Issues 中询问了跟我出现类似问题的一个前辈解决的

解决方案: 在general.py里面加入报错的函数,之后就能正常进行自动标注了。

猜你喜欢

转载自blog.csdn.net/etrospect/article/details/125937353