ms-poly-90k_coco-instance.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. # Align with Detectron2
  18. backend = 'pillow'
  19. train_pipeline = [
  20. dict(
  21. type='LoadImageFromFile',
  22. backend_args=backend_args,
  23. imdecode_backend=backend),
  24. dict(
  25. type='LoadAnnotations',
  26. with_bbox=True,
  27. with_mask=True,
  28. poly2mask=False),
  29. dict(
  30. type='RandomChoiceResize',
  31. scales=[(1333, 640), (1333, 672), (1333, 704), (1333, 736),
  32. (1333, 768), (1333, 800)],
  33. keep_ratio=True,
  34. backend=backend),
  35. dict(type='RandomFlip', prob=0.5),
  36. dict(type='PackDetInputs')
  37. ]
  38. test_pipeline = [
  39. dict(
  40. type='LoadImageFromFile',
  41. backend_args=backend_args,
  42. imdecode_backend=backend),
  43. dict(type='Resize', scale=(1333, 800), keep_ratio=True, backend=backend),
  44. dict(
  45. type='LoadAnnotations',
  46. with_bbox=True,
  47. with_mask=True,
  48. poly2mask=False),
  49. dict(
  50. type='PackDetInputs',
  51. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  52. 'scale_factor'))
  53. ]
  54. train_dataloader = dict(
  55. batch_size=2,
  56. num_workers=2,
  57. persistent_workers=True,
  58. pin_memory=True,
  59. sampler=dict(type='InfiniteSampler', shuffle=True),
  60. batch_sampler=dict(type='AspectRatioBatchSampler'),
  61. dataset=dict(
  62. type=dataset_type,
  63. data_root=data_root,
  64. ann_file='annotations/instances_train2017.json',
  65. data_prefix=dict(img='train2017/'),
  66. filter_cfg=dict(filter_empty_gt=True, min_size=32),
  67. pipeline=train_pipeline,
  68. backend_args=backend_args))
  69. val_dataloader = dict(
  70. batch_size=1,
  71. num_workers=2,
  72. persistent_workers=True,
  73. drop_last=False,
  74. pin_memory=True,
  75. sampler=dict(type='DefaultSampler', shuffle=False),
  76. dataset=dict(
  77. type=dataset_type,
  78. data_root=data_root,
  79. ann_file='annotations/instances_val2017.json',
  80. data_prefix=dict(img='val2017/'),
  81. test_mode=True,
  82. pipeline=test_pipeline,
  83. backend_args=backend_args))
  84. test_dataloader = val_dataloader
  85. val_evaluator = dict(
  86. type='CocoMetric',
  87. ann_file=data_root + 'annotations/instances_val2017.json',
  88. metric=['bbox', 'segm'],
  89. format_only=False,
  90. backend_args=backend_args)
  91. test_evaluator = val_evaluator
  92. # training schedule for 90k
  93. max_iter = 90000
  94. train_cfg = dict(
  95. type='IterBasedTrainLoop', max_iters=max_iter, val_interval=10000)
  96. val_cfg = dict(type='ValLoop')
  97. test_cfg = dict(type='TestLoop')
  98. # learning rate
  99. param_scheduler = [
  100. dict(
  101. type='LinearLR', start_factor=0.001, by_epoch=False, begin=0,
  102. end=1000),
  103. dict(
  104. type='MultiStepLR',
  105. begin=0,
  106. end=max_iter,
  107. by_epoch=False,
  108. milestones=[60000, 80000],
  109. gamma=0.1)
  110. ]
  111. # optimizer
  112. optim_wrapper = dict(
  113. type='OptimWrapper',
  114. optimizer=dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001))
  115. # Default setting for scaling LR automatically
  116. # - `enable` means enable scaling LR automatically
  117. # or not by default.
  118. # - `base_batch_size` = (8 GPUs) x (2 samples per GPU).
  119. auto_scale_lr = dict(enable=False, base_batch_size=16)
  120. default_hooks = dict(checkpoint=dict(by_epoch=False, interval=10000))
  121. log_processor = dict(by_epoch=False)