cascade-mask-rcnn_convnext-t-p4-w7_fpn_4conv1fc-giou_amp-ms-crop-3x_coco.py 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. _base_ = [
  2. '../_base_/models/cascade-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. roi_head=dict(bbox_head=[
  25. dict(
  26. type='ConvFCBBoxHead',
  27. num_shared_convs=4,
  28. num_shared_fcs=1,
  29. in_channels=256,
  30. conv_out_channels=256,
  31. fc_out_channels=1024,
  32. roi_feat_size=7,
  33. num_classes=80,
  34. bbox_coder=dict(
  35. type='DeltaXYWHBBoxCoder',
  36. target_means=[0., 0., 0., 0.],
  37. target_stds=[0.1, 0.1, 0.2, 0.2]),
  38. reg_class_agnostic=False,
  39. reg_decoded_bbox=True,
  40. norm_cfg=dict(type='SyncBN', requires_grad=True),
  41. loss_cls=dict(
  42. type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
  43. loss_bbox=dict(type='GIoULoss', loss_weight=10.0)),
  44. dict(
  45. type='ConvFCBBoxHead',
  46. num_shared_convs=4,
  47. num_shared_fcs=1,
  48. in_channels=256,
  49. conv_out_channels=256,
  50. fc_out_channels=1024,
  51. roi_feat_size=7,
  52. num_classes=80,
  53. bbox_coder=dict(
  54. type='DeltaXYWHBBoxCoder',
  55. target_means=[0., 0., 0., 0.],
  56. target_stds=[0.05, 0.05, 0.1, 0.1]),
  57. reg_class_agnostic=False,
  58. reg_decoded_bbox=True,
  59. norm_cfg=dict(type='SyncBN', requires_grad=True),
  60. loss_cls=dict(
  61. type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
  62. loss_bbox=dict(type='GIoULoss', loss_weight=10.0)),
  63. dict(
  64. type='ConvFCBBoxHead',
  65. num_shared_convs=4,
  66. num_shared_fcs=1,
  67. in_channels=256,
  68. conv_out_channels=256,
  69. fc_out_channels=1024,
  70. roi_feat_size=7,
  71. num_classes=80,
  72. bbox_coder=dict(
  73. type='DeltaXYWHBBoxCoder',
  74. target_means=[0., 0., 0., 0.],
  75. target_stds=[0.033, 0.033, 0.067, 0.067]),
  76. reg_class_agnostic=False,
  77. reg_decoded_bbox=True,
  78. norm_cfg=dict(type='SyncBN', requires_grad=True),
  79. loss_cls=dict(
  80. type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
  81. loss_bbox=dict(type='GIoULoss', loss_weight=10.0))
  82. ]))
  83. # augmentation strategy originates from DETR / Sparse RCNN
  84. train_pipeline = [
  85. dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}),
  86. dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
  87. dict(type='RandomFlip', prob=0.5),
  88. dict(
  89. type='RandomChoice',
  90. transforms=[[
  91. dict(
  92. type='RandomChoiceResize',
  93. scales=[(480, 1333), (512, 1333), (544, 1333), (576, 1333),
  94. (608, 1333), (640, 1333), (672, 1333), (704, 1333),
  95. (736, 1333), (768, 1333), (800, 1333)],
  96. keep_ratio=True)
  97. ],
  98. [
  99. dict(
  100. type='RandomChoiceResize',
  101. scales=[(400, 1333), (500, 1333), (600, 1333)],
  102. keep_ratio=True),
  103. dict(
  104. type='RandomCrop',
  105. crop_type='absolute_range',
  106. crop_size=(384, 600),
  107. allow_negative_crop=True),
  108. dict(
  109. type='RandomChoiceResize',
  110. scales=[(480, 1333), (512, 1333), (544, 1333),
  111. (576, 1333), (608, 1333), (640, 1333),
  112. (672, 1333), (704, 1333), (736, 1333),
  113. (768, 1333), (800, 1333)],
  114. keep_ratio=True)
  115. ]]),
  116. dict(type='PackDetInputs')
  117. ]
  118. train_dataloader = dict(dataset=dict(pipeline=train_pipeline))
  119. max_epochs = 36
  120. train_cfg = dict(max_epochs=max_epochs)
  121. # learning rate
  122. param_scheduler = [
  123. dict(
  124. type='LinearLR', start_factor=0.001, by_epoch=False, begin=0,
  125. end=1000),
  126. dict(
  127. type='MultiStepLR',
  128. begin=0,
  129. end=max_epochs,
  130. by_epoch=True,
  131. milestones=[27, 33],
  132. gamma=0.1)
  133. ]
  134. # Enable automatic-mixed-precision training with AmpOptimWrapper.
  135. optim_wrapper = dict(
  136. type='AmpOptimWrapper',
  137. constructor='LearningRateDecayOptimizerConstructor',
  138. paramwise_cfg={
  139. 'decay_rate': 0.7,
  140. 'decay_type': 'layer_wise',
  141. 'num_layers': 6
  142. },
  143. optimizer=dict(
  144. _delete_=True,
  145. type='AdamW',
  146. lr=0.0002,
  147. betas=(0.9, 0.999),
  148. weight_decay=0.05))