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

Fix swin embeddings interpolation #30936

Conversation

amyeroberts
Copy link
Collaborator

What does this PR do?

Fixes broken tests on main introduced by #30656

The PR mistakenly introduced interpolation to the patch embeddings, which shouldn't be done, and also adds a verification check which doesn't account for the padding in _maybe_pad

@amyeroberts amyeroberts requested a review from ydshieh May 21, 2024 10:54
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@ydshieh ydshieh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

(why the tests are failing however? The interpolate_pos_encoding is False by default no? Or it is set to True in some tests?)

@amyeroberts
Copy link
Collaborator Author

@ydshieh Yes, it's set to False by default. There's a few things happening here:

  • The interpolation logic was added for the patch embeddings (which shouldn't have happened)
  • Swin actually already handles images of different sizes (providing they're divisible by 32), so in the pipeline tests, images different from those the model was trained on were being passed in
  • The additional interpolation logic added a check to verify the input images size if interpolation was False (as before). However, because swin can handle some images of different sizes, and interpolate_pos_encoding was False by default this new check was triggered and would fail

@amyeroberts amyeroberts merged commit d24097e into huggingface:main May 21, 2024
21 checks passed
@amyeroberts amyeroberts deleted the fix-swin-interpolate-embeddings-check branch May 21, 2024 14:40
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

Successfully merging this pull request may close these issues.

3 participants