Skip to content
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: shape '[1, 1, 14, 16, 13]' is invalid for input of size 3120 #4

Closed
EricLe-dev opened this issue Nov 6, 2020 · 5 comments

Comments

@EricLe-dev
Copy link

Dear @Yaoyi-Li,

Thank you so much for this great work. I'm training this on my custom dataset. With all 512x512 images. The model seems to worked well. However, there are images where I received this error:
RuntimeError: shape '[1, 1, 14, 16, 13]' is invalid for input of size 3120

The problem came from this line and this line in the code. Some images worked well, but there are a lot of images that encountered this error.

Can you please give me a small guide on how to fix it? Thank you so much!

@EricLe-dev
Copy link
Author

A bit more information, since you have not yet provided the pretrained model "model_best_resnet34_D_nomixup.pth.tar", I used the ResNet34_En_nomixup model from your previous work (GCA-Matting) and it seems to work, at least, the training ran flawlessly. I'm not sure if that is also a source of that problem.

@EricLe-dev
Copy link
Author

@Yaoyi-Li I tested your pretrained model HOP-9x9-RI-all-data.pth and this model also encountered exactly the same problem. Can you please give me a guide on how to fix it? Thank you so much!

@Yaoyi-Li
Copy link
Owner

Yaoyi-Li commented Nov 9, 2020

Did you add the training dataloader by yourself? I think you can check whether the size of input image is divisible by 32 first. And the input image should be larger than (15*32, 15*32). If your image is smaller than (480, 480), you can pad the image or reduce the default embed_radius

@EricLe-dev
Copy link
Author

EricLe-dev commented Nov 9, 2020

Thank you for your reply. I did add the training data load myself, using the training from your previous work GCA-Matting. All images in my training data have the size of 512x512. I wrote a piece of code to resize the input images to be divisible by 32. However, that problem still persists. I tested with your pretrained model and it happened exactly the same.

Please find attached one of the image and corresponding trimap that I used to test. Please kindly note that all input images were resize to be divisible by 32.

The error was:
RuntimeError: shape '[1, 13, 1, 12, 12]' is invalid for input of size 2160

new_img
new_trimap

@EricLe-dev
Copy link
Author

@Yaoyi-Li Seems to be a minor bug in my code. Thank you so much. I figured it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants