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

Plug-in version implementation #20

Open
zjykzj opened this issue Jul 28, 2021 · 0 comments
Open

Plug-in version implementation #20

zjykzj opened this issue Jul 28, 2021 · 0 comments

Comments

@zjykzj
Copy link

zjykzj commented Jul 28, 2021

hi @DingXiaoH , nice work !!! According to borrows your implementation, I'm has realized a plug-in version of DiverseBranchBlock

This plug-in version has the following advantages:

  1. Do not modify original model
  2. After training, can fuse DBB to original architecture
  3. Support mixed insert/fuse operations for ACBlock/RepVGGBlock/DBBlock

How to insert

Use Config FIle

see rd50_dbb_cifar100_224_e100_sgd_calr.yaml

...
MODEL:
  CONV:
    TYPE: 'Conv2d'
    ADD_BLOCKS: ('DiverseBranchBlock',)
...

build resnet50_d with DDB

from zcls.config import cfg
from zcls.model.recognizers.build import build_recognizer

cfg.merge_from_file(args.config_file)
model = build_recognizer(cfg, device=torch.device('cpu'))

Test

see test_dbblock.py

How to fuse

see model_fuse.py

$ python tools/model_fuse.py --help
usage: model_fuse.py [-h] [--verbose] CONFIG_FILE OUTPUT_DIR

Fuse block for ACBlock/RepVGGBLock/DBBlock

positional arguments:
  CONFIG_FILE  path to config file
  OUTPUT_DIR   path to output

optional arguments:
  -h, --help   show this help message and exit
  --verbose    Print Model Info

Other

Structural Parameterization is really a nice idea !!! By using ACBlock, I improved model precision in a Dataset that is more bigger than ImageNet, hope DBB can make better precision

Last, thanks you again

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

No branches or pull requests

1 participant