bubbliiiing / yolov7-pytorch

这是一个yolov7的库,可以用于训练自己的数据集。
GNU General Public License v3.0
861 stars 150 forks source link

请问 我在训练时提示 result type Float can't be cast to the desired output type __int64 是什么原因? #41

Open SUNHAOH opened 1 year ago

SUNHAOH commented 1 year ago

请问 我在训练时提示 result type Float can't be cast to the desired output type __int64 是什么原因?

image

zy597337447 commented 1 year ago

请问 我在训练时提示 result type Float can't be cast to the desired output type __int64 是什么原因?

image

我在yolov5中遇到过这个问题,你可以贴一下你的torch和cuda版本,,我觉得和这个有关。我torch1.7.0和cuda11.0没问题。

bubbliiiing commented 1 year ago

嗯是

chunguangqu commented 1 year ago

解决方法步骤:

  1. 将yolo_training.py文件中的451行的【anchors_i= torch.from_numpy(self.anchors[i] / self.stride[i]).type_as(predictions[i])】修改为【anchors_i,shape = torch.from_numpy(self.anchors[i] / self.stride[i]).type_as(predictions[i]),predictions[i].shape】
  2. 将yolotraining.py文件中的513行的【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)))】
  3. 完成以上两步即可。
f1owkang commented 1 year ago

解决方法步骤:

  1. 将yolo_training.py文件中的451行的【anchors_i= torch.from_numpy(self.anchors[i] / self.stride[i]).type_as(predictions[i])】修改为【anchors_i,shape = torch.from_numpy(self.anchors[i] / self.stride[i]).type_as(predictions[i]),predictions[i].shape】
  2. 将yolotraining.py文件中的513行的【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)))】
  3. 完成以上两步即可。

感谢大佬

bubbliiiing commented 1 year ago

我也处理一下哈。