yolov5/v7训练报错build target indices.append((b, a, gj.clamp
torch 1.12.0运行yolov5 6.0版本时报错:
build target indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) # image, anchor, grid indices runtimeerror: result type float can’t be cast to the desired output type long int
解决方案
RuntimeError: result type Float can’t be cast to the desired output type long int · Issue #35 · WongKinYiu/yolov7 · GitHub
在loss.py文件下修改
gain = torch.ones(7, device = device)
替换为
gain = torch.ones(7, device = device).long()
参考: