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 #36

Open
poojatambe opened this issue Oct 31, 2022 · 7 comments

Comments

@poojatambe
Copy link

Facing error while training.
Training command: !python polygon_train.py --weights yolov5s.pt --cfg polygon_yolov5s_ucas.yaml
--data data/custom.yaml --hyp hyp.ucas.yaml --img-size 1024
--epochs 3 --batch-size 12 --noautoanchor --polygon --cache

image

@SjoerdBoonen
Copy link

SjoerdBoonen commented Mar 23, 2023

Facing error while training. Training command: !python polygon_train.py --weights yolov5s.pt --cfg polygon_yolov5s_ucas.yaml --data data/custom.yaml --hyp hyp.ucas.yaml --img-size 1024 --epochs 3 --batch-size 12 --noautoanchor --polygon --cache

image

Hey Im currently getting the same error, did you find a way to fix it?
I looked at the original YOLOv5 repo from Utralytics and there they mentioned that they fixed the issue in a more recent version (ultralytics/yolov5#8405), however I think this repo is built on an older version.

@XinzeLee do you know how to fix this?

@dt140120
Copy link

Facing error while training. Training command: !python polygon_train.py --weights yolov5s.pt --cfg polygon_yolov5s_ucas.yaml --data data/custom.yaml --hyp hyp.ucas.yaml --img-size 1024 --epochs 3 --batch-size 12 --noautoanchor --polygon --cache

image

same error

@github-rajs
Copy link

Getting same error.Any fix for this?

@jlclemon
Copy link

jlclemon commented May 4, 2023

I have found that modifying the offending line in loss.py to be:

indices.append((b, a, gj.clamp_(0, int(gain[3].item()) - 1), gi.clamp_(0, int(gain[2].item()) - 1))) # image, anchor, grid indices

allows it to run training. I am still verifying if the training results in a correct model.

@dt140120
Copy link

dt140120 commented May 4, 2023

I have found that modifying the offending line in loss.py to be:

indices.append((b, a, gj.clamp_(0, int(gain[3].item()) - 1), gi.clamp_(0, int(gain[2].item()) - 1))) # image, anchor, grid indices

allows it to run training. I am still verifying if the training results in a correct model.

Can you capture the screen of training for reference ?

@helianthus1
Copy link

helianthus1 commented Jun 27, 2023

In loss.py (line 173 ), gain = torch.ones(7, device=targets.device) → gain = torch.ones(7, device=targets.device).long()

@poojatambe
Copy link
Author

Run this command before python setup.py install :

!pip3 install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html

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

6 participants