-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Swin transformer handle window size smaller than input size #6222
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
Swin transformer handle window size smaller than input size #6222
Conversation
…mer by updating window_size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @YosuaMichael. I left a couple of comments, let me know what you think.
Edit: also the failing tests seem related.
Investigating on the failing test, the changes affect the result when the input size is 112 or smaller.
As we can see, this PR reduce the accuracy significantly. When looking at the reason, it because the Looking at this, I think this change need more discussion and if we really want to implement like the original implementation its better to have a "better" reason like to implement Swin Transformer V2. Therefore for now I will close this PR. |
@YosuaMichael I think we can do some modification on the model: cc @datumbox |
Hi @xiaohu2015 , sorry for the late reply! I am trying to understand your suggestion on having window_size specified for each layer. In this case, is it correct to say that the user need to retrain the model in order to change the window_size? |
@YosuaMichael yes. |
This PR introduce logic in swin transformer to update the window_size if it is bigger than the input size.
This behaviour follow the original implementation: https://github.com/microsoft/Swin-Transformer/blob/main/models/swin_transformer.py#L192-L195
We introduced this change on a commit in #6088, however since we want to cherrypick that PR and the main goal of #6088 is to adapt the components so it can be reused on the swin transformer 3d, we decide to revert back this change in order to lower the risk during the release.
However since this change can be useful especially if we want to adapt the components to swin transformer v2 (as commented by @xiaohu2015 in #6088 (comment)), we introduce the change back in this PR.
We have tested this change by running the validation script:
where model_variant can be
swin_t, swin_s, swin_b
and weight_variant can beSwin_T, Swin_S, Swin_B
.Here are the validation resutl: