这里写自定义目录标题

  • 一、错误1
    • 解决方案1
  • 二、 错误2
    • 解决方案2:

一、错误1

Can't get attribute 'SPPF' on <module 'models.common' from 'D:\\Pycharm\\Code\\yolov5-5.0\\models\\common.py'>

解决方案1

你可以去github上,这儿我用的是YOLOv5.5的版本,就去Tags6里面的model/common.py里面去找到这个SPPF的类,把它拷过来到你这个Tags5的model/common.py里面,这样你的代码就也有这个类了,还要引入一个warnings包就行了


点开common.py文件

import warnings
class 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))

将这个复制到对应的类就行了。

二、 错误2

刚解决了上一个问题,结果又出现了问题,我也很崩溃,差了半天,也没有找到解决办法,最终,我找到了,哈哈,让我笑一会!!!下面看错误:

RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton

解决方案2:


注意看这两个是否对应:

因为我运行代码的是后模型没有下载下来,所以自己去github上下载的模型,然后出错了,就是模型错了,这儿给出地址:
https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt
下载到
如图同级目录下就行了,然后就可以运行了!

【解决问题】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton相关推荐

  1. 报错解决——RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton

    问题描述 RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dim ...

  2. The size of tensor a (4) must match the size of tensor b (3) at non-singletonThe size of

    报错: RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton 解决: ...

  3. The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimension 0 维度不匹配

    在导入一个png文件的时候,发现报这个错,源码如下,经过查询找到了两种解决方案. from PIL import Image from torchvision import transforms fr ...

  4. RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0—问题分析

    声明: 这里仅仅提供一个思路,暂时没有绝对正确通用的解决方案 作者:{ 墨理 } 感谢通过私信.评论交流,协力探讨解决问题的同学 UP .Penser 文章目录 探讨的 pytorch 报错信息如下 ...

  5. PyTorch 笔记(11)— Tensor内部存储结构(头信息区 Tensor,存储区 Storage)

    1. Tensor 内部存储结构 tensor 数据结构如下图所示,tensor 分为头信息区(Tensor)和存储区 (Storage),信息区主要保存着 Tensor 的形状(size).步长(s ...

  6. python中tensor与variable_NLP实战篇之tf2中tensor、variable、gradient、ops

    本文是基于tensorflow2.2.0版本,介绍了tf中变量.张量的概念,tf中梯度的计算方式和tensor相关的操作. 实战系列篇章中主要会分享,解决实际问题时的过程.遇到的问题或者使用的工具等等 ...

  7. CUDA编译器nvcc可能遇到:error: asm operand type size(8) does not match type/size implied by constraint ‘r‘

    0. 问题描述 该问题产生于我在ptcharm中试图用cupy加速numpy计算,进行一些简单但是繁琐的数据处理,这个问题和cupy关系不大,cupy只要照着nvcc -v给出的版本号对应着下载就ok ...

  8. Kernel size can‘t be greater than actual input size的解决方案

    报错信息:RuntimeError: Calculated padded input size per channel: (49). Kernel size: (64). Kernel size ca ...

  9. Pytorch踩坑: RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0.

    报错信息: RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 186 a ...

  10. python size和count_groupby 的妙用(注意size和count)

    Pandas的groupby()功能很强大,用好了可以方便的解决很多问题,在数据处理以及日常工作中经常能施展拳脚. 今天,我们一起来领略下groupby()的魅力吧. 首先,引入相关package: ...

最新文章

  1. Imageloader3-单例模式
  2. oracle汽车排量怎么写,这样的表中的数据怎样排量修改啊。
  3. 3.1_ 1_ 内存的基础知识
  4. 利用mongodb开发lbs应用实践【转】
  5. 图解TCPIP-传输层 TCP
  6. IT人士|不可不知的10个行业内幕
  7. javascript学习之数组的使用一 push pop shift unshift 方法
  8. 2012.4.20总结
  9. [原创]jQuery的this和$(this)
  10. uReport2报表工具的基础使用及注意事项
  11. matlab中信号叠加高斯噪声代码
  12. 百度竞价推广之关键词选择技巧
  13. CF 128A Statues
  14. Phyton安装MySQL驱动
  15. 3DLut表实现log视频的后期调色原理
  16. 计算机维修的入门知识
  17. 猜名次 C语言简单的实现
  18. 淘宝客运营推广技巧方法有哪些?
  19. C# DataView常见操作
  20. 数据库实验-触发器实验

热门文章

  1. GSM 第二代移动通信网络
  2. 稳态误差,超调与PID的关系
  3. SFP光模块高低温老化测试 高低温试验测试设备
  4. 京东、阿里:健康版图再博弈
  5. 信息学奥赛一本通 1293:买书 | OpenJudge NOI 2.6 6049:买书
  6. 极客时间 MySQL 字段
  7. 企业如何软件商业化? .
  8. android 计时器函数,Android Chronometer控件实现计时器函数详解
  9. 企业估值研究到底从何处着手?
  10. 杭州电子科技大学计算机学院复试细则,2020杭州电子科技大学计算机学院考研复试公告...