训练yolo的时候报错,debug发现,在yolo.py文件夹里面,具体在这个位置:

x = m(x),观察哪一行的x进行的错误,找到报错模块。
本问题具体体现在步长为2的Conv,卷积后得到的尺寸,经过upsampling后无法回到原来的尺寸。
所以更改Concat就可以了,找到common.py
class Concat(nn.Module):
# Concatenate a list of tensors along dimension
def __init__(self, dimension=1):
super(Concat, self).__init__()
self.d = dimension
def forward(self, x):
# 确保x是一个列表
assert isinstance(x, list), 'Concat expects a list of tensors'
# 找出最大的空间维度
max_h = max(tensor.size(-2) for tensor in x)
max_w = max(tensor.size(-1) for tensor in x)
# 调整每个张量的大小
resized_tensors = []
for tensor in x:
if tensor.size(-2) != max_h or tensor.size(-1) != max_w:
resized = F.interpolate(tensor, size=(max_h, max_w), mode='bilinear'

最低0.47元/天 解锁文章
6777





