-
-
Notifications
You must be signed in to change notification settings - Fork 16.5k
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
TypeError: tuple indices must be integers or slices, not tuple #9390
Comments
👋 Hello @yangboz, 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. RequirementsPython>=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 EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf 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. |
@yangboz there might be something wrong with your model yaml or dataset format. See Train Custom Data tutorial to get started: Tutorials
Good luck 🍀 and let us know if you have any other questions! |
👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs. Access additional YOLOv5 🚀 resources:
Access additional Ultralytics ⚡ resources:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed! Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐! |
你好,请问解决了这个问题吗 |
@HaHalr 你好!看起来你是在寻找有关之前讨论的问题的解决方案。如果你遇到的是特定的错误消息或问题,我建议首先检查你的代码是否最新,并确认你遵循了所有的数据准备和训练步骤。如果问题仍然存在,请提供更具体的错误描述和代码上下文,这样我们可以更准确地帮助你。感谢你对YOLOv5的支持!🌟 |
@glenn-jocher Hello Author, I have followed the data preparation and training steps, but I still find that the problem exists. I am at a loss on how to deal with it and have not found any relevant solutions, so I am seeking help. Below is the error information prompted after I executed train.py: home/liu/anaconda3/yes/envs/myolov5/lib/python3.7/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3190.) Transferred 354/450 items from ./yolov5s.pt
0%| | 0/159 [00:12<?, ?it/s] . I hope you can give me some direction or method to solve this problem. I would be very grateful. |
@HaHalr Hi there! It looks like the issue is related to improper indexing or data types when handling the Please ensure that anchors = torch.tensor(anchors).float().to(device) # Assuming you have a device defined Also, double-check the shape and type of If the problem persists, it might be helpful to print out the types and shapes of variables involved in the operation causing the error right before it occurs. This can give you more insight into why the type error is happening. Keep going, debugging issues like this can be tricky but you're on the right path! 🚀 |
@glenn-jocher Dear author, thank you for your valuable suggestions. After repeatedly checking the loss.py file, I found two errors and have corrected them. I am very grateful for your recent responses. I would like to share the joy of solving the problem with you. Thank you once again! |
@HaHalr That's fantastic news! 🎉 I'm glad to hear you were able to solve the issues by making those corrections in the |
@HaHalr 麻烦能告知改了那个地方吗 |
错误原因好像出才数据集上,有点忘了,你可以先试试用200张或者更少的数据集试试,因为我后续用了yolo 其他版本,所以可能有点忘了在 2024年7月28日,12:15,daidairong ***@***.***> 写道:
尊敬的作者,感谢您的宝贵建议。在反复检查 loss.py 文件后,我发现了两个错误并已进行了纠正。我非常感谢你最近的答复。我想与您分享解决问题的喜悦。再次感谢你们!
想知道改了哪里求求了
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@HaHalr 你好!很高兴听到你已经解决了问题并且愿意分享你的解决方案。对于@HaHalr 提到的错误,可能确实与数据集有关。为了帮助其他遇到类似问题的用户,能否请你详细描述一下你在 如果你不太记得具体的修改内容,可以尝试以下步骤来帮助其他用户排查问题:
希望这些建议对你有所帮助。如果你有更多的细节可以分享,欢迎随时更新!感谢你对 YOLOv5 社区的支持!😊 |
Search before asking
YOLOv5 Component
Training
Bug
Traceback (most recent call last):
File "/home/xibaoda/yolov5_ws/train.py", line 664, in
main(opt)
File "/home/xibaoda/yolov5_ws/train.py", line 559, in main
train(opt.hyp, opt, device, callbacks)
File "/home/xibaoda/yolov5_ws/train.py", line 347, in train
loss, loss_items = compute_loss(pred, targets.to(device)) # loss scaled by batch_size
File "/home/xibaoda/yolov5_ws/utils/loss.py", line 125, in call
tcls, tbox, indices, anchors = self.build_targets(p, targets) # targets
File "/home/xibaoda/yolov5_ws/utils/loss.py", line 205, in build_targets
r = t[..., 4:6] / anchors[:, None] # wh ratio
TypeError: tuple indices must be integers or slices, not tuple
Environment
No response
Minimal Reproducible Example
Additional
loss.py
dataset4xyz.yaml copy from default [dataset.yaml]
python 3.9
torch 1.12.1
torchvision 0.13.1
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: