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

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