ultralytics / ultralytics

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

RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 22 but got size 21 for tensor number 1 in the list. #18968

Open Ellohiye opened 1 week ago

Ellohiye commented 1 week ago

Search before asking

Question

When using yolov8-p6 to train 1000*2048 size images, bs=6, imgsz=1280, the training is normal. Why is the test error when imgsz=1280, bs=1?

Additional

No response

UltralyticsAssistant commented 1 week ago

👋 Hello @Ellohiye, thank you for your interest in Ultralytics 🚀! We recommend a visit to the 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. Specifically, include the exact command you ran along with any modifications you may have made to the code or configuration used.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples, training logs, and the configuration used during training and testing. Additionally, confirm whether you are following our Tips for Best Training Results.

Join the Ultralytics community where it suits you best. For real-time chat, head to Discord 🎧. Prefer in-depth discussions? Check out Discourse. Or dive into threads on our Subreddit to share knowledge with the community.

Upgrade

Upgrade to the latest ultralytics package including all requirements in a Python>=3.8 environment with PyTorch>=1.8 to verify your issue is not already resolved in the latest version:

pip install -U ultralytics

Environments

YOLO 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 YOLO Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

⚠️ This is an automated response, but an Ultralytics engineer will follow up with you as soon as possible.

Y-T-G commented 1 week ago

You Can you elaborate on your issue?

What you did and what the issue is?

Ellohiye commented 1 week ago

Image

Ellohiye commented 1 week ago

On this 1000*2048 size dataset, I used bs=4/6, imgsz=1280 parameters for training. The training process went well. When executing python val.py, the parameters were: imgsz=1280, bs=1, and the program reported an error as shown above

Y-T-G commented 1 week ago

It's a very old version of Ultralytics. You should update to the latest.

Ellohiye commented 6 days ago

Since we are using the yolov8 version as the baseline model, if we update it, it may lead to unfair experiments. Is there any other solution? After searching, it seems that the problem is due to the fact that the size of the dataset images is 1000*2048, which cannot be divided by 32 evenly.

Y-T-G commented 6 days ago

Bugs related to an old version wouldn't be counted as bugs. Since it may be fixed in the latest version. The version you're using is 15 months old.