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

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

Open
sayyidan-i opened this issue Dec 1, 2023 · 3 comments

Comments

@sayyidan-i
Copy link

I tried to training custom dataset but turns out I get this error, please enlighten me


RuntimeError Traceback (most recent call last)
/content/Yolo-FastestV2-Tooth/train.py in
108 preds = model(imgs)
109 # loss计算
--> 110 iou_loss, obj_loss, cls_loss, total_loss = utils.loss.compute_loss(preds, targets, cfg, device)
111
112 # 反向传播求解梯度

1 frames
/content/Yolo-FastestV2-Tooth/utils/loss.py in build_target(preds, targets, cfg, device)
117 # Append
118 a = t[:, 6].long() # anchor indices
--> 119 indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) # image, anchor, grid indices
120 tbox.append(torch.cat((gxy - gij, gwh), 1)) # box
121 anch.append(anchors_cfg[a]) # anchors

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

@sanimgh
Copy link

sanimgh commented Dec 22, 2023

do you have a solution ?

@dinhln03
Copy link

at util/loss.py, you may need to change to this in build_target function, then it'll work
image

@flanremi
Copy link

indices.append((b, a, gj.clamp_(0, gain[3].long() - 1), gi.clamp_(0, gain[2].long() - 1)))
you need edit your code to this one, then will work

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

No branches or pull requests

4 participants