centripetalnet_hourglass104_16xb6-crop511-210e-mstest_coco.py 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. _base_ = [
  2. '../_base_/default_runtime.py', '../_base_/datasets/coco_detection.py'
  3. ]
  4. data_preprocessor = dict(
  5. type='DetDataPreprocessor',
  6. mean=[123.675, 116.28, 103.53],
  7. std=[58.395, 57.12, 57.375],
  8. bgr_to_rgb=True)
  9. # model settings
  10. model = dict(
  11. type='CornerNet',
  12. data_preprocessor=data_preprocessor,
  13. backbone=dict(
  14. type='HourglassNet',
  15. downsample_times=5,
  16. num_stacks=2,
  17. stage_channels=[256, 256, 384, 384, 384, 512],
  18. stage_blocks=[2, 2, 2, 2, 2, 4],
  19. norm_cfg=dict(type='BN', requires_grad=True)),
  20. neck=None,
  21. bbox_head=dict(
  22. type='CentripetalHead',
  23. num_classes=80,
  24. in_channels=256,
  25. num_feat_levels=2,
  26. corner_emb_channels=0,
  27. loss_heatmap=dict(
  28. type='GaussianFocalLoss', alpha=2.0, gamma=4.0, loss_weight=1),
  29. loss_offset=dict(type='SmoothL1Loss', beta=1.0, loss_weight=1),
  30. loss_guiding_shift=dict(
  31. type='SmoothL1Loss', beta=1.0, loss_weight=0.05),
  32. loss_centripetal_shift=dict(
  33. type='SmoothL1Loss', beta=1.0, loss_weight=1)),
  34. # training and testing settings
  35. train_cfg=None,
  36. test_cfg=dict(
  37. corner_topk=100,
  38. local_maximum_kernel=3,
  39. distance_threshold=0.5,
  40. score_thr=0.05,
  41. max_per_img=100,
  42. nms=dict(type='soft_nms', iou_threshold=0.5, method='gaussian')))
  43. # data settings
  44. train_pipeline = [
  45. dict(type='LoadImageFromFile', backend_args=_base_.backend_args),
  46. dict(type='LoadAnnotations', with_bbox=True),
  47. dict(
  48. type='PhotoMetricDistortion',
  49. brightness_delta=32,
  50. contrast_range=(0.5, 1.5),
  51. saturation_range=(0.5, 1.5),
  52. hue_delta=18),
  53. dict(
  54. # The cropped images are padded into squares during training,
  55. # but may be smaller than crop_size.
  56. type='RandomCenterCropPad',
  57. crop_size=(511, 511),
  58. ratios=(0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3),
  59. test_mode=False,
  60. test_pad_mode=None,
  61. mean=data_preprocessor['mean'],
  62. std=data_preprocessor['std'],
  63. # Image data is not converted to rgb.
  64. to_rgb=data_preprocessor['bgr_to_rgb']),
  65. dict(type='Resize', scale=(511, 511), keep_ratio=False),
  66. dict(type='RandomFlip', prob=0.5),
  67. dict(type='PackDetInputs'),
  68. ]
  69. test_pipeline = [
  70. dict(
  71. type='LoadImageFromFile',
  72. to_float32=True,
  73. backend_args=_base_.backend_args),
  74. # don't need Resize
  75. dict(
  76. type='RandomCenterCropPad',
  77. crop_size=None,
  78. ratios=None,
  79. border=None,
  80. test_mode=True,
  81. test_pad_mode=['logical_or', 127],
  82. mean=data_preprocessor['mean'],
  83. std=data_preprocessor['std'],
  84. # Image data is not converted to rgb.
  85. to_rgb=data_preprocessor['bgr_to_rgb']),
  86. dict(type='LoadAnnotations', with_bbox=True),
  87. dict(
  88. type='PackDetInputs',
  89. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'border'))
  90. ]
  91. train_dataloader = dict(
  92. batch_size=6,
  93. num_workers=3,
  94. batch_sampler=None,
  95. dataset=dict(pipeline=train_pipeline))
  96. val_dataloader = dict(dataset=dict(pipeline=test_pipeline))
  97. test_dataloader = val_dataloader
  98. # optimizer
  99. optim_wrapper = dict(
  100. type='OptimWrapper',
  101. optimizer=dict(type='Adam', lr=0.0005),
  102. clip_grad=dict(max_norm=35, norm_type=2))
  103. max_epochs = 210
  104. # learning rate
  105. param_scheduler = [
  106. dict(
  107. type='LinearLR',
  108. start_factor=1.0 / 3,
  109. by_epoch=False,
  110. begin=0,
  111. end=500),
  112. dict(
  113. type='MultiStepLR',
  114. begin=0,
  115. end=max_epochs,
  116. by_epoch=True,
  117. milestones=[190],
  118. gamma=0.1)
  119. ]
  120. train_cfg = dict(
  121. type='EpochBasedTrainLoop', max_epochs=max_epochs, val_interval=1)
  122. val_cfg = dict(type='ValLoop')
  123. test_cfg = dict(type='TestLoop')
  124. # NOTE: `auto_scale_lr` is for automatically scaling LR,
  125. # USER SHOULD NOT CHANGE ITS VALUES.
  126. # base_batch_size = (16 GPUs) x (6 samples per GPU)
  127. auto_scale_lr = dict(base_batch_size=96)
  128. tta_model = dict(
  129. type='DetTTAModel',
  130. tta_cfg=dict(
  131. nms=dict(type='soft_nms', iou_threshold=0.5, method='gaussian'),
  132. max_per_img=100))
  133. tta_pipeline = [
  134. dict(
  135. type='LoadImageFromFile',
  136. to_float32=True,
  137. backend_args=_base_.backend_args),
  138. dict(
  139. type='TestTimeAug',
  140. transforms=[
  141. [
  142. # ``RandomFlip`` must be placed before ``RandomCenterCropPad``,
  143. # otherwise bounding box coordinates after flipping cannot be
  144. # recovered correctly.
  145. dict(type='RandomFlip', prob=1.),
  146. dict(type='RandomFlip', prob=0.)
  147. ],
  148. [
  149. dict(
  150. type='RandomCenterCropPad',
  151. crop_size=None,
  152. ratios=None,
  153. border=None,
  154. test_mode=True,
  155. test_pad_mode=['logical_or', 127],
  156. mean=data_preprocessor['mean'],
  157. std=data_preprocessor['std'],
  158. # Image data is not converted to rgb.
  159. to_rgb=data_preprocessor['bgr_to_rgb'])
  160. ],
  161. [dict(type='LoadAnnotations', with_bbox=True)],
  162. [
  163. dict(
  164. type='PackDetInputs',
  165. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  166. 'flip', 'flip_direction', 'border'))
  167. ]
  168. ])
  169. ]