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

Calculate loss and report an error #13393

Closed
1 task done
lllittleX opened this issue Oct 30, 2024 · 2 comments
Closed
1 task done

Calculate loss and report an error #13393

lllittleX opened this issue Oct 30, 2024 · 2 comments
Labels
question Further information is requested

Comments

@lllittleX
Copy link

Search before asking

Question

I did not make any mistakes in the training before October 27, and I made an error in the training on October 29. When I retrained the previous model, I still reported an error even though none of the parameters had changed:
0%| | 0/353 [00:02<?, ?it/s]
Traceback (most recent call last):
File "D:/code/YOLOV5-master/train_FoodDetection.py", line 908, in
main(opt)
File "D:/code/YOLOV5-master/train_FoodDetection.py", line 682, in main
train(opt.hyp, opt, device, callbacks)
File "D:/code/YOLOV5-master/train_FoodDetection.py", line 385, in train
loss, loss_items = compute_loss(pred, targets.to(device)) # loss scaled by batch_size
File "D:\code\YOLOV5-master\utils\loss.py", line 154, in call
pxy, pwh, _, pcls = pi[b, a, gj, gi].split((2, 2, 1, self.nc), 1) # target-subset of predictions
File "D:\software\anaconda\envs\pytorch-2.1\lib\site-packages\torch_tensor.py", line 864, in split
return torch._VF.split_with_sizes(self, split_size, dim)
IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)
My nc is 126 and pi is shown as torch.Size([45, 393, 80, 80])

Additional

In the training from October 29 to today, the step of downloading yolov 5n.pt suddenly appeared, which was not available before

@lllittleX lllittleX added the question Further information is requested label Oct 30, 2024
@UltralyticsAssistant
Copy link
Member

👋 Hello @lllittleX, thank you for your interest in YOLOv5 🚀! It sounds like you're encountering an issue that might be a 🐛 bug. To help us investigate, please provide a minimum reproducible example that includes any relevant code snippets or configurations that lead to the error.

If this involves custom training, please ensure you include details about your dataset, any custom modifications, and the complete error traceback. This information will be crucial to diagnosing the problem.

For your setup, make sure you are using Python>=3.8.0 with all requirements installed, including PyTorch>=1.8. It's important to use a clean environment to rule out any dependency issues.

YOLOv5 can be run in diverse environments, including Jupyter notebooks, Google Cloud, AWS, and Docker. Make sure your environment is up to date with all dependencies, such as CUDA/CUDNN, Python, and PyTorch, preinstalled.

Meanwhile, an Ultralytics engineer will review your issue soon to provide further assistance. Thanks for your patience! 😊

By the way, have you checked out YOLOv8? It's our latest model, offering state-of-the-art performance for 2023 in object detection, image segmentation, and classification tasks!

@pderrenger
Copy link
Member

@lllittleX it seems like there might be a mismatch between your model's output dimensions and the expected dimensions for your classes. Please ensure that your nc (number of classes) is correctly set to 126 in your configuration files and matches the model's architecture. Additionally, verify that you are using the latest version of YOLOv5 to rule out any recent changes that might affect your setup. If the issue persists, consider checking your dataset and label files for any inconsistencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants