首页 > 其他分享 >训练yolov5模型时报错AttributeError: Can't get attribute 'SPPF' on module 'models.common

训练yolov5模型时报错AttributeError: Can't get attribute 'SPPF' on module 'models.common

时间:2023-05-14 12:36:14浏览次数:38  
标签:__ yolov5 SPPF warnings self get y1 y2

解决方法

打开 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))
import warnings  置顶


标签:__,yolov5,SPPF,warnings,self,get,y1,y2
From: https://www.cnblogs.com/dzwj/p/17399051.html

相关文章

  • 解决docker search influxdb 报错Error response from daemon: Get "https://index.do
    解决dockersearchinfluxdb报错Errorresponsefromdaemon:Get"https://index.docker.io/v1/search?q=influxdb&n=25":dialtcp:lookupindex.docker.ioon192.168.12.2:53:readudp192.168.12.128:39189->192.168.12.2:53:i/otimeoutdockerpull&......
  • PowerShell-get-counter-算机上找不到任何性能计数器集: 错误 800007d0
    #已经解决了,感谢国外大神的解答:https://techcommunity.microsoft.com/t5/windows-powershell/get-counter-could-not-find-any-performance-counter-sets-on-the/m-p/3811330/thread-id/6430#M6433 获取计数器:在192.168.50.101计算机上找不到任何性能计数器集:错误80000 ......
  • 关于C语言getchar()的作用理解
    让我们先看一个程序#include<stdio.h>intmain(){charch[100];fgets(ch,10,stdin);//用标准输入设备输入fputs(ch,stdout);//用标准输出设备输出return0;}这个时候,我们输入超过10个字符,只读前十个字符;不超过10个字符,输入字符时,输出会多输出一行,说明\n也......
  • target method '%s' found on bean target class '%s', but not found in any interf
    targetmethod'%s'foundonbeantargetclass'%s',butnotfoundinanyinterface(s)forbeanJDKproxy.Eitherpullthemethoduptoaninterfaceorswitchtosubclass(CGLIB)proxiesbysettingproxy-target-class/proxyTargetClass......
  • 解决 apt-get Could not get lock /var/lib/dpkg/lock-frontend , it is held by proc
    问题: 用lsof命令看看这几个文件是被哪个进程锁住的啊,然后先杀掉那几个进程。不杀进程,直接移除文件的话,可能仍有其他进程在操作apt的缓存,多个命令同时写apt缓存很容易发生冲突sudolsof/var/lib/dpkg/lock-frontend 杀掉进程kill-98798 ......
  • getPhysicalNumberOfCells读取excel表格数据,清除空行后代码仍然识别空行,(已解决)
     表格只有几十行数据,但是getPhysicalNumberOfCells读取时还有800多行,原因在于之前把表格数据拓展到了800行,清除数据时,表格的样式为更改,可以尝试使用格式刷复制空行格式刷到错误空行上但是我试了没有用,反而还多了几十行,然后尝试用代码判断空行,只有格式没有数据的空行全部删除,......
  • 判断软件的闲置时间GetLastInputInfo
    //GetLastInputInfo是检测系统输入的,应用到某个程序中不合适!此问题有二种解法来监控输入消息:1.用线程级HOOK,钩上MOUSEHOOK与KEYBOARDHOOK2.在Application.OnMessage中做处理显然,用第2种方法比较方便!众所周知,键盘与鼠标消息都是队列消息,需要经过消息队列后经过一些处理,再发往......
  • nginx 10061: No connection could be made because the target machine actively ref
    nginx10061:Noconnectioncouldbemadebecausethetargetmachineactivelyrefusedit nginx重载配置一直有些不生效,查看后,发现nginx有4个,全部关闭掉,再重开nginx,正常了nginx.exe-squit,可以把正常的nginx退出掉,其他的nginx,任务管理器强制关闭掉startnginx开启nginx,o......
  • 从0到1发布自己的Nuget包
    Nuget1、创建示例项目--创建文件夹EasyUtilityCoremdEasyUtilityCorecdEasyUtilityCore​--新建EasyUtilityCore类库dotnetnewclasslib新建扩展StringExtensionusingSystem;​namespaceEasyUtilityCore{publicstaticclassStringExtension{......
  • spring aop MethodSignature = (MethodSignature) joinPoint.getSignature();
    MethodSignaturesignature=(MethodSignature)joinPoint.getSignature();为什么这里可以转回为MethodSignatrue,官网上没有这么说,如果这里转换失败,那运行会报错,这是不允许的。必须找到调用这里的代码,看看这里的Signature 是怎么放进去的。网上找了好久没有找到相关知识......