Skip to content

Conversation

@ItzDerock
Copy link

This PR re-implements the patch done in ultralytics/yolov5 pr 8067 to fix this error when using torch 1.12

reimplements ultralytics/yolov5 pr #88067
RuntimeError: result type Float can't be cast to the desired output type long int
@ItzDerock
Copy link
Author

fixes #270

@RainYQ
Copy link

RainYQ commented Dec 7, 2022

for torch == 1.13.0

just fix it

utils/loss.py

-> 130
gain = torch.ones(6, device=targets.device, dtype=torch.long) # normalized to gridspace gain
-> 138
gain[2:] = torch.tensor(p[i].shape, dtype=torch.long)[[3, 2, 3, 2]] # xyxy gain
-> 144
at = torch.arange(na, device=targets.device).view(na, 1).repeat(1, nt) # anchor tensor, same as .repeat_interleave(nt)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants