|
| 1 | +_base_ = [ |
| 2 | + '../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py', |
| 3 | + '../_base_/datasets/ade20k.py' |
| 4 | +] |
| 5 | +# model settings |
| 6 | +checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/segnext/mscan_t_20230227-119e8c9f.pth' # noqa |
| 7 | +ham_norm_cfg = dict(type='GN', num_groups=32, requires_grad=True) |
| 8 | +crop_size = (512, 512) |
| 9 | +data_preprocessor = dict( |
| 10 | + type='SegDataPreProcessor', |
| 11 | + mean=[123.675, 116.28, 103.53], |
| 12 | + std=[58.395, 57.12, 57.375], |
| 13 | + bgr_to_rgb=True, |
| 14 | + pad_val=0, |
| 15 | + seg_pad_val=255, |
| 16 | + size=(512, 512), |
| 17 | + test_cfg=dict(size_divisor=32)) |
| 18 | +model = dict( |
| 19 | + type='EncoderDecoder', |
| 20 | + data_preprocessor=data_preprocessor, |
| 21 | + pretrained=None, |
| 22 | + backbone=dict( |
| 23 | + type='MSCAN', |
| 24 | + init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file), |
| 25 | + embed_dims=[32, 64, 160, 256], |
| 26 | + mlp_ratios=[8, 8, 4, 4], |
| 27 | + drop_rate=0.0, |
| 28 | + drop_path_rate=0.1, |
| 29 | + depths=[3, 3, 5, 2], |
| 30 | + attention_kernel_sizes=[5, [1, 7], [1, 11], [1, 21]], |
| 31 | + attention_kernel_paddings=[2, [0, 3], [0, 5], [0, 10]], |
| 32 | + act_cfg=dict(type='GELU'), |
| 33 | + norm_cfg=dict(type='BN', requires_grad=True)), |
| 34 | + decode_head=dict( |
| 35 | + type='LightHamHead', |
| 36 | + in_channels=[64, 160, 256], |
| 37 | + in_index=[1, 2, 3], |
| 38 | + channels=256, |
| 39 | + ham_channels=256, |
| 40 | + dropout_ratio=0.1, |
| 41 | + num_classes=150, |
| 42 | + norm_cfg=ham_norm_cfg, |
| 43 | + align_corners=False, |
| 44 | + loss_decode=dict( |
| 45 | + type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0), |
| 46 | + ham_kwargs=dict( |
| 47 | + MD_S=1, |
| 48 | + MD_R=16, |
| 49 | + train_steps=6, |
| 50 | + eval_steps=7, |
| 51 | + inv_t=100, |
| 52 | + rand_init=True)), |
| 53 | + # model training and testing settings |
| 54 | + train_cfg=dict(), |
| 55 | + test_cfg=dict(mode='whole')) |
| 56 | + |
| 57 | +# dataset settings |
| 58 | +train_dataloader = dict(batch_size=16) |
| 59 | + |
| 60 | +# optimizer |
| 61 | +optim_wrapper = dict( |
| 62 | + _delete_=True, |
| 63 | + type='OptimWrapper', |
| 64 | + optimizer=dict( |
| 65 | + type='AdamW', lr=0.00006, betas=(0.9, 0.999), weight_decay=0.01), |
| 66 | + paramwise_cfg=dict( |
| 67 | + custom_keys={ |
| 68 | + 'pos_block': dict(decay_mult=0.), |
| 69 | + 'norm': dict(decay_mult=0.), |
| 70 | + 'head': dict(lr_mult=10.) |
| 71 | + })) |
| 72 | + |
| 73 | +param_scheduler = [ |
| 74 | + dict( |
| 75 | + type='LinearLR', start_factor=1e-6, by_epoch=False, begin=0, end=1500), |
| 76 | + dict( |
| 77 | + type='PolyLR', |
| 78 | + power=1.0, |
| 79 | + begin=1500, |
| 80 | + end=160000, |
| 81 | + eta_min=0.0, |
| 82 | + by_epoch=False, |
| 83 | + ) |
| 84 | +] |
0 commit comments