ssj_270k_coco-instance.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. _base_ = '../_base_/default_runtime.py'
  2. # dataset settings
  3. dataset_type = 'CocoDataset'
  4. data_root = 'data/coco/'
  5. image_size = (1024, 1024)
  6. # Example to use different file client
  7. # Method 1: simply set the data root and let the file I/O module
  8. # automatically infer from prefix (not support LMDB and Memcache yet)
  9. # data_root = 's3://openmmlab/datasets/detection/coco/'
  10. # Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6
  11. # backend_args = dict(
  12. # backend='petrel',
  13. # path_mapping=dict({
  14. # './data/': 's3://openmmlab/datasets/detection/',
  15. # 'data/': 's3://openmmlab/datasets/detection/'
  16. # }))
  17. backend_args = None
  18. # Standard Scale Jittering (SSJ) resizes and crops an image
  19. # with a resize range of 0.8 to 1.25 of the original image size.
  20. train_pipeline = [
  21. dict(type='LoadImageFromFile', backend_args=backend_args),
  22. dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
  23. dict(
  24. type='RandomResize',
  25. scale=image_size,
  26. ratio_range=(0.8, 1.25),
  27. keep_ratio=True),
  28. dict(
  29. type='RandomCrop',
  30. crop_type='absolute_range',
  31. crop_size=image_size,
  32. recompute_bbox=True,
  33. allow_negative_crop=True),
  34. dict(type='FilterAnnotations', min_gt_bbox_wh=(1e-2, 1e-2)),
  35. dict(type='RandomFlip', prob=0.5),
  36. dict(type='PackDetInputs')
  37. ]
  38. test_pipeline = [
  39. dict(type='LoadImageFromFile', backend_args=backend_args),
  40. dict(type='Resize', scale=(1333, 800), keep_ratio=True),
  41. dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
  42. dict(
  43. type='PackDetInputs',
  44. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  45. 'scale_factor'))
  46. ]
  47. train_dataloader = dict(
  48. batch_size=2,
  49. num_workers=2,
  50. persistent_workers=True,
  51. sampler=dict(type='InfiniteSampler'),
  52. dataset=dict(
  53. type=dataset_type,
  54. data_root=data_root,
  55. ann_file='annotations/instances_train2017.json',
  56. data_prefix=dict(img='train2017/'),
  57. filter_cfg=dict(filter_empty_gt=True, min_size=32),
  58. pipeline=train_pipeline,
  59. backend_args=backend_args))
  60. val_dataloader = dict(
  61. batch_size=1,
  62. num_workers=2,
  63. persistent_workers=True,
  64. drop_last=False,
  65. sampler=dict(type='DefaultSampler', shuffle=False),
  66. dataset=dict(
  67. type=dataset_type,
  68. data_root=data_root,
  69. ann_file='annotations/instances_val2017.json',
  70. data_prefix=dict(img='val2017/'),
  71. test_mode=True,
  72. pipeline=test_pipeline,
  73. backend_args=backend_args))
  74. test_dataloader = val_dataloader
  75. val_evaluator = dict(
  76. type='CocoMetric',
  77. ann_file=data_root + 'annotations/instances_val2017.json',
  78. metric=['bbox', 'segm'],
  79. format_only=False,
  80. backend_args=backend_args)
  81. test_evaluator = val_evaluator
  82. # The model is trained by 270k iterations with batch_size 64,
  83. # which is roughly equivalent to 144 epochs.
  84. max_iters = 270000
  85. train_cfg = dict(
  86. type='IterBasedTrainLoop', max_iters=max_iters, val_interval=10000)
  87. val_cfg = dict(type='ValLoop')
  88. test_cfg = dict(type='TestLoop')
  89. # optimizer assumes bs=64
  90. optim_wrapper = dict(
  91. type='OptimWrapper',
  92. optimizer=dict(type='SGD', lr=0.1, momentum=0.9, weight_decay=0.00004))
  93. # learning rate policy
  94. # lr steps at [0.9, 0.95, 0.975] of the maximum iterations
  95. param_scheduler = [
  96. dict(
  97. type='LinearLR', start_factor=0.001, by_epoch=False, begin=0,
  98. end=1000),
  99. dict(
  100. type='MultiStepLR',
  101. begin=0,
  102. end=270000,
  103. by_epoch=False,
  104. milestones=[243000, 256500, 263250],
  105. gamma=0.1)
  106. ]
  107. default_hooks = dict(checkpoint=dict(by_epoch=False, interval=10000))
  108. log_processor = dict(by_epoch=False)
  109. # NOTE: `auto_scale_lr` is for automatically scaling LR,
  110. # USER SHOULD NOT CHANGE ITS VALUES.
  111. # base_batch_size = (32 GPUs) x (2 samples per GPU)
  112. auto_scale_lr = dict(base_batch_size=64)