| 
 | 1 | +_base_ = [  | 
 | 2 | +    'mmdet::_base_/models/mask-rcnn_r50_fpn.py',  | 
 | 3 | +    'mmdet::_base_/datasets/coco_instance.py',  | 
 | 4 | +    'mmdet::_base_/schedules/schedule_1x.py',  | 
 | 5 | +    'mmdet::_base_/default_runtime.py'  | 
 | 6 | +]  | 
 | 7 | + | 
 | 8 | +# please install the mmclassification dev-1.x branch  | 
 | 9 | +# import mmcls.models to trigger register_module in mmcls  | 
 | 10 | +custom_imports = dict(imports=['mmcls.models'], allow_failed_imports=False)  | 
 | 11 | +checkpoint_file = 'https://download.openmmlab.com/mmclassification/v0/convnext-v2/convnext-v2-base_3rdparty-fcmae_in1k_20230104-8a798eaf.pth'  # noqa  | 
 | 12 | +image_size = (1024, 1024)  | 
 | 13 | + | 
 | 14 | +model = dict(  | 
 | 15 | +    backbone=dict(  | 
 | 16 | +        _delete_=True,  | 
 | 17 | +        type='mmcls.ConvNeXt',  | 
 | 18 | +        arch='base',  | 
 | 19 | +        out_indices=[0, 1, 2, 3],  | 
 | 20 | +        # TODO: verify stochastic depth rate {0.1, 0.2, 0.3, 0.4}  | 
 | 21 | +        drop_path_rate=0.4,  | 
 | 22 | +        layer_scale_init_value=0.,  # disable layer scale when using GRN  | 
 | 23 | +        gap_before_final_norm=False,  | 
 | 24 | +        use_grn=True,  # V2 uses GRN  | 
 | 25 | +        init_cfg=dict(  | 
 | 26 | +            type='Pretrained', checkpoint=checkpoint_file,  | 
 | 27 | +            prefix='backbone.')),  | 
 | 28 | +    neck=dict(in_channels=[128, 256, 512, 1024]),  | 
 | 29 | +    test_cfg=dict(  | 
 | 30 | +        rpn=dict(nms=dict(type='nms')),  # TODO: does RPN use soft_nms?  | 
 | 31 | +        rcnn=dict(nms=dict(type='soft_nms'))))  | 
 | 32 | + | 
 | 33 | +train_pipeline = [  | 
 | 34 | +    dict(type='LoadImageFromFile', file_client_args=_base_.file_client_args),  | 
 | 35 | +    dict(type='LoadAnnotations', with_bbox=True, with_mask=True),  | 
 | 36 | +    dict(  | 
 | 37 | +        type='RandomResize',  | 
 | 38 | +        scale=image_size,  | 
 | 39 | +        ratio_range=(0.1, 2.0),  | 
 | 40 | +        keep_ratio=True),  | 
 | 41 | +    dict(  | 
 | 42 | +        type='RandomCrop',  | 
 | 43 | +        crop_type='absolute_range',  | 
 | 44 | +        crop_size=image_size,  | 
 | 45 | +        recompute_bbox=True,  | 
 | 46 | +        allow_negative_crop=True),  | 
 | 47 | +    dict(type='FilterAnnotations', min_gt_bbox_wh=(1e-2, 1e-2)),  | 
 | 48 | +    dict(type='RandomFlip', prob=0.5),  | 
 | 49 | +    dict(type='PackDetInputs')  | 
 | 50 | +]  | 
 | 51 | + | 
 | 52 | +train_dataloader = dict(  | 
 | 53 | +    batch_size=4,  # total_batch_size 32 = 8 GPUS x 4 images  | 
 | 54 | +    num_workers=8,  | 
 | 55 | +    dataset=dict(pipeline=train_pipeline))  | 
 | 56 | + | 
 | 57 | +max_epochs = 36  | 
 | 58 | +train_cfg = dict(max_epochs=max_epochs)  | 
 | 59 | + | 
 | 60 | +# learning rate  | 
 | 61 | +param_scheduler = [  | 
 | 62 | +    dict(  | 
 | 63 | +        type='LinearLR', start_factor=0.001, by_epoch=False, begin=0,  | 
 | 64 | +        end=1000),  | 
 | 65 | +    dict(  | 
 | 66 | +        type='MultiStepLR',  | 
 | 67 | +        begin=0,  | 
 | 68 | +        end=max_epochs,  | 
 | 69 | +        by_epoch=True,  | 
 | 70 | +        milestones=[27, 33],  | 
 | 71 | +        gamma=0.1)  | 
 | 72 | +]  | 
 | 73 | + | 
 | 74 | +# Enable automatic-mixed-precision training with AmpOptimWrapper.  | 
 | 75 | +optim_wrapper = dict(  | 
 | 76 | +    type='AmpOptimWrapper',  | 
 | 77 | +    constructor='LearningRateDecayOptimizerConstructor',  | 
 | 78 | +    paramwise_cfg={  | 
 | 79 | +        'decay_rate': 0.95,  | 
 | 80 | +        'decay_type': 'layer_wise',  # TODO: sweep layer-wise lr decay?  | 
 | 81 | +        'num_layers': 12  | 
 | 82 | +    },  | 
 | 83 | +    optimizer=dict(  | 
 | 84 | +        _delete_=True,  | 
 | 85 | +        type='AdamW',  | 
 | 86 | +        lr=0.0001,  | 
 | 87 | +        betas=(0.9, 0.999),  | 
 | 88 | +        weight_decay=0.05,  | 
 | 89 | +    ))  | 
 | 90 | + | 
 | 91 | +default_hooks = dict(checkpoint=dict(max_keep_ckpts=1))  | 
0 commit comments