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

Small changes in swin_transformer.py for Image size scale #155

Open
zichengsaber opened this issue Dec 22, 2021 · 3 comments
Open

Small changes in swin_transformer.py for Image size scale #155

zichengsaber opened this issue Dec 22, 2021 · 3 comments

Comments

@zichengsaber
Copy link

zichengsaber commented Dec 22, 2021

Thanks for your remarkable work, when I use the pretrained model ,I found it difficult to scale the input Image size,even I use the image size like window_size*2^n , it loads failed. So I check the code, find that In Class SwinTransformerBlock code
self.register_buffer("attn_mask", attn_mask) is unnecessary,because attn_mask is not a learnable parameter, if you register it as buffer, it will hinder you change the input Image size

@zeliu98
Copy link
Contributor

zeliu98 commented Dec 24, 2021

Hi, you can just delete the "attn_mask" in the pre-trained model. Besides, we have also provided a function for your purpose:

def load_pretrained(config, model, logger):

@zichengsaber
Copy link
Author

Hi, you can just delete the "attn_mask" in the pre-trained model. Besides, we have also provided a function for your purpose:

def load_pretrained(config, model, logger):

thank you very much I will try it

@khanhnguyenuet
Copy link

Hi, you can just delete the "attn_mask" in the pre-trained model. Besides, we have also provided a function for your purpose:

def load_pretrained(config, model, logger):

Hi there, I did as u said to load pretrained model but I only can load the state_dict to model and still can not parse the image through the model due to the lack of attn_mask. Could u explain why?. In case I want to train with another image size, how can I train the model?

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

3 participants