运行YOLOV5出现报错AttributeError: Can't get attribute 'SPPF'

问题

AttributeError: Can't get attribute 'SPPF'

运行yolov5下面Tags5的代码出现问题:
AttributeError: Cant get attribute SPPF on module models

搞了很久,最终得到解决方案,特此公布给遇到同样问题的人。

运行的是yolov5 Tags5的代码,出现了这个报错:

解决方案

  1. 到Tags6里面的model/common.py里面去找到这个SPPF的类,把它拷过来到Tags5的model/common.py里面,这样你的代码就也有这个类了,还要引入一个warnings

如果找不到SPPF这个类,那我现在直接粘贴在这里,你们只需要复制到你们的common.py里面即可,记得把import warnings放在上面去

import warningsclass SPPF(nn.Module):# Spatial Pyramid Pooling - Fast (SPPF) layer for YOLOv5 by Glenn Jocherdef __init__(self, c1, c2, k=5):  # equivalent to SPP(k=(5, 9, 13))super().__init__()c_ = c1 // 2  # hidden channelsself.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() warningy1 = self.m(x)y2 = self.m(y1)return self.cv2(torch.cat([x, y1, y2, self.m(y2)], 1))

AttributeError: Cant get attribute SPPF on module models相关推荐

  1. 解决YOLO v5的AttributeError: Can‘t get attribute SPPF on module models. common的问题

    ** 目录 一.问题描述 二.解决方法 三.参考来源 一.问题描述 在运行YOLOv5的detect.py程序时候,出现了以下错误提示AttributeError: Can't get attribu ...

  2. AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘D:\\ModelTest\\yolov5-5

    记录一下这个错误: AttributeError: Can't get attribute 'SPPF' on <module 'models.common' from 'D:\\ModelTe ...

  3. 运行yolov5-5.0出现AttributeError: Can‘t get attribute ‘SPPF‘ 正确解决方法

    运行yolov5旧版本代码(比如5.0版本)出现错误 AttributeError: Can't get attribute 'SPPF' on <module 'models.common' ...

  4. yolov5_6.0以上的模型和6.0以下的模型不兼容问题。Can‘t get attribute ‘SPPF‘

    yolov5_6.0以上的模型和6.0以下的模型不兼容问题: [完全解决yolov5权重6.0与之前版本不兼容问题]Can't get attribute 'SPPF' on emodule 'mod ...

  5. AttributeError: Can‘t get attribute ‘SPPF‘

    1.环境:训练自己的YOLOv5-5.0模型. 2.报错原因:预训练权重的版本与源码框架不匹配,在下面的网站中找到对应的YOLOv5-5.0的版本: Releases · ultralytics/yo ...

  6. AttributeError: Can‘t get attribute ‘Net‘ on module ‘__main__‘

    在使用pytorch深度学习框架的时候,我们加载预先训练好的完整pkl模型时,如果报错: AttributeError: Can't get attribute 'Net' on module '__ ...

  7. Can't get attribute '_rebuild_tensor_v2' on module 'torch._utils'

    Can't get attribute '_rebuild_tensor_v2' on <module 'torch._utils' pip uninstall torch 会把0.1.2版本也 ...

  8. gensim : AttributeError: The vocab attribute was removed from KeyedVector in Gensim 4.0.0.

    gensim报错:AttributeError: The vocab attribute was removed from KeyedVector in Gensim 4.0.0. Use Keyed ...

  9. openpyxl:AttributeError: ‘MergedCell’ object attribute ‘value’ is read-only

    openpyxl:AttributeError: 'MergedCell' object attribute 'value' is read-only 使用openpyxl向excel写入数据时,报了 ...

最新文章

  1. UVA 11752 超级幂
  2. 使用resnet训练CIFAR10
  3. 以python入门教程新世界-Python打开新世界的大门-入门篇1
  4. C#委托及事件 详解(讲得比较透彻)
  5. Python下opencv使用笔记系列
  6. Sicily 1155. Can I Post the lette
  7. 苹果CMS V10 播放记录_苹果cms整合dplayer播放器增加记忆+P2P播放+自动下一集
  8. C++对象产生和销毁的顺序
  9. IE8 -- 此网页上的问题导致 Internet explore 关闭并重新打开该选项卡
  10. 10月24日杨力祥老师谈话有感[转]
  11. 18位华人当选2022年加拿大工程院院士!京东副总裁梅涛入选!
  12. mysql 启动 配置文件,mysql启动服务配置文件编写
  13. vb连接mysql教程视频_VB连接MYSQL数据的方法
  14. 【Python练习】乌龟吃鱼小游戏
  15. c语言函数大全表格形式,C语言函数大全[表格形式].doc
  16. 暴露在公网环境下主机的安全防护
  17. CC3200使用MQTT协议连接Onenet平台实践
  18. 思考如何概括“技术美术”(Technical Artist)的职责
  19. 8、springboot-获取客户端Ip地址
  20. 数据库原理作业3 — JMU

热门文章

  1. 读书:历史 -- 海上丝绸之路
  2. 简单protobuf
  3. 下载安装 binary editor
  4. (一)七种AOP实现方法
  5. SQL SERVER的锁机制(三)——概述(锁与事务隔离级别)
  6. C++入门经典-例6.14-通过指针连接两个字符数组
  7. 大数的减法函数--c语言
  8. cocoaPods安装、更新第三方库
  9. C# Windows CE使用小技巧实例
  10. 启用IIS的Gzip压缩 【转】