ultralytics / ultralytics

Ultralytics YOLO11 🚀
https://docs.ultralytics.com
GNU Affero General Public License v3.0
32.69k stars 6.29k forks source link

RuntimeError: shape '[-1, 3, 3]' is invalid for input of size 6936 #2850

Closed martinyezhen closed 1 year ago

martinyezhen commented 1 year ago

Search before asking

YOLOv8 Component

No response

Bug

when I run the order :yolo segment val data=Triangle_215.yaml model=yolov8n-pose.pt pretrained=True project=Triangle_215 name=n_pretrain epochs=10 batch=4 device=cpu,

It shows the errorTraceback (most recent call last): File "/Users/apple/Desktop/bpycv-master/venv/bin/yolo", line 8, in sys.exit(entrypoint()) File "/Users/apple/Desktop/bpycv-master/venv/lib/python3.8/site-packages/ultralytics/yolo/cfg/init.py", line 394, in entrypoint getattr(model, mode)(overrides) # default args from model File "/Users/apple/Desktop/bpycv-master/venv/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, *kwargs) File "/Users/apple/Desktop/bpycv-master/venv/lib/python3.8/site-packages/ultralytics/yolo/engine/model.py", line 302, in val validator(model=self.model) File "/Users/apple/Desktop/bpycv-master/venv/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(args, kwargs) File "/Users/apple/Desktop/bpycv-master/venv/lib/python3.8/site-packages/ultralytics/yolo/engine/validator.py", line 174, in call self.plot_predictions(batch, preds, batch_i) File "/Users/apple/Desktop/bpycv-master/venv/lib/python3.8/site-packages/ultralytics/yolo/v8/pose/val.py", line 158, in plot_predictions pred_kpts = torch.cat([p[:, 6:].view(-1, self.kpt_shape)[:15] for p in preds], 0) File "/Users/apple/Desktop/bpycv-master/venv/lib/python3.8/site-packages/ultralytics/yolo/v8/pose/val.py", line 158, in pred_kpts = torch.cat([p[:, 6:].view(-1, self.kpt_shape)[:15] for p in preds], 0) RuntimeError: shape '[-1, 3, 3]' is invalid for input of size 6936 but when I run the order:yolo segment train data=Triangle_215.yaml model=yolov8n-pose.pt pretrained=True project=Triangle_215 name=n_pretrain epochs=10 batch=4 device=cpu It works well. This bug seems so stranger.

Environment

No response

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

github-actions[bot] commented 1 year ago

👋 Hello @martinyezhen, thank you for your interest in YOLOv8 🚀! We recommend a visit to the YOLOv8 Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Install

Pip install the ultralytics package including all requirements in a Python>=3.7 environment with PyTorch>=1.7.

pip install ultralytics

Environments

YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

Ultralytics CI

If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 1 year ago

@martinyezhen hi there!

Thank you for bringing this issue to our attention. It seems that the error is caused by an invalid tensor shape. The error message "shape '[-1, 3, 3]' is invalid for input of size 6936" indicates that the input tensor is expected to have a shape of [-1, 3, 3], but the actual size of the input tensor is 6936, which does not match the expected shape.

This error appears when running the command "yolo segment val" but not when running "yolo segment train", which is quite strange. It may be helpful to check if there are any differences in the data or models used when running these two commands.

If you are willing to submit a PR, that would be great! However, if you do not have experience with debugging and fixing such issues, we recommend checking the YOLOv8 documentation and GitHub Issues to find similar issues and solutions that may work for you.

Let us know if you have any further questions or concerns.

Best regards!

glenn-jocher commented 1 year ago

@martinyezhen your command is incorrect. You've used a segment command on a pose model. These are two completely separate tasks. I'd recommend reviewing the tasks and usage examples there. https://docs.ultralytics.com/tasks/

If you mix tasks, you should expect errors, that's the correct result.

github-actions[bot] commented 1 year ago

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

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 YOLO 🚀 and Vision AI ⭐