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] Refator ViT (Continue #295) #395

Merged
merged 23 commits into from Oct 18, 2021
Merged

Conversation

mzr1996
Copy link
Member

@mzr1996 mzr1996 commented Aug 5, 2021

Motivation

This PR is the update of PR #295, to refactor vit backbone.

Modification

Based on #295, continue to work.

BC-breaking (Optional)

ViT structure is changed, old config and checkpoint will be broken.

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.

@codecov
Copy link

codecov bot commented Aug 5, 2021

Codecov Report

Merging #395 (d1a2f41) into master (0381309) will increase coverage by 0.54%.
The diff coverage is 92.99%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #395      +/-   ##
==========================================
+ Coverage   77.96%   78.51%   +0.54%     
==========================================
  Files         102      102              
  Lines        5619     5612       -7     
  Branches      923      915       -8     
==========================================
+ Hits         4381     4406      +25     
+ Misses       1111     1087      -24     
+ Partials      127      119       -8     
Flag Coverage Δ
unittests 78.51% <92.99%> (+0.54%) ⬆️

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

Impacted Files Coverage Δ
mmcls/models/backbones/vision_transformer.py 93.79% <92.03%> (+16.25%) ⬆️
mmcls/models/utils/attention.py 98.72% <92.85%> (-1.28%) ⬇️
mmcls/models/heads/vision_transformer_head.py 93.18% <100.00%> (+1.28%) ⬆️
mmcls/models/utils/__init__.py 100.00% <100.00%> (ø)
mmcls/utils/logger.py 100.00% <0.00%> (+25.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0381309...d1a2f41. Read the comment docs.

@mzr1996 mzr1996 force-pushed the refactor-vit branch 2 times, most recently from 472c97a to 885a4f2 Compare August 13, 2021 08:59
@mzr1996 mzr1996 force-pushed the refactor-vit branch 3 times, most recently from c97350a to a6a7655 Compare August 20, 2021 06:25
@mzr1996 mzr1996 changed the title [WIP] Refator ViT (Continue #295) [Refactor] Refator ViT (Continue #295) Aug 23, 2021
@mzr1996 mzr1996 requested a review from Ezra-Yu August 23, 2021 04:56
@mzr1996
Copy link
Member Author

mzr1996 commented Aug 23, 2021

@Ezra-Yu This PR depends on #398, we need to merge that at first.

configs/vision_transformer/README.md Show resolved Hide resolved
mmcls/models/necks/gap.py Outdated Show resolved Hide resolved
configs/_base_/models/vit-base-p16.py Show resolved Hide resolved
configs/vision_transformer/README.md Show resolved Hide resolved
mmcls/models/utils/attention.py Show resolved Hide resolved
mmcls/models/backbones/vision_transformer.py Show resolved Hide resolved
Copy link
Collaborator

@Ezra-Yu Ezra-Yu left a comment

Choose a reason for hiding this comment

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

LGTM.

@mzr1996 mzr1996 merged commit 2932f9d into open-mmlab:master Oct 18, 2021
mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Nov 24, 2022
* [Squash] Refator ViT (from open-mmlab#295)

* Use base variable to simplify auto_aug setting

* Use common PatchEmbed, remove HybridEmbed and refactor ViT init
structure.

* Add `output_cls_token` option and change the output format of ViT and
input format of ViT head.

* Update unit tests and add test for `output_cls_token`.

* Support out_indices.

* Standardize config files

* Support resize position embedding.

* Add readme file of vit

* Rename config file

* Improve docs about ViT.

* Update docstring

* Use local version `MultiheadAttention` instead of mmcv version.

* Fix MultiheadAttention

* Support `qk_scale` argument in `MultiheadAttention`

* Improve docs and change `layer_cfg` to `layer_cfgs` and support
sequence.

* Use init_cfg to init Linear layer in VisionTransformerHead

* update metafile

* Update checkpoints and configs

* Imporve docstring.

* Update README

* Revert GAP modification.
@mzr1996 mzr1996 deleted the refactor-vit branch December 7, 2022 02:08
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

2 participants