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

[Refactor] refactor _prepare_pos_embed in ViT to fix bug in loading old checkpoint #1679

Merged

Conversation

Ben-Louis
Copy link
Contributor

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

Fix the bug in #1656

Modification

With the implementation in #1656, ckpt_pos_embed_shape will be converted to a tuple, and will cause a bug in the judgment of whether to remove the cls token:

if (not self.with_cls_token and ckpt_pos_embed_shape[1] == self.pos_embed.shape[1] + 1):
    ...

In this PR, the removal of the cls token is moved ahead of the process of resizing pos_embed. This implementation has undergone accuracy verification.

BC-breaking (Optional)

Does the modification introduce changes that break the backward compatibility of the downstream repositories?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

If this PR introduces a new feature, it is better to list some use cases here and update the documentation.

Checklist

Before PR:

  • Pre-commit or other linting tools are used to fix the potential lint issues.
  • Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests.
  • The modification is covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • The documentation has been modified accordingly, like docstring or example tutorials.

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with those projects, like MMDet or MMSeg.
  • CLA has been signed and all committers have signed the CLA in this PR.

@CLAassistant
Copy link

CLAassistant commented Jun 29, 2023

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

❗ No coverage uploaded for pull request base (test-1.0@658db80). Click here to learn what that means.
Patch has no changes to coverable lines.

❗ Current head fc2e7b6 differs from pull request most recent head 7b90a3d. Consider uploading reports for the commit 7b90a3d to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##             test-1.0    #1679   +/-   ##
===========================================
  Coverage            ?   65.50%           
===========================================
  Files               ?      329           
  Lines               ?    25590           
  Branches            ?     4078           
===========================================
  Hits                ?    16763           
  Misses              ?     8214           
  Partials            ?      613           
Flag Coverage Δ
unittests 65.50% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@fangyixiao18 fangyixiao18 merged commit 00030e3 into open-mmlab:test-1.0 Jul 3, 2023
8 of 9 checks passed
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.

None yet

4 participants