当前位置:网站首页>【解决问题】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton
【解决问题】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton
2022-07-31 05:16:00 【王大队长】
在运行yolov5的时候报错:
一、错误1
Can't get attribute 'SPPF' on <module 'models.common' from 'D:\\Pycharm\\Code\\yolov5-5.0\\models\\common.py'>
没有找到SPPF属性
解决方法:
你可以去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 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))
将这个复制到对应的类就行了。
二、 错误2
解决完上一个问题后又报了一个错误:
RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton
解决方案:
下载:
https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt
替换默认下载的yolov5s.pt,因为默认下载的是V6.1的
替换后,在运行 detect.py就OK了
参考资料:
边栏推荐
猜你喜欢

MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案

Gradle sync failed: Uninitialized object exists on backward branch 142

Tencent Cloud GPU Desktop Server Driver Installation

flutter 混合开发 module 依赖
![[Ubuntu20.04 installs MySQL and MySQL-workbench visualization tool]](/img/3d/1b65fb33bfbf22da8243df1ab33ed5.png)
[Ubuntu20.04 installs MySQL and MySQL-workbench visualization tool]

qt:cannot open C:\Users\XX\AppData\Local\Temp\main.obj.15576.16.jom for write

Powershell中UTF-8环境中文乱码解决办法

腾讯云GPU桌面服务器驱动安装

Understanding of js arrays

VS connects to MYSQL through ODBC (2)
随机推荐
cocoscreator 显示刘海内容
function in js
understand js operators
CMOS管原理,及其在推挽电路中的应用
npm WARN config global `--global`, `--local` are deprecated. Use `--location solution
Tencent Cloud GPU Desktop Server Driver Installation
The browser looks for events bound or listened to by js
UiBot存在已打开的MicrosoftEdge浏览器,无法执行安装
Markdown 帮助文档
Several forms of Attribute Changer
flutter arr 依赖
kotlin 插件更新到1.3.21
Attribute Changer的几种形态
Common JVM interview questions and answers
活体检测CDCN学习笔记
场效应管 | N-mos内部结构详解
podspec自动化升级脚本
sql 外键约束【表关系绑定】
cocos2d-x-3.2 image graying effect
Nmap的下载与安装