retinanet_effb3_fpn_8xb4-crop896-1x_coco.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. _base_ = [
  2. '../_base_/models/retinanet_r50_fpn.py',
  3. '../_base_/schedules/schedule_1x.py',
  4. '../_base_/datasets/coco_detection.py', '../_base_/default_runtime.py'
  5. ]
  6. image_size = (896, 896)
  7. batch_augments = [dict(type='BatchFixedSizePad', size=image_size)]
  8. norm_cfg = dict(type='BN', requires_grad=True)
  9. checkpoint = 'https://download.openmmlab.com/mmclassification/v0/efficientnet/efficientnet-b3_3rdparty_8xb32-aa_in1k_20220119-5b4887a0.pth' # noqa
  10. model = dict(
  11. data_preprocessor=dict(
  12. type='DetDataPreprocessor',
  13. mean=[123.675, 116.28, 103.53],
  14. std=[58.395, 57.12, 57.375],
  15. bgr_to_rgb=True,
  16. pad_size_divisor=32,
  17. batch_augments=batch_augments),
  18. backbone=dict(
  19. _delete_=True,
  20. type='EfficientNet',
  21. arch='b3',
  22. drop_path_rate=0.2,
  23. out_indices=(3, 4, 5),
  24. frozen_stages=0,
  25. norm_cfg=dict(
  26. type='SyncBN', requires_grad=True, eps=1e-3, momentum=0.01),
  27. norm_eval=False,
  28. init_cfg=dict(
  29. type='Pretrained', prefix='backbone', checkpoint=checkpoint)),
  30. neck=dict(
  31. in_channels=[48, 136, 384],
  32. start_level=0,
  33. out_channels=256,
  34. relu_before_extra_convs=True,
  35. no_norm_on_lateral=True,
  36. norm_cfg=norm_cfg),
  37. bbox_head=dict(type='RetinaSepBNHead', num_ins=5, norm_cfg=norm_cfg),
  38. # training and testing settings
  39. train_cfg=dict(assigner=dict(neg_iou_thr=0.5)))
  40. # dataset settings
  41. train_pipeline = [
  42. dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}),
  43. dict(type='LoadAnnotations', with_bbox=True),
  44. dict(
  45. type='RandomResize',
  46. scale=image_size,
  47. ratio_range=(0.8, 1.2),
  48. keep_ratio=True),
  49. dict(type='RandomCrop', crop_size=image_size),
  50. dict(type='RandomFlip', prob=0.5),
  51. dict(type='PackDetInputs')
  52. ]
  53. test_pipeline = [
  54. dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}),
  55. dict(type='Resize', scale=image_size, keep_ratio=True),
  56. dict(type='LoadAnnotations', with_bbox=True),
  57. dict(
  58. type='PackDetInputs',
  59. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  60. 'scale_factor'))
  61. ]
  62. train_dataloader = dict(
  63. batch_size=4, num_workers=4, dataset=dict(pipeline=train_pipeline))
  64. val_dataloader = dict(dataset=dict(pipeline=test_pipeline))
  65. test_dataloader = val_dataloader
  66. # optimizer
  67. optim_wrapper = dict(
  68. optimizer=dict(lr=0.04),
  69. paramwise_cfg=dict(norm_decay_mult=0, bypass_duplicate=True))
  70. # learning policy
  71. max_epochs = 12
  72. param_scheduler = [
  73. dict(type='LinearLR', start_factor=0.1, by_epoch=False, begin=0, end=1000),
  74. dict(
  75. type='MultiStepLR',
  76. begin=0,
  77. end=max_epochs,
  78. by_epoch=True,
  79. milestones=[8, 11],
  80. gamma=0.1)
  81. ]
  82. train_cfg = dict(max_epochs=max_epochs)
  83. # cudnn_benchmark=True can accelerate fix-size training
  84. env_cfg = dict(cudnn_benchmark=True)
  85. # NOTE: `auto_scale_lr` is for automatically scaling LR,
  86. # USER SHOULD NOT CHANGE ITS VALUES.
  87. # base_batch_size = (8 GPUs) x (4 samples per GPU)
  88. auto_scale_lr = dict(base_batch_size=32)