找到utils的loss.py文件,找到下面两行
ctrl f搜索anchors = self.anchors[i],换成anchors, shape = self.anchors[i], p[i].shape
ctrl f 搜索indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) 换成indices.append((b, a, gj.clamp_(0, shape[2] - 1), gi.clamp_(0, shape[3] - 1)))
就可以开始训练
indices.append((b, a, gj.clamp_(0, shape[2] - 1), gi.clamp_(0, shape[3] - 1))) # image, anchor, grid