mask-rcnn_convnext-t-p4-w7_fpn_amp-ms-crop-3x_coco.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. _base_ = [
  2. '../_base_/models/mask-rcnn_r50_fpn.py',
  3. '../_base_/datasets/coco_instance.py',
  4. '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
  5. ]
  6. # TODO: delete custom_imports after mmcls supports auto import
  7. # please install mmcls>=1.0
  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/downstream/convnext-tiny_3rdparty_32xb128-noema_in1k_20220301-795e9634.pth' # noqa
  11. model = dict(
  12. backbone=dict(
  13. _delete_=True,
  14. type='mmcls.ConvNeXt',
  15. arch='tiny',
  16. out_indices=[0, 1, 2, 3],
  17. drop_path_rate=0.4,
  18. layer_scale_init_value=1.0,
  19. gap_before_final_norm=False,
  20. init_cfg=dict(
  21. type='Pretrained', checkpoint=checkpoint_file,
  22. prefix='backbone.')),
  23. neck=dict(in_channels=[96, 192, 384, 768]))
  24. # augmentation strategy originates from DETR / Sparse RCNN
  25. train_pipeline = [
  26. dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}),
  27. dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
  28. dict(type='RandomFlip', prob=0.5),
  29. dict(
  30. type='RandomChoice',
  31. transforms=[[
  32. dict(
  33. type='RandomChoiceResize',
  34. scales=[(480, 1333), (512, 1333), (544, 1333), (576, 1333),
  35. (608, 1333), (640, 1333), (672, 1333), (704, 1333),
  36. (736, 1333), (768, 1333), (800, 1333)],
  37. keep_ratio=True)
  38. ],
  39. [
  40. dict(
  41. type='RandomChoiceResize',
  42. scales=[(400, 1333), (500, 1333), (600, 1333)],
  43. keep_ratio=True),
  44. dict(
  45. type='RandomCrop',
  46. crop_type='absolute_range',
  47. crop_size=(384, 600),
  48. allow_negative_crop=True),
  49. dict(
  50. type='RandomChoiceResize',
  51. scales=[(480, 1333), (512, 1333), (544, 1333),
  52. (576, 1333), (608, 1333), (640, 1333),
  53. (672, 1333), (704, 1333), (736, 1333),
  54. (768, 1333), (800, 1333)],
  55. keep_ratio=True)
  56. ]]),
  57. dict(type='PackDetInputs')
  58. ]
  59. train_dataloader = dict(dataset=dict(pipeline=train_pipeline))
  60. max_epochs = 36
  61. train_cfg = dict(max_epochs=max_epochs)
  62. # learning rate
  63. param_scheduler = [
  64. dict(
  65. type='LinearLR', start_factor=0.001, by_epoch=False, begin=0,
  66. end=1000),
  67. dict(
  68. type='MultiStepLR',
  69. begin=0,
  70. end=max_epochs,
  71. by_epoch=True,
  72. milestones=[27, 33],
  73. gamma=0.1)
  74. ]
  75. # Enable automatic-mixed-precision training with AmpOptimWrapper.
  76. optim_wrapper = dict(
  77. type='AmpOptimWrapper',
  78. constructor='LearningRateDecayOptimizerConstructor',
  79. paramwise_cfg={
  80. 'decay_rate': 0.95,
  81. 'decay_type': 'layer_wise',
  82. 'num_layers': 6
  83. },
  84. optimizer=dict(
  85. _delete_=True,
  86. type='AdamW',
  87. lr=0.0001,
  88. betas=(0.9, 0.999),
  89. weight_decay=0.05,
  90. ))