当前位置:网站首页>【解决问题】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了
参考资料:
边栏推荐
猜你喜欢
![[swagger close] The production environment closes the swagger method](/img/43/17be22626ba152b33beaf03f92fbec.png)
[swagger close] The production environment closes the swagger method

softmax函数详解

The feign call fails, JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r

朴素贝叶斯文本分类(代码实现)

MySQL高级SQL语句(二)

This in js points to the prototype object

The browser looks for events bound or listened to by js

jenkins +miniprogram-ci 一键上传微信小程序

npm WARN config global `--global`, `--local` are deprecated. Use `--location solution

np.fliplr与np.flipud
随机推荐
SQLite 查询表中每天插入的数量
sql 添加 default 约束
浅谈对分布式模式下CAP的理解
ERROR Error: No module factory availabl at Object.PROJECT_CONFIG_JSON_NOT_VALID_OR_NOT_EXIST ‘Error
The server time zone value ‘й‘ is unrecognized or represents more than one time zone
How MySQL - depots table?A look at will understand
C语言 | 获取字符串里逗号间隔的内容
function in js
random.randint函数用法
cocos2d-x-3.2图片灰化效果
quick-3.5 ActionTimeline的setLastFrameCallFunc调用会崩溃问题
微信小程序启动优化
Attribute Changer的几种形态
mysql common commands
Using IIS10 to build an asp website in win11
WeChat applet source code acquisition and decompilation method
[uiautomation] Get WeChat friend list (stored in txt)
MySql to create data tables
unicloud 云开发记录
JS写一段代码,判断一个字符串中出现次数最多的字符串,并统计出现的次数JS