ms-poly_3x_coco-instance.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. _base_ = '../_base_/default_runtime.py'
  2. # dataset settings
  3. dataset_type = 'CocoDataset'
  4. data_root = 'data/coco/'
  5. # Example to use different file client
  6. # Method 1: simply set the data root and let the file I/O module
  7. # automatically infer from prefix (not support LMDB and Memcache yet)
  8. # data_root = 's3://openmmlab/datasets/detection/coco/'
  9. # Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6
  10. # backend_args = dict(
  11. # backend='petrel',
  12. # path_mapping=dict({
  13. # './data/': 's3://openmmlab/datasets/detection/',
  14. # 'data/': 's3://openmmlab/datasets/detection/'
  15. # }))
  16. backend_args = None
  17. # In mstrain 3x config, img_scale=[(1333, 640), (1333, 800)],
  18. # multiscale_mode='range'
  19. train_pipeline = [
  20. dict(type='LoadImageFromFile', backend_args=backend_args),
  21. dict(
  22. type='LoadAnnotations',
  23. with_bbox=True,
  24. with_mask=True,
  25. poly2mask=False),
  26. dict(
  27. type='RandomResize', scale=[(1333, 640), (1333, 800)],
  28. keep_ratio=True),
  29. dict(type='RandomFlip', prob=0.5),
  30. dict(type='PackDetInputs'),
  31. ]
  32. test_pipeline = [
  33. dict(type='LoadImageFromFile', backend_args=backend_args),
  34. dict(type='Resize', scale=(1333, 800), keep_ratio=True),
  35. dict(
  36. type='LoadAnnotations',
  37. with_bbox=True,
  38. with_mask=True,
  39. poly2mask=False),
  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=2,
  47. num_workers=2,
  48. persistent_workers=True,
  49. sampler=dict(type='DefaultSampler', shuffle=True),
  50. batch_sampler=dict(type='AspectRatioBatchSampler'),
  51. dataset=dict(
  52. type='RepeatDataset',
  53. times=3,
  54. dataset=dict(
  55. type=dataset_type,
  56. data_root=data_root,
  57. ann_file='annotations/instances_train2017.json',
  58. data_prefix=dict(img='train2017/'),
  59. filter_cfg=dict(filter_empty_gt=True, min_size=32),
  60. pipeline=train_pipeline,
  61. backend_args=backend_args)))
  62. val_dataloader = dict(
  63. batch_size=2,
  64. num_workers=2,
  65. persistent_workers=True,
  66. drop_last=False,
  67. sampler=dict(type='DefaultSampler', shuffle=False),
  68. dataset=dict(
  69. type=dataset_type,
  70. data_root=data_root,
  71. ann_file='annotations/instances_val2017.json',
  72. data_prefix=dict(img='val2017/'),
  73. test_mode=True,
  74. pipeline=test_pipeline,
  75. backend_args=backend_args))
  76. test_dataloader = val_dataloader
  77. val_evaluator = dict(
  78. type='CocoMetric',
  79. ann_file=data_root + 'annotations/instances_val2017.json',
  80. metric=['bbox', 'segm'],
  81. backend_args=backend_args)
  82. test_evaluator = val_evaluator
  83. # training schedule for 3x with `RepeatDataset`
  84. train_cfg = dict(type='EpochBasedTrainLoop', max_epochs=12, val_interval=1)
  85. val_cfg = dict(type='ValLoop')
  86. test_cfg = dict(type='TestLoop')
  87. # learning rate
  88. # Experiments show that using milestones=[9, 11] has higher performance
  89. param_scheduler = [
  90. dict(
  91. type='LinearLR', start_factor=0.001, by_epoch=False, begin=0, end=500),
  92. dict(
  93. type='MultiStepLR',
  94. begin=0,
  95. end=12,
  96. by_epoch=True,
  97. milestones=[9, 11],
  98. gamma=0.1)
  99. ]
  100. # optimizer
  101. optim_wrapper = dict(
  102. type='OptimWrapper',
  103. optimizer=dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001))
  104. # Default setting for scaling LR automatically
  105. # - `enable` means enable scaling LR automatically
  106. # or not by default.
  107. # - `base_batch_size` = (8 GPUs) x (2 samples per GPU).
  108. auto_scale_lr = dict(enable=False, base_batch_size=16)