Skip to content

Plug-in version implementation #20

@zjykzj

Description

@zjykzj

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions