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

[Feature] Support VAN #739

Merged
merged 11 commits into from
Apr 28, 2022
Merged

[Feature] Support VAN #739

merged 11 commits into from
Apr 28, 2022

Conversation

okotaku
Copy link
Collaborator

@okotaku okotaku commented Mar 22, 2022

Motivation

Visual Attention Network
official repo

Result

CUB200
bs8×1GPU

model top1 acc
van-l 89.54

Config

_base_ = [
    '../_base_/models/van/van_large.py', '../_base_/datasets/cub_bs8_384.py',
    '../_base_/schedules/cub_bs64.py', '../_base_/default_runtime.py'
]

checkpoint = 'van_large.pth'  # converted weight from official repo

model = dict(
    type='ImageClassifier',
    backbone=dict(
        init_cfg=dict(
            type='Pretrained', checkpoint=checkpoint, prefix='backbone')),
    head=dict(num_classes=200, ))

paramwise_cfg = dict(
    norm_decay_mult=0.0,
    bias_decay_mult=0.0,
    custom_keys={
        '.absolute_pos_embed': dict(decay_mult=0.0),
        '.relative_position_bias_table': dict(decay_mult=0.0)
    })

optimizer = dict(
    _delete_=True,
    type='AdamW',
    lr=5e-5,
    weight_decay=0.0005,
    eps=1e-8,
    betas=(0.9, 0.999),
    paramwise_cfg=paramwise_cfg)
optimizer_config = dict(grad_clip=dict(max_norm=5.0), _delete_=True)

log_config = dict(interval=20)  # log every 20 intervals

checkpoint_config = dict(
    interval=1, max_keep_ckpts=3)  # save last three checkpoints
fp16 = dict(loss_scale='dynamic')

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.

@okotaku okotaku changed the title Van [Feature] VAN Mar 22, 2022
@okotaku okotaku changed the title [Feature] VAN [Feature] Support VAN Mar 22, 2022
@codecov
Copy link

codecov bot commented Mar 22, 2022

Codecov Report

Merging #739 (8e11e3b) into dev (6beac50) will increase coverage by 0.21%.
The diff coverage is 96.85%.

@@            Coverage Diff             @@
##              dev     #739      +/-   ##
==========================================
+ Coverage   86.68%   86.90%   +0.21%     
==========================================
  Files         128      129       +1     
  Lines        8255     8414     +159     
  Branches     1422     1446      +24     
==========================================
+ Hits         7156     7312     +156     
- Misses        885      886       +1     
- Partials      214      216       +2     
Flag Coverage Δ
unittests 86.81% <96.85%> (+0.19%) ⬆️

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

Impacted Files Coverage Δ
mmcls/models/backbones/van.py 96.83% <96.83%> (ø)
mmcls/models/backbones/__init__.py 100.00% <100.00%> (ø)
mmcls/datasets/builder.py 91.04% <0.00%> (+1.49%) ⬆️
mmcls/utils/setup_env.py 100.00% <0.00%> (+4.54%) ⬆️

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 6beac50...8e11e3b. Read the comment docs.

@Ezra-Yu
Copy link
Collaborator

Ezra-Yu commented Apr 2, 2022

Thank you for your great contribution, please fix the conflicts!

Could you provide us with the converted checkpoints for imagenet-1k dataset? you can refer to the convert-scripts like twins2mmcls. The weights can be uploaded to Google Driver or TmpLink or just provide the convert script.

@okotaku
Copy link
Collaborator Author

okotaku commented Apr 4, 2022

@Ezra-Yu
http://tmp.link/f/624a4df33256d
http://tmp.link/f/624a4e02a47eb
http://tmp.link/f/624a4e0b28ba8
http://tmp.link/f/624a4e0dbbfc1

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.

  1. Please fix the conficts
  2. try to use mmcv config init

i will complete the checkpoints and docs including metafile later.

mmcls/models/backbones/van.py Show resolved Hide resolved
mmcls/models/backbones/van.py Outdated Show resolved Hide resolved
configs/van/README.md Outdated Show resolved Hide resolved
mmcls/models/backbones/van.py Outdated Show resolved Hide resolved
mmcls/models/backbones/van.py Outdated Show resolved Hide resolved
mmcls/models/backbones/van.py Show resolved Hide resolved
mmcls/models/backbones/van.py Outdated Show resolved Hide resolved
mmcls/models/backbones/van.py Outdated Show resolved Hide resolved
mmcls/models/backbones/van.py Outdated Show resolved Hide resolved
mmcls/models/backbones/van.py Outdated Show resolved Hide resolved
@CLAassistant
Copy link

