Skip to content

fix: RuntimeError: result type Float can't be cast to the desired output type long int#271

Open
ItzDerock wants to merge 1 commit intoWongKinYiu:mainfrom
ItzDerock:main
Open

fix: RuntimeError: result type Float can't be cast to the desired output type long int#271
ItzDerock wants to merge 1 commit intoWongKinYiu:mainfrom
ItzDerock:main

Conversation

@ItzDerock
Copy link
Copy Markdown

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
Copy Markdown
Author

fixes #270

@RainYQ
Copy link
Copy Markdown

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