Skip to content

[WIP]Refactor vit2#295

Closed
HIT-cwh wants to merge 119 commits intoopen-mmlab:masterfrom
HIT-cwh:refactor_vit2
Closed

[WIP]Refactor vit2#295
HIT-cwh wants to merge 119 commits intoopen-mmlab:masterfrom
HIT-cwh:refactor_vit2

Conversation

@HIT-cwh
Copy link
Copy Markdown
Collaborator

@HIT-cwh HIT-cwh commented Jun 8, 2021

Hi! This pr refactors vision transformer with FFN and MSA in transformer.py, mmcv. As the refactor_tramsformer_base branch created by shilong isn't merged now, all the unitests failed.
Pls kindly take a look.

HIT-cwh added 2 commits June 15, 2021 22:29
# Conflicts:
#	mmcls/models/backbones/vision_transformer.py
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 15, 2021

Codecov Report

Merging #295 (062d65f) into master (1a7cebe) will increase coverage by 0.12%.
The diff coverage is 86.88%.

❗ Current head 062d65f differs from pull request most recent head 33c196a. Consider uploading reports for the commit 33c196a to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #295      +/-   ##
==========================================
+ Coverage   76.02%   76.14%   +0.12%     
==========================================
  Files          96       96              
  Lines        5109     5069      -40     
  Branches      849      842       -7     
==========================================
- Hits         3884     3860      -24     
+ Misses       1106     1096      -10     
+ Partials      119      113       -6     
Flag Coverage Δ
unittests 76.14% <86.88%> (+0.12%) ⬆️

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

Impacted Files Coverage Δ
mmcls/models/backbones/vision_transformer.py 80.41% <84.00%> (+3.82%) ⬆️
mmcls/models/heads/vision_transformer_head.py 93.61% <100.00%> (+0.59%) ⬆️
mmcls/models/necks/gap.py 80.00% <100.00%> (+0.83%) ⬆️

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 1a7cebe...33c196a. Read the comment docs.

attn_drop_rate=0.,
drop_path_rate=0.,
num_fcs=2,
qkv_bias=True,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems that the default qkv_bias is False (qkv_bias=False) in most repos (e.g. TIMM), so maybe we can follow the common practices.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In fact, the default value of qkv_bias is True. (e.g. TIMM)

class HybridEmbed(BaseModule):
"""CNN Feature Map Embedding.

Extract feature map from CNN, flatten, project to embedding dim.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Docstring of Args

super(PatchEmbed, self).__init__()
norm_cfg=None,
conv_cfg=None,
init_cfg=None):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add kernel_size, stride and padding args to suppport overlap embedding.

mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Aug 5, 2021
@mzr1996
Copy link
Copy Markdown
Member

mzr1996 commented Aug 5, 2021

Closed, continue with #395

@mzr1996 mzr1996 closed this Aug 5, 2021
mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Aug 5, 2021
mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Aug 10, 2021
mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Aug 20, 2021
mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Aug 24, 2021
mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Aug 24, 2021
mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Sep 28, 2021
mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Sep 28, 2021
mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Oct 13, 2021
mzr1996 added a commit that referenced this pull request Oct 18, 2021
* [Squash] Refator ViT (from #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 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.
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.

4 participants