ms-90k_coco.py 3.7 KB

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