Yolo-FastestV2 icon indicating copy to clipboard operation
Yolo-FastestV2 copied to clipboard

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

Open sayyidan-i opened this issue 1 year ago • 3 comments

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

sayyidan-i avatar Dec 01 '23 17:12 sayyidan-i

do you have a solution ?

sanimgh avatar Dec 22 '23 15:12 sanimgh

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

dinhln03 avatar Jan 27 '24 14:01 dinhln03

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

flanremi avatar Feb 29 '24 14:02 flanremi