Closed Luckycat518 closed 2 years ago
❔Question
你好,我在尝试采用carafe算子进行训练时,报错如下: yolo.py in parsemodel c2 = make_divisible(c2 gw, 8) TypeError: unsupported operand type(s) for : 'NoneType' and 'float' 请问该如何解决呢?是哪里没设置对吗?
Additional context
你发下命令 看看
❔Question
你好,我在尝试采用carafe算子进行训练时,报错如下: yolo.py in parsemodel c2 = make_divisible(c2 gw, 8) TypeError: unsupported operand type(s) for : 'NoneType' and 'float' 请问该如何解决呢?是哪里没设置对吗?
Additional context
你发下命令 看看
也可以先clone我新的代码 因为昨天进行了一次大更新
你好,我是基于您的代码对我的v6.0的common.py和yolo.py进行了修改。具体修改如下
在common.py中添加了如下内容: class CARAFE(nn.Module):
def __init__(self, c1, c2, kernel_size=3, up_factor=2):
super(CARAFE, self).__init__()
self.kernel_size = kernel_size
self.up_factor = up_factor
self.down = nn.Conv2d(c1, c1 // 4, 1)
self.encoder = nn.Conv2d(c1 // 4, self.up_factor ** 2 * self.kernel_size ** 2,
self.kernel_size, 1, self.kernel_size // 2)
self.out = nn.Conv2d(c1, c2, 1)
def forward(self, x):
N, C, H, W = x.size()
# N,C,H,W -> N,C,delta*H,delta*W
# kernel prediction module
kernel_tensor = self.down(x) # (N, Cm, H, W)
kernel_tensor = self.encoder(kernel_tensor) # (N, S^2 * Kup^2, H, W)
kernel_tensor = F.pixel_shuffle(kernel_tensor, self.up_factor) # (N, S^2 * Kup^2, H, W)->(N, Kup^2, S*H, S*W)
kernel_tensor = F.softmax(kernel_tensor, dim=1) # (N, Kup^2, S*H, S*W)
kernel_tensor = kernel_tensor.unfold(2, self.up_factor, step=self.up_factor) # (N, Kup^2, H, W*S, S)
kernel_tensor = kernel_tensor.unfold(3, self.up_factor, step=self.up_factor) # (N, Kup^2, H, W, S, S)
kernel_tensor = kernel_tensor.reshape(N, self.kernel_size ** 2, H, W, self.up_factor ** 2) # (N, Kup^2, H, W, S^2)
kernel_tensor = kernel_tensor.permute(0, 2, 3, 1, 4) # (N, H, W, Kup^2, S^2)
# content-aware reassembly module
# tensor.unfold: dim, size, step
x = F.pad(x, pad=(self.kernel_size // 2, self.kernel_size // 2,
self.kernel_size // 2, self.kernel_size // 2),
mode='constant', value=0) # (N, C, H+Kup//2+Kup//2, W+Kup//2+Kup//2)
x = x.unfold(2, self.kernel_size, step=1) # (N, C, H, W+Kup//2+Kup//2, Kup)
x = x.unfold(3, self.kernel_size, step=1) # (N, C, H, W, Kup, Kup)
x = x.reshape(N, C, H, W, -1) # (N, C, H, W, Kup^2)
x = x.permute(0, 2, 3, 1, 4) # (N, H, W, C, Kup^2)
out_tensor = torch.matmul(x, kernel_tensor) # (N, H, W, C, S^2)
out_tensor = out_tensor.reshape(N, H, W, -1)
out_tensor = out_tensor.permute(0, 3, 1, 2)
out_tensor = F.pixel_shuffle(out_tensor, self.up_factor)
out_tensor = self.out(out_tensor)
#print("up shape:",out_tensor.shape)
return out_tensor
在yolo.py中添加了CARAFE,修改如下: if m in [Conv, GhostConv, Bottleneck, GhostBottleneck, SPP, SPPF, GSConv, DWConv, CARAFE, MixConv2d, Focus, CrossConv, BottleneckCSP, C3, C3TR, C3STR, C3SPP, C3Ghost, CBAM, Conv_maxpool, ShuffleNetV2_InvertedResidual......
运行的具体指令如下: python train.py --weights weights/yolov5l.pt --cfg models/ablation_experimental_wgq/yolov5lCBAM-SwinTrans-DWconv-Decoupledhead-CARAFE.yaml --data data/Ws.yaml --epoch 300 --batch-size 8 --img 608 --nohalf --device '0'
grey_questionQuestion
你好,我在尝试采用carafe算子进行训练时,报错如下: yolo.py in parsemodel c2 = make_divisible(c2 gw, 8) TypeError: unsupported operand type(s) for : 'NoneType' and 'float' 请问该如何解决呢?是哪里没设置对吗?
Additional context
你发下命令 看看
也可以先clone我新的代码 因为昨天进行了一次大更新
好的,我看看,您有空也可以看看我结合您代码进行的更改是否存在问题。即使不结合trans,仅在yolov5-6.0.yaml中基于上述修改替换CARAFE算子依然报上述错误“: yolo.py in parsemodel c2 = make_divisible(c2 gw, 8) TypeError: unsupported operand type(s) for : 'NoneType' and 'float' ”
grey_questionQuestion
你好,我在尝试采用carafe算子进行训练时,报错如下: yolo.py in parsemodel c2 = make_divisible(c2 gw, 8) TypeError: unsupported operand type(s) for : 'NoneType' and 'float' 请问该如何解决呢?是哪里没设置对吗?
Additional context
你发下命令 看看
也可以先clone我新的代码 因为昨天进行了一次大更新
clone您新的代码并在您的文件夹下运行指令“python train.py --weights weights/yolov5s.pt --cfg models/yolov5s-carafe.yaml --data data/Weld2009.yaml --epoch 300 --batch-size 8 --img 608 --device '0' --name l-Cara”后报错如下“File "train.py", line 416, in train loss, loss_items = compute_loss(pred, targets.to(device)) # loss scaled by batch_size File "/home/imcm/code/wanggq/yolov5research-master/utils/loss.py", line 221, in call pxy, pwh, , pcls = pi[b, a, gj, gi].tensor_split((2, 4, 5), dim=1) # target-subset of predictions AttributeError: 'Tensor' object has no attribute 'tensor_split' ”
grey_questionQuestion
你好,我在尝试采用carafe算子进行训练时,报错如下: yolo.py in parsemodel c2 = make_divisible(c2 gw, 8) TypeError: unsupported operand type(s) for : 'NoneType' and 'float' 请问该如何解决呢?是哪里没设置对吗?
Additional context
你发下命令 看看
也可以先clone我新的代码 因为昨天进行了一次大更新
clone您新的代码并在您的文件夹下运行指令“python train.py --weights weights/yolov5s.pt --cfg models/yolov5s-carafe.yaml --data data/Weld2009.yaml --epoch 300 --batch-size 8 --img 608 --device '0' --name l-Cara”后报错如下“File "train.py", line 416, in train loss, loss_items = compute_loss(pred, targets.to(device)) # loss scaled by batch_size File "/home/imcm/code/wanggq/yolov5research-master/utils/loss.py", line 221, in call pxy, pwh, , pcls = pi[b, a, gj, gi].tensor_split((2, 4, 5), dim=1) # target-subset of predictions AttributeError: 'Tensor' object has no attribute 'tensor_split' ”
好的 今天更新 不过我先测下yolov7的结构
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
❔Question
你好,我在尝试采用carafe算子进行训练时,报错如下: yolo.py in parsemodel c2 = make_divisible(c2 gw, 8) TypeError: unsupported operand type(s) for : 'NoneType' and 'float' 请问该如何解决呢?是哪里没设置对吗?
Additional context