RuntimeError: result type Float can't be cast to the desired output type long int
Closed this issue ยท 8 comments
Search before asking
- I have searched the YOLOv5 issues and discussions and found no similar questions.
Question
I tried to run this on Monash dataset [https://github.com/MarcusLimJunYi/Monash-Guns-Dataset]
and i get this error:
File "/content/yolov5/utils/loss.py", line 211, 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
Where do I need to do the changes ?
Additional
No response
๐ Hello @lucysumi, thank you for your interest in YOLOv5 ๐! Please visit our โญ๏ธ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.
If this is a ๐ Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.
If this is a custom training โ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.
For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.
Requirements
Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:
git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install
Environments
YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
- Google Colab and Kaggle notebooks with free GPU:
- Google Cloud Deep Learning VM. See GCP Quickstart Guide
- Amazon Deep Learning AMI. See AWS Quickstart Guide
- Docker Image. See Docker Quickstart Guide
Status
If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on macOS, Windows, and Ubuntu every 24 hours and on every commit.
That's the error I get when I tried to train it on a custom dataset from roboflow.
@lucysumi your YOLOv5 code is out of date. To update and resolve this issue:
- Git โ
git pull
from within youryolov5/
directory orgit clone https://github.com/ultralytics/yolov5
again - PyTorch Hub โ Force-reload
model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
- Notebooks โ View updated notebooks
- Docker โ
sudo docker pull ultralytics/yolov5:latest
to update your image
It worked perfectly in solving my problem. Thank you @glenn-jocher
If someone is wondering what change will fix the problem, here is the commit: https://github.com/ultralytics/yolov5/pull/8067/files
If someone is wondering what change will fix the problem, here is the commit: https://github.com/ultralytics/yolov5/pull/8067/files
it works,thank you.
@keepgoing365 glad to hear it's working! ๐ Remember that the YOLOv5 community and the Ultralytics team are here to help with any issues you encounter. If you have any more questions, feel free to ask.