当前位置:网站首页>【解决问题】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了
参考资料:
边栏推荐
- Understanding SSRF, this article is enough
- cocos create EditBox 输入文字被刘海屏遮挡修改
- Judgment of database in SQL injection
- MySQL compressed package installation, fool teaching
- Xiaomi mobile phone SMS location service activation failed
- sqlite 查看表结构 android.database.sqlite.SQLiteException: table splitTable has no column named
- Hyper-V新建虚拟机注意事项
- 为数学而歌之伯努利家族
- VS2017 connects to MYSQL
- [windows]--- SQL Server 2008 super detailed installation tutorial
猜你喜欢

如何修改数据库密码
![[swagger close] The production environment closes the swagger method](/img/43/17be22626ba152b33beaf03f92fbec.png)
[swagger close] The production environment closes the swagger method
![[Ubuntu20.04 installs MySQL and MySQL-workbench visualization tool]](/img/3d/1b65fb33bfbf22da8243df1ab33ed5.png)
[Ubuntu20.04 installs MySQL and MySQL-workbench visualization tool]

flutter arr dependencies

Xiaomi mobile phone SMS location service activation failed

DC-CDN学习笔记

2021美赛C题M奖思路

Using IIS10 to build an asp website in win11

flutter 混合开发 module 依赖

VS通过ODBC连接MYSQL(一)
随机推荐
动态规划(一)| 斐波那契数列和归递
function in js
朴素贝叶斯文本分类(代码实现)
Principle analysis of famous website msdn.itellyou.cn
The browser looks for events bound or listened to by js
Understanding of js arrays
cocos2d-x-3.2 不能混合颜色修改
Talking about the understanding of CAP in distributed mode
Understanding SSRF, this article is enough
Podspec verification dependency error problem pod lib lint , need to specify the source
break and continue exit in js
Android software security and reverse analysis reading notes
UiBot存在已打开的MicrosoftEdge浏览器,无法执行安装
A simple bash to powershell case
Podspec automatic upgrade script
ERROR Error: No module factory availabl at Object.PROJECT_CONFIG_JSON_NOT_VALID_OR_NOT_EXIST ‘Error
cocos2d-x-3.2 Physics
Using IIS10 to build an asp website in win11
对js的数组的理解
configure:error no SDL library found