在loss.py中用ctrl+F 找到 gain[2:] = torch.tensor(p[i].shape)[[3, 2, 3, 2]] # xyxy gain 这一行
在其上面添加 shape = p[i].shape 如上图所添加的一样。
之后找到 indices.append 大概168行左右 换成下面的样子
indices.append((b, a, gj.clamp_(0, shape[2] - 1), gi.clamp_(0, shape[3] - 1))) # image, anchor, grid indices 就ok了
和yolov5解决思路一样 但具体位置不一样