YOLOv5+Swin Transformer
本科生工科生cv改代码
本来做的7,但是7报错一直解决不了,我就试试5
1、先是第一个报错
TypeError: __init__() missing 1 required positional argument: 'c2'
解决:在yolo.py里
-
if m in {
-
Conv, GhostConv, Bottleneck, GhostBottleneck, SPP, SPPF, DWConv, MixConv2d, Focus, CrossConv,
-
BottleneckCSP, C3, C3TR, C3SPP, C3Ghost, nn.ConvTranspose2d, DWConvTranspose2d, C3x, C3STR}:
-
# add a C3STR at the end of the sentence(aran)
-
c1, c2 = ch[f], args[0]
-
if c2 != no: # if not output
-
c2 = make_divisible(c2 * gw, 8) # change 8 to 9
-
-
args = [c1, c2, *args[1:]]
-
if m in {BottleneckCSP, C3, C3TR, C3Ghost, C3x, C3STR}:# add a C3STR at the end of the sentence(aran)
-
args.insert(2, n) # number of repeats
2、
-
File "/root/yolov5_master/models/common.py", line 1315, in __init__
-
super().__init__(c1, c2, c2, n, shortcut, g, e)
-
TypeError: __init__() takes from 3 to 7 positional arguments but 8 were given
解决:common里删掉一个c2
-
class C3STR(C3):
-
# C3 module with SwinTransformerBlock()
-
def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5):
-
super().__init__(c1, c2, n, shortcut, g, e) # a c2 was deleted by aran
-
c_ = int(c2 * e)
-
num_heads = c_ // 32
-
self.m = SwinTransformerBlock(c_, c_, num_heads, n)
3、
NameError: name 'window_partition' is not defined
解决:应该加上window_partition 和 window_reverse, 加在common,具体位置是在芒果哥加在common的代码前面
-
def window_partition(x, window_size):
-
B, H, W, C = x.shape
-
x = x.view(B, H // window_size, window_size, W // window_size, window_size, C)
-
windows = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(-1, window_size, window_size, C)
-
return windows
-
-
-
def window_reverse(windows, window_size, H, W):
-
B = int(windows.shape[0] / (H * W / window_size / window_size))
-
x = windows.view(B, H // window_size, W // window_size, window_size, window_size, -1)
-
x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1)
-
return x
4、
NameError: name 'F' is not defined
解决:在common里面
import torch.nn.functional as F
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhgfkgcc
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
怎样阻止微信小程序自动打开
PHP中文网 06-13 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01