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

extend vit and add mae model and finetune checkpoint file #707

Merged
merged 6 commits into from
Oct 25, 2023

Conversation

sageyou
Copy link
Collaborator

@sageyou sageyou commented Jul 18, 2023

Thank you for your contribution to the MindCV repo.
Before submitting this PR, please make sure:

Motivation

  1. rebase pr Update ViT for feature extraction, support elative positional embedding and layer scale #733 of SamitHuang
  2. update model vit
  3. add and update model mae (also with chheckpoint file fo mae finetune)
  4. remaining tasks: upload new checkpoint files of vit (after being merged of this pr)

Test Plan

(How should this PR be tested? Do you require special setup to run the test or repro the fixed bug?)

Related Issues and PRs

#733
(Is this PR part of a group of changes? Link the other relevant PRs and Issues here. Use https://help.github.com/en/articles/closing-issues-using-keywords for help on GitHub syntax)

@vigo999
Copy link
Collaborator

vigo999 commented Jul 28, 2023

@SamitHuang @geniuspatrick please review

@sageyou sageyou changed the title add mae add mae model and finetune checkpoint file Aug 7, 2023
@@ -198,3 +202,105 @@ def build_model_with_cfg(
raise RuntimeError(f"`feature_only` is not implemented for `{model_cls.__name__}` model.") from e

return model


def interpolate_relative_position_bias(checkpoint_params, network):
Copy link
Collaborator

Choose a reason for hiding this comment

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

下面这俩函数好像没有用到?

@vigo999 vigo999 self-requested a review August 31, 2023 11:41
@vigo999
Copy link
Collaborator

vigo999 commented Aug 31, 2023

原本的vit 是否可以提供vit encoder? 不单独搞vit_encoder.py @sageyou @geniuspatrick

@sageyou
Copy link
Collaborator Author

sageyou commented Aug 31, 2023

原本的vit 是否可以提供vit encoder? 不单独搞vit_encoder.py @sageyou @geniuspatrick

mae可以实现,但是会麻烦 结构都要动。
beit不行,因为新的vit_encoder就是出于mae和beit可以共同使用enocoder而写的,里面增加了新的功能供beit使用, 例如Attention中可以使用relative_position_bias,encoder中可选择使用LayerScale等,具体请看治锋之前提的一个issue:https://github.com/mindspore-lab/mindcv/issues/693。
总的来说新的可以兼容原来的vit encoder, 非要整改的话, 个人建议改原来的vit。 @vigo999 @geniuspatrick

@SamitHuang
Copy link
Collaborator

已将ViT Encoder加入到原vit中,请Review并rebase 该PR: #733

@sageyou sageyou changed the title add mae model and finetune checkpoint file extend vit and add mae model and finetune checkpoint file Sep 11, 2023
@sageyou sageyou force-pushed the pr_ssl branch 2 times, most recently from e063900 to 0b52806 Compare September 13, 2023 02:23
@sageyou
Copy link
Collaborator Author

sageyou commented Sep 14, 2023

review plz, @SamitHuang @geniuspatrick

@geniuspatrick
Copy link
Collaborator

LGTM. BTW, have the new weights been verified?

@sageyou
Copy link
Collaborator Author

sageyou commented Sep 14, 2023

LGTM. BTW, have the new weights been verified?

@geniuspatrick Yes, I have validated all of them, including vit and mae.
However, the ckpt file of vit has not been uploaded yet: the url of pretrained-vit of this pr is not the latest. I would like to do it next~

B, C, H, W = x.shape
if self.image_size is not None:
if self.strict_img_size:
assert H == self.image_size[0], f"Input height ({H}) doesn't match model ({self.image_size[0]})."
Copy link
Collaborator

Choose a reason for hiding this comment

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

assert in cell.construct is not recommended for MS+910B, which will lower the performance.

@SamitHuang SamitHuang merged commit 5fd01e2 into mindspore-lab:main Oct 25, 2023
5 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.

SSL/MIM/CL:【补充训练特性】自监督,并在beit, mae上验证。
4 participants