当前位置:网站首页>【解决问题】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了
参考资料:
边栏推荐
- quick-3.5 无法正常显示有混合纹理的csb文件
- Attribute Changer的几种形态
- cocos2d-x-3.2 image graying effect
- MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
- CMOS管原理,及其在推挽电路中的应用
- cocos2d-x-3.2 不能混合颜色修改
- How MySQL - depots table?A look at will understand
- UiBot存在已打开的MicrosoftEdge浏览器,无法执行安装
- sql add default constraint
- qt:cannot open C:\Users\XX\AppData\Local\Temp\main.obj.15576.16.jom for write
猜你喜欢
随机推荐
浏览器查找js绑定或者监听的事件
js中的全局作用域与函数作用域
Understanding of js arrays
cocos2d-x-3.2 不能混合颜色修改
quick-3.6源码修改纪录
[Cloud native] Simple introduction and use of microservice Nacos
Flutter mixed development module dependencies
QT VS中双击ui文件无法打开的问题
Hyper-V新建虚拟机注意事项
CMOS管原理,及其在推挽电路中的应用
朴素贝叶斯文本分类(代码实现)
浅谈对分布式模式下CAP的理解
VTK:Could not locate vtkTextRenderer object.
this指向问题
[Ubuntu20.04 installs MySQL and MySQL-workbench visualization tool]
活体检测FaceBagNet阅读笔记
[Cloud Native] What should I do if SQL (and stored procedures) run too slowly?
C语言 | 获取字符串里逗号间隔的内容
js中的对象与函数的理解
Markdown help documentation