-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 30 but got size 29 for tensor number 1 in the list. #243
Comments
when change the img size to 640 the code run correctly ? why? |
@totoadel you have to make sure the img size can be divided by 32. That's the rule. :) |
i use 460 , i should use 480, thank you |
It works with YOLOv5, it will automatically change the image size to be divisible by 32. I guess v8 doesnt do that? |
@Laughing-q my image sizes are 1024x1024 but not working. i am facing this error Sizes of tensors must match except in dimension 1. Expected size 57 but got size 0 for tensor number 1 in the list. i am using this command to run yolo instance segmentation |
@Caliphamin Training with your command but with coco128-seg.yaml works correctly to me. yolo task=segment mode=train model=yolov8m-seg.pt data=coco128-seg.yaml epochs=100 imgsz=1024 batch=4 BTW I'm using the latest version of package. |
@Laughing-q |
@Laughing-q |
@Caliphamin sure, laughingq@163.com. |
@Caliphamin I just checked your dataset, and found you were using a detection labels but trying to train a segmentation model which is incorrect. You should always train a segmentation model with segmentation labels. BTW I just saw the following error when I was trying to reproduce your issue but it seems that you didn't encounter this error msg. |
@Laughing-q ooooh, you mean my data is wrong. actually i did not get this message. i just thought my image sizes or batch sizes are wrong |
@Caliphamin Also It's better to use the latest version of package. :) |
I will do that too:) |
@Laughing-q I am getting the same erroe can you check my dataset too.. |
@AnonymousPhython my problem solved by changing dataset label from object detection to instance segmentation |
hi, it is YOLOv8 i am using yolov8n-seg. |
Pls send the code that you use to train |
thanks.. it is working now.. |
@AnonymousPhython What?how?😁 |
I apologize for any confusion. I am an AI language model and sometimes my responses might not make sense or be relevant to the conversation. Is there anything I can assist you with? |
@Kr-Sheshank it seems you are ruining training on local pc , if true, change batch=1 |
No i m running in google colab,
|
I tried this it is working, training for coco data set is working but not for my dataset which I'm using from exporting from roboflow |
@Kr-Sheshank write down your .yaml file here |
names:
|
I think problem is with my dataset,I used another v8 segment data set from roboflow than training got start |
@VYRION-Ai based on the error message you posted, it looks like the issue may be with your dataset. If you used another YOLOv8 segment dataset from Roboflow and the training started successfully, then it could be that your original dataset may have had issues with it. You may want to double check your original dataset to ensure that it's properly formatted and contains the necessary files and annotations in the correct format for YOLOv8 to work with. |
I encounter same problem.I guess something wrong in the process during json file convert to txt file.But I am not sure.Can you help me . |
I encountered the same problem, but when I set the parameter “save_hybrid” to False, this issue is resolved. |
I got the same above problems in Yolov8 `
head:
I already try to change stride 32 to 64 in "v5loader.py", "build.py" and "trainer.py" |
I was exhausted after wasting my whole day due to this parameter. You just saved my life |
@aleehamza25 i'm glad to hear that setting the parameter "save_hybrid" to False resolved the issue for you! Sometimes small changes can have a big impact. If you have any more questions or need further assistance, feel free to ask! |
@MandilJThapa it looks like there might be an issue with the way the dataset or the model is configured. Could you please check if your |
After improving the YOLOv8 model structure, I encountered a similar issue when performing val on the Visdrone dataset:
|
This is my command: model = YOLO("/home/lyu4/datasets/dh_wp/dh/visdrone-det/v8-improve/runs/detect/yolov8x_DW_swin_FOCUS-3--调参/weights/best.pt") validation_results = model.val(data="/home/lyu4/datasets/dh_wp/dh/visdrone-det/v8-improve/datasets/VisDrone-test.yaml", imgsz=960, iou = 0.6, batch=1)` |
@AZong76 it seems like you're encountering a tensor size mismatch error during the concatenation process in your model's forward pass. This typically happens when the dimensions of the tensors being concatenated do not align as expected except for the specified dimension (in your case, dimension 1). Here are a few steps you can take to troubleshoot and potentially resolve this issue:
If these steps do not resolve the problem, consider providing more details such as the specific layers involved in the error, and possibly a snippet of your model's architecture around the problematic layers. This information could help further diagnose the issue. |
Search before asking
YOLOv8 Component
No response
Bug
When trying to do traning in local pc
yolo task=detect mode=train model=yolov8n.pt data=data.yaml epochs=3 imgsz=460 batch=1 cache=True
Environment
No response
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: