DRENet icon indicating copy to clipboard operation
DRENet copied to clipboard

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

Open tommylatranvu opened this issue 2 years ago • 2 comments

Hello Chen, Thank you very much for taking your time to answer me! I appreciate! When I run the training code train.py, I had the error:

Image sizes 512 train, 512 test Using 8 dataloader workers Logging results to LEVIR-Ship/exp2 Starting training for 1000 epochs...

 Epoch   gpu_mem       box       obj       cls       dgi     total   targets  img_size

0%| | 0/145 [00:00<?, ?it/s] Traceback (most recent call last): File "/home/la/Desktop/DRENet_ship/train.py", line 515, in train(hyp, opt, device, tb_writer, wandb) File "/home/la/Desktop/DRENet_ship/train.py", line 294, in train loss, loss_items, adaptParams = compute_loss(pred, dgimgs.to(device), targets.to(device)) # loss scaled by batch_size File "/home/la/Desktop/DRENet_ship/utils/loss.py", line 135, in call tcls, tbox, indices, anchors = self.build_targets(p[0], targets) # targets File "/home/la/Desktop/DRENet_ship/utils/loss.py", line 245, 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 wandb: Waiting for W&B process to finish... (failed 1). Press Control-C to abort syncing.

I did not change anything from your code. Could you please give me a solution to solve this problem. Thanks!

Best regards,

Tran-Vu

tommylatranvu avatar Jun 27 '23 13:06 tommylatranvu

Hi @tommylatranvu ,

This is a problem caused by an incompatible torch version. You can find some discussions about this here.

And there are some simple and easy ways online to solve the problems, like this.

Hope these can help.

WindVChen avatar Jun 27 '23 16:06 WindVChen

Thanks a lot!

tommylatranvu avatar Jun 28 '23 06:06 tommylatranvu