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: The size of tensor a (32) must match the size of tensor b (64) at non-singleton dimension 2 #46

Closed
liuyjchj1 opened this issue Jul 26, 2023 · 8 comments

Comments

@liuyjchj1
Copy link

Is the input image size of the SAM model fixed at 1024? It seems that an error occurs when inputting images of other sizes. I tried using a 512-sized image and it resulted in a RuntimeError: The size of tensor a (32) must match the size of tensor b (64) at non-singleton dimension 2.

@liuyjchj1
Copy link
Author

我输入的图像尺寸设置为512,但是报错为RuntimeError: The size of tensor a (32) must match the size of tensor b (64) at non-singleton dimension 2,查了一下,发现SAM模型本身的输入就是1024,那怎么训练其他尺寸的数据呢?是硬padding为1024吗?

@LinhuiHu
Copy link

sam源码中的sam.py有一个process函数是这样直接padding的,感觉训练应该也是吧

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The sam.py in the sam source code has a process function that directly pads in this way. I feel that the training should be the same.

@WuJunde
Copy link
Collaborator

WuJunde commented Jul 30, 2023

yes, you need to change some hyper-parameters to train image with other sizes. if you want to solve it in preprocessing, I will recommend resize, instead of padding.

@liuyjchj1
Copy link
Author

yes, you need to change some hyper-parameters to train image with other sizes. if you want to solve it in preprocessing, I will recommend resize, instead of padding.

Thank you! I will follow the method you suggested!

@gm1019
Copy link

gm1019 commented Oct 27, 2023

So this still mean resizing the image to 1024?

@ShChen233
Copy link

yes, you need to change some hyper-parameters to train image with other sizes. if you want to solve it in preprocessing, I will recommend resize, instead of padding.

Thank you! I will follow the method you suggested!

所以是重新训练的吗

@WuJunde
Copy link
Collaborator

WuJunde commented Jan 7, 2024

image resolution now can be resized, just set -image_size parameter in the running. check my newest update.

@WuJunde WuJunde closed this as completed Jan 7, 2024
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

6 participants