CLAassistant commented Apr 19, 2022

CLA assistant check
All committers have signed the CLA.

@okotaku okotaku requested a review from Ezra-Yu April 19, 2022 09:24
@ZwwWayne
Copy link
Contributor

Would be great if the PR message could also show the example config in downstream repos like mmseg/mmdet

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 df6edd7 into open-mmlab:dev Apr 28, 2022
ayulockin pushed a commit to ayulockin/mmclassification that referenced this pull request May 6, 2022
* [Enhance] Add extra dataloader settings in configs. (open-mmlab#752)

* Use `train_dataloader`, `val_dataloader` and `test_dataloader` settings
in the `data` field to specify different arguments.

* Fix bug

* Fix bug

* [Enhance] Improve CPE performance by reduce memory copy. (open-mmlab#762)

* [Feature] Support resize relative position embedding in `SwinTransformer`. (open-mmlab#749)

* [Feature]: Add resize rel pos embed

* [Refactor]: Create a separated resize_rel_pos_bias_table func

* [Refactor]: Refactor rel pos embed bias

* [Refactor]: Move interpolate into func

* Remove index buffer only when window_size changes

Co-authored-by: mzr1996 <mzr1996@163.com>

* [Feature] Add PoolFormer backbone and checkpoints. (open-mmlab#746)

* add PoolFormer

* fix some typos in PoolFormer

* fix lint error

* modify out_indices and gap

* fix typo

* fix lint

* fix typo

* fix typo in poolforemr README

* fix lint

* Update some paths

* Refactor freeze_stages method

* Add unit tests

* Fix lint

Co-authored-by: mzr1996 <mzr1996@163.com>

* Bump version to v0.22.1 (open-mmlab#785)

* [Docs] Refine API reference. (open-mmlab#774)

* [Docs] Refine API reference

* Add PoolFormer

* [Docs] Fix docs.

* [Enhance] Reduce the memory usage of unit tests for Swin-Transformer. (open-mmlab#759)

* [Feature] Support VAN. (open-mmlab#739)

* add van

* fix config

* add metafile

* add test

* model convert script

* fix review

* fix lint

* fix the configs and improve docs

* rm debug lines

* add VAN into api

Co-authored-by: Yu Zhaohui <1105212286@qq.com>

* [Feature] Support DenseNet. (open-mmlab#750)

* init add densenet implementation

* Add config and converted models

* update meta

* add test for memory efficient

* Add docs

* add doc for jit

* Update checkpoint path

* Update readthedocs

Co-authored-by: mzr1996 <mzr1996@163.com>

* [Fix] Use symbolic link in the API reference of Chinese docs.

* [Enhance] Support training on IPU and add fine-tuning configs of ViT. (open-mmlab#723)

* implement training and evaluation on IPU

* fp16 SOTA

* Tput reaches 5600

* 123

* add poptorch dataloder

* change ipu_replicas to ipu-replicas

* add noqa to config long line(website)

* remove ipu dataloder test code

* del one blank line in test_builder

* refine the dataloder initialization

* fix a typo

* refine args for dataloder

* remove an annoted line

* process one more conflict

* adjust code structure in mmcv.ipu

* adjust ipu code structure in mmcv

* IPUDataloader to IPUDataLoader

* align with mmcv

* adjust according to mmcv

* mmcv code structre fixed

Co-authored-by: hudi <dihu@graphcore.ai>

* [Fix] Fix lint and mmcv version requirement for IPU.

* Bump version to v0.23.0 (open-mmlab#809)

* Refacoter Wandb hook and refine docstring

Co-authored-by: XiaobingZhang <xiaobing.zhang@intel.com>
Co-authored-by: Yuan Liu <30762564+YuanLiuuuuuu@users.noreply.github.com>
Co-authored-by: Weihao Yu <1090924009@qq.com>
Co-authored-by: takuoko <to78314910@gmail.com>
Co-authored-by: Yu Zhaohui <1105212286@qq.com>
Co-authored-by: Hubert <42952108+yingfhu@users.noreply.github.com>
Co-authored-by: Hu Di <476658825@qq.com>
Co-authored-by: hudi <dihu@graphcore.ai>
mzr1996 added a commit that referenced this pull request Jun 2, 2022
…Biases Integration) (#764)

* wandb integration

* visualize using wandb tables

* wandb tables enhanced

* Refactor MMClsWandbHook (#1)

* [Enhance] Add extra dataloader settings in configs. (#752)

* Use `train_dataloader`, `val_dataloader` and `test_dataloader` settings
in the `data` field to specify different arguments.

* Fix bug

* Fix bug

* [Enhance] Improve CPE performance by reduce memory copy. (#762)

* [Feature] Support resize relative position embedding in `SwinTransformer`. (#749)

* [Feature]: Add resize rel pos embed

* [Refactor]: Create a separated resize_rel_pos_bias_table func

* [Refactor]: Refactor rel pos embed bias

* [Refactor]: Move interpolate into func

* Remove index buffer only when window_size changes

Co-authored-by: mzr1996 <mzr1996@163.com>

* [Feature] Add PoolFormer backbone and checkpoints. (#746)

* add PoolFormer

* fix some typos in PoolFormer

* fix lint error

* modify out_indices and gap

* fix typo

* fix lint

* fix typo

* fix typo in poolforemr README

* fix lint

* Update some paths

* Refactor freeze_stages method

* Add unit tests

* Fix lint

Co-authored-by: mzr1996 <mzr1996@163.com>

* Bump version to v0.22.1 (#785)

* [Docs] Refine API reference. (#774)

* [Docs] Refine API reference

* Add PoolFormer

* [Docs] Fix docs.

* [Enhance] Reduce the memory usage of unit tests for Swin-Transformer. (#759)

* [Feature] Support VAN. (#739)

* add van

* fix config

* add metafile

* add test

* model convert script

* fix review

* fix lint

* fix the configs and improve docs

* rm debug lines

* add VAN into api

Co-authored-by: Yu Zhaohui <1105212286@qq.com>

* [Feature] Support DenseNet. (#750)

* init add densenet implementation

* Add config and converted models

* update meta

* add test for memory efficient

* Add docs

* add doc for jit

* Update checkpoint path

* Update readthedocs

Co-authored-by: mzr1996 <mzr1996@163.com>

* [Fix] Use symbolic link in the API reference of Chinese docs.

* [Enhance] Support training on IPU and add fine-tuning configs of ViT. (#723)

* implement training and evaluation on IPU

* fp16 SOTA

* Tput reaches 5600

* 123

* add poptorch dataloder

* change ipu_replicas to ipu-replicas

* add noqa to config long line(website)

* remove ipu dataloder test code

* del one blank line in test_builder

* refine the dataloder initialization

* fix a typo

* refine args for dataloder

* remove an annoted line

* process one more conflict

* adjust code structure in mmcv.ipu

* adjust ipu code structure in mmcv

* IPUDataloader to IPUDataLoader

* align with mmcv

* adjust according to mmcv

* mmcv code structre fixed

Co-authored-by: hudi <dihu@graphcore.ai>

* [Fix] Fix lint and mmcv version requirement for IPU.

* Bump version to v0.23.0 (#809)

* Refacoter Wandb hook and refine docstring

Co-authored-by: XiaobingZhang <xiaobing.zhang@intel.com>
Co-authored-by: Yuan Liu <30762564+YuanLiuuuuuu@users.noreply.github.com>
Co-authored-by: Weihao Yu <1090924009@qq.com>
Co-authored-by: takuoko <to78314910@gmail.com>
Co-authored-by: Yu Zhaohui <1105212286@qq.com>
Co-authored-by: Hubert <42952108+yingfhu@users.noreply.github.com>
Co-authored-by: Hu Di <476658825@qq.com>
Co-authored-by: hudi <dihu@graphcore.ai>

* shuffle val data

* minor updates

* minor fix

Co-authored-by: Ma Zerun <mzr1996@163.com>
Co-authored-by: XiaobingZhang <xiaobing.zhang@intel.com>
Co-authored-by: Yuan Liu <30762564+YuanLiuuuuuu@users.noreply.github.com>
Co-authored-by: Weihao Yu <1090924009@qq.com>
Co-authored-by: takuoko <to78314910@gmail.com>
Co-authored-by: Yu Zhaohui <1105212286@qq.com>
Co-authored-by: Hubert <42952108+yingfhu@users.noreply.github.com>
Co-authored-by: Hu Di <476658825@qq.com>
Co-authored-by: hudi <dihu@graphcore.ai>
mzr1996 pushed a commit to mzr1996/mmpretrain that referenced this pull request Nov 24, 2022
* add van

* fix config

* add metafile

* add test

* model convert script

* fix review

* fix lint

* fix the configs and improve docs

* rm debug lines

* add VAN into api

Co-authored-by: Yu Zhaohui <1105212286@qq.com>
mzr1996 added a commit to mzr1996/mmpretrain that referenced this pull request Nov 24, 2022
…Biases Integration) (open-mmlab#764)

* wandb integration

* visualize using wandb tables

* wandb tables enhanced

* Refactor MMClsWandbHook (open-mmlab#1)

* [Enhance] Add extra dataloader settings in configs. (open-mmlab#752)

* Use `train_dataloader`, `val_dataloader` and `test_dataloader` settings
in the `data` field to specify different arguments.

* Fix bug

* Fix bug

* [Enhance] Improve CPE performance by reduce memory copy. (open-mmlab#762)

* [Feature] Support resize relative position embedding in `SwinTransformer`. (open-mmlab#749)

* [Feature]: Add resize rel pos embed

* [Refactor]: Create a separated resize_rel_pos_bias_table func

* [Refactor]: Refactor rel pos embed bias

* [Refactor]: Move interpolate into func

* Remove index buffer only when window_size changes

Co-authored-by: mzr1996 <mzr1996@163.com>

* [Feature] Add PoolFormer backbone and checkpoints. (open-mmlab#746)

* add PoolFormer

* fix some typos in PoolFormer

* fix lint error

* modify out_indices and gap

* fix typo

* fix lint

* fix typo

* fix typo in poolforemr README

* fix lint

* Update some paths

* Refactor freeze_stages method

* Add unit tests

* Fix lint

Co-authored-by: mzr1996 <mzr1996@163.com>

* Bump version to v0.22.1 (open-mmlab#785)

* [Docs] Refine API reference. (open-mmlab#774)

* [Docs] Refine API reference

* Add PoolFormer

* [Docs] Fix docs.

* [Enhance] Reduce the memory usage of unit tests for Swin-Transformer. (open-mmlab#759)

* [Feature] Support VAN. (open-mmlab#739)

* add van

* fix config

* add metafile

* add test

* model convert script

* fix review

* fix lint

* fix the configs and improve docs

* rm debug lines

* add VAN into api

Co-authored-by: Yu Zhaohui <1105212286@qq.com>

* [Feature] Support DenseNet. (open-mmlab#750)

* init add densenet implementation

* Add config and converted models

* update meta

* add test for memory efficient

* Add docs

* add doc for jit

* Update checkpoint path

* Update readthedocs

Co-authored-by: mzr1996 <mzr1996@163.com>

* [Fix] Use symbolic link in the API reference of Chinese docs.

* [Enhance] Support training on IPU and add fine-tuning configs of ViT. (open-mmlab#723)

* implement training and evaluation on IPU

* fp16 SOTA

* Tput reaches 5600

* 123

* add poptorch dataloder

* change ipu_replicas to ipu-replicas

* add noqa to config long line(website)

* remove ipu dataloder test code

* del one blank line in test_builder

* refine the dataloder initialization

* fix a typo

* refine args for dataloder

* remove an annoted line

* process one more conflict

* adjust code structure in mmcv.ipu

* adjust ipu code structure in mmcv

* IPUDataloader to IPUDataLoader

* align with mmcv

* adjust according to mmcv

* mmcv code structre fixed

Co-authored-by: hudi <dihu@graphcore.ai>

* [Fix] Fix lint and mmcv version requirement for IPU.

* Bump version to v0.23.0 (open-mmlab#809)

* Refacoter Wandb hook and refine docstring

Co-authored-by: XiaobingZhang <xiaobing.zhang@intel.com>
Co-authored-by: Yuan Liu <30762564+YuanLiuuuuuu@users.noreply.github.com>
Co-authored-by: Weihao Yu <1090924009@qq.com>
Co-authored-by: takuoko <to78314910@gmail.com>
Co-authored-by: Yu Zhaohui <1105212286@qq.com>
Co-authored-by: Hubert <42952108+yingfhu@users.noreply.github.com>
Co-authored-by: Hu Di <476658825@qq.com>
Co-authored-by: hudi <dihu@graphcore.ai>

* shuffle val data

* minor updates

* minor fix

Co-authored-by: Ma Zerun <mzr1996@163.com>
Co-authored-by: XiaobingZhang <xiaobing.zhang@intel.com>
Co-authored-by: Yuan Liu <30762564+YuanLiuuuuuu@users.noreply.github.com>
Co-authored-by: Weihao Yu <1090924009@qq.com>
Co-authored-by: takuoko <to78314910@gmail.com>
Co-authored-by: Yu Zhaohui <1105212286@qq.com>
Co-authored-by: Hubert <42952108+yingfhu@users.noreply.github.com>
Co-authored-by: Hu Di <476658825@qq.com>
Co-authored-by: hudi <dihu@graphcore.ai>
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

5 participants