retinanet_r50_fpn_crop640-50e_coco.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. _base_ = [
  2. '../_base_/models/retinanet_r50_fpn.py',
  3. '../_base_/datasets/coco_detection.py',
  4. '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
  5. ]
  6. norm_cfg = dict(type='BN', requires_grad=True)
  7. model = dict(
  8. data_preprocessor=dict(
  9. type='DetDataPreprocessor',
  10. mean=[123.675, 116.28, 103.53],
  11. std=[58.395, 57.12, 57.375],
  12. bgr_to_rgb=True,
  13. pad_size_divisor=64,
  14. batch_augments=[dict(type='BatchFixedSizePad', size=(640, 640))]),
  15. backbone=dict(norm_eval=False),
  16. neck=dict(
  17. relu_before_extra_convs=True,
  18. no_norm_on_lateral=True,
  19. norm_cfg=norm_cfg),
  20. bbox_head=dict(type='RetinaSepBNHead', num_ins=5, norm_cfg=norm_cfg),
  21. # training and testing settings
  22. train_cfg=dict(assigner=dict(neg_iou_thr=0.5)))
  23. # dataset settings
  24. train_pipeline = [
  25. dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}),
  26. dict(type='LoadAnnotations', with_bbox=True),
  27. dict(
  28. type='RandomResize',
  29. scale=(640, 640),
  30. ratio_range=(0.8, 1.2),
  31. keep_ratio=True),
  32. dict(type='RandomCrop', crop_size=(640, 640)),
  33. dict(type='RandomFlip', prob=0.5),
  34. dict(type='PackDetInputs')
  35. ]
  36. test_pipeline = [
  37. dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}),
  38. dict(type='Resize', scale=(640, 640), keep_ratio=True),
  39. dict(type='LoadAnnotations', with_bbox=True),
  40. dict(
  41. type='PackDetInputs',
  42. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  43. 'scale_factor'))
  44. ]
  45. train_dataloader = dict(
  46. batch_size=8, num_workers=4, dataset=dict(pipeline=train_pipeline))
  47. val_dataloader = dict(dataset=dict(pipeline=test_pipeline))
  48. test_dataloader = val_dataloader
  49. # training schedule for 50e
  50. max_epochs = 50
  51. train_cfg = dict(max_epochs=max_epochs)
  52. # learning rate
  53. param_scheduler = [
  54. dict(type='LinearLR', start_factor=0.1, by_epoch=False, begin=0, end=1000),
  55. dict(
  56. type='MultiStepLR',
  57. begin=0,
  58. end=max_epochs,
  59. by_epoch=True,
  60. milestones=[30, 40],
  61. gamma=0.1)
  62. ]
  63. # optimizer
  64. optim_wrapper = dict(
  65. optimizer=dict(type='SGD', lr=0.08, momentum=0.9, weight_decay=0.0001),
  66. paramwise_cfg=dict(norm_decay_mult=0, bypass_duplicate=True))
  67. env_cfg = dict(cudnn_benchmark=True)
  68. # NOTE: `auto_scale_lr` is for automatically scaling LR,
  69. # USER SHOULD NOT CHANGE ITS VALUES.
  70. # base_batch_size = (8 GPUs) x (8 samples per GPU)
  71. auto_scale_lr = dict(base_batch_size=64)