mask-rcnn_convnext-v2-b_fpn_lsj-3x-fcmae_coco.py 2.8 KB

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