使用高版本torch训练yolo-fastV2报错result type float can‘t be cast to the desired output type long int

版本

- pytorch=1.12.0=py3.9_cuda11.6_cudnn8.3.2_0
- pytorch-mutex=1.0=cuda
- torchaudio=0.12.0=py39_cu116
- torchvision=0.13.0=py39_cu116

报错

  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

使用高版本torch训练yolo-fastV2报错result type float can‘t be cast to the desired output type long int_第1张图片

解决方案

RuntimeError: result type Float can't be cast to the desired output type long int · Issue #35 · WongKinYiu/yolov7 · GitHub

使用高版本torch训练yolo-fastV2报错result type float can‘t be cast to the desired output type long int_第2张图片

 

在loss.py文件下修改

gain = torch.ones(7, device = device)

替换为

gain = torch.ones(7, device = device).long()

你可能感兴趣的:(深度学习,深度学习,目标检测,人工智能)