mask-rcnn_r50_fpn_crop640-50e_coco.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. _base_ = [
  2. '../_base_/models/mask-rcnn_r50_fpn.py',
  3. '../_base_/datasets/coco_instance.py',
  4. '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
  5. ]
  6. norm_cfg = dict(type='BN', requires_grad=True)
  7. image_size = (640, 640)
  8. batch_augments = [dict(type='BatchFixedSizePad', size=image_size)]
  9. model = dict(
  10. data_preprocessor=dict(pad_size_divisor=64, batch_augments=batch_augments),
  11. backbone=dict(norm_cfg=norm_cfg, norm_eval=False),
  12. neck=dict(
  13. type='FPN',
  14. in_channels=[256, 512, 1024, 2048],
  15. out_channels=256,
  16. norm_cfg=norm_cfg,
  17. num_outs=5),
  18. roi_head=dict(
  19. bbox_head=dict(norm_cfg=norm_cfg), mask_head=dict(norm_cfg=norm_cfg)))
  20. dataset_type = 'CocoDataset'
  21. data_root = 'data/coco/'
  22. train_pipeline = [
  23. dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}),
  24. dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
  25. dict(
  26. type='RandomResize',
  27. scale=image_size,
  28. ratio_range=(0.8, 1.2),
  29. keep_ratio=True),
  30. dict(
  31. type='RandomCrop',
  32. crop_type='absolute_range',
  33. crop_size=image_size,
  34. allow_negative_crop=True),
  35. dict(type='RandomFlip', prob=0.5),
  36. dict(type='PackDetInputs')
  37. ]
  38. test_pipeline = [
  39. dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}),
  40. dict(type='Resize', scale=image_size, keep_ratio=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=8, num_workers=4, dataset=dict(pipeline=train_pipeline))
  48. val_dataloader = dict(dataset=dict(pipeline=test_pipeline))
  49. test_dataloader = val_dataloader
  50. # learning policy
  51. max_epochs = 50
  52. train_cfg = dict(max_epochs=max_epochs, val_interval=2)
  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. type='OptimWrapper',
  66. optimizer=dict(type='SGD', lr=0.08, momentum=0.9, weight_decay=0.0001),
  67. paramwise_cfg=dict(norm_decay_mult=0, bypass_duplicate=True),
  68. clip_grad=None)
  69. # NOTE: `auto_scale_lr` is for automatically scaling LR,
  70. # USER SHOULD NOT CHANGE ITS VALUES.
  71. # base_batch_size = (8 GPUs) x (8 samples per GPU)
  72. auto_scale_lr = dict(base_batch_size=64)