Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Training yields: RuntimeError: result type Float can't be cast to the desired output type long int #118

Open
bdubbs-clarifai opened this issue Oct 11, 2022 · 4 comments · May be fixed by #139

Comments

@bdubbs-clarifai
Copy link

I'm currently trying to train either yolov7 or v5 and I am getting the same error when I run the training script for both:
Traceback (most recent call last): File "train.py", line 695, in <module> main(opt) File "train.py", line 591, in main train(opt.hyp, opt, device, callbacks) File "train.py", line 376, in train loss, loss_items = compute_loss(pred, targets.to(device)) # loss scaled by batch_size File "/content/yoloair/utils/loss.py", line 123, in __call__ tcls, tbox, indices, anchors = self.build_targets(p, targets) # targets File "/content/yoloair/utils/loss.py", line 222, in build_targets 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

Is there an obvious mistake that I am making? I'm only changing the config and using the following to train:

!python train.py --data coco128.yaml --weights '' --cfg /content/yoloair/configs/yolov5-Improved/yolov5s_mobileone_backbone.yaml --img 640 --epochs 3 --device 0

Any help would be appreciated!

@hu-luoye
Copy link

same error

@MrAccelerator
Copy link

Is this problem solved? I have the same problem

@OliviaX9
Copy link

Hi all, I might have an answer for this:

change line 222 into:
indices.append((b, a, gj.clamp_(0, shape[2] - 1), gi.clamp_(0, shape[3] - 1)))
add one line code before line 222:
shape = p[i].shape

it works for me :)

@akashAD98 akashAD98 linked a pull request Nov 25, 2022 that will close this issue
@theMoon321
Copy link

Hi all, I might have an answer for this:

change line 222 into: indices.append((b, a, gj.clamp_(0, shape[2] - 1), gi.clamp_(0, shape[3] - 1))) add one line code before line 222: shape = p[i].shape

it works for me :)

Thank you! Your answer is very helpful.

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 a pull request may close this issue.

5 participants