-
Notifications
You must be signed in to change notification settings - Fork 139
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
read mask error? only batches of spatial targets supported (3D tensors) but got targets of size: : [1, 360, 640, 3] #118
Comments
help! |
@mengxia1994 Just to be sure, what is the format of your seg label, is it png single channel? And which line of code yielded that error message? |
I'm guessing your labels are one-hot, in which case you need to turn them to their argmax. |
Thank you for your reply! I just check again my seg label, they are png single channel. |
that is weird. if your labels are grayscale images, they should not have this problem. Maybe save some labels to files and check them? Or can you show me your dataloader code, if it was modified. |
the error is below:
RuntimeError: only batches of spatial targets supported (3D tensors) but got targets of size: : [1, 360, 640, 3]
I think it is because the dataloader read the mask png as rgb 3 channel. If i reshape it in pytorch-auto-drive/utils/runners/lane_det_trainer.py like labels = labels[:, :, :, 0].clone(), I got error:
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [1, 128, 45, 80]], which is output 0 of ReluBackward0, is at version 20; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).
Have searched and tried several way, maybe it can only be solved at early place, like in dataloader.
Please tell me where I was wrong and how to solve this.
By the way, I am using custom dataset orgnized in tusimple format and used pytorch-auto-drive/tools/tusimple_list_convertor.py to generate txt(change some path). Using resa_resnet18_tusimple config.
The mask png data shouldn't be a problem because I have used it to train several other open source code.
The text was updated successfully, but these errors were encountered: