faster-rcnn_r50_fpn_crop640-50e_coco.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. _base_ = [
  2. '../_base_/models/faster-rcnn_r50_fpn.py',
  3. '../_base_/datasets/coco_detection.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(norm_cfg=norm_cfg),
  13. roi_head=dict(bbox_head=dict(norm_cfg=norm_cfg)))
  14. dataset_type = 'CocoDataset'
  15. data_root = 'data/coco/'
  16. train_pipeline = [
  17. dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}),
  18. dict(type='LoadAnnotations', with_bbox=True),
  19. dict(
  20. type='RandomResize',
  21. scale=image_size,
  22. ratio_range=(0.8, 1.2),
  23. keep_ratio=True),
  24. dict(
  25. type='RandomCrop',
  26. crop_type='absolute_range',
  27. crop_size=image_size,
  28. allow_negative_crop=True),
  29. dict(type='RandomFlip', prob=0.5),
  30. dict(type='PackDetInputs')
  31. ]
  32. test_pipeline = [
  33. dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}),
  34. dict(type='Resize', scale=image_size, keep_ratio=True),
  35. dict(
  36. type='PackDetInputs',
  37. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  38. 'scale_factor'))
  39. ]
  40. train_dataloader = dict(
  41. batch_size=8, num_workers=4, dataset=dict(pipeline=train_pipeline))
  42. val_dataloader = dict(dataset=dict(pipeline=test_pipeline))
  43. test_dataloader = val_dataloader
  44. # learning policy
  45. max_epochs = 50
  46. train_cfg = dict(max_epochs=max_epochs, val_interval=2)
  47. param_scheduler = [
  48. dict(type='LinearLR', start_factor=0.1, by_epoch=False, begin=0, end=1000),
  49. dict(
  50. type='MultiStepLR',
  51. begin=0,
  52. end=max_epochs,
  53. by_epoch=True,
  54. milestones=[30, 40],
  55. gamma=0.1)
  56. ]
  57. # optimizer
  58. optim_wrapper = dict(
  59. type='OptimWrapper',
  60. optimizer=dict(type='SGD', lr=0.08, momentum=0.9, weight_decay=0.0001),
  61. paramwise_cfg=dict(norm_decay_mult=0, bypass_duplicate=True),
  62. clip_grad=None)
  63. # NOTE: `auto_scale_lr` is for automatically scaling LR,
  64. # USER SHOULD NOT CHANGE ITS VALUES.
  65. # base_batch_size = (8 GPUs) x (8 samples per GPU)
  66. auto_scale_lr = dict(base_batch_size=64)