faster-rcnn_r50_fpn_1x_voc0712-cocofmt.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. _base_ = [
  2. '../_base_/models/faster-rcnn_r50_fpn.py', '../_base_/datasets/voc0712.py',
  3. '../_base_/default_runtime.py'
  4. ]
  5. model = dict(roi_head=dict(bbox_head=dict(num_classes=20)))
  6. METAINFO = {
  7. 'classes':
  8. ('aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat',
  9. 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person',
  10. 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor'),
  11. # palette is a list of color tuples, which is used for visualization.
  12. 'palette': [(106, 0, 228), (119, 11, 32), (165, 42, 42), (0, 0, 192),
  13. (197, 226, 255), (0, 60, 100), (0, 0, 142), (255, 77, 255),
  14. (153, 69, 1), (120, 166, 157), (0, 182, 199), (0, 226, 252),
  15. (182, 182, 255), (0, 0, 230), (220, 20, 60), (163, 255, 0),
  16. (0, 82, 0), (3, 95, 161), (0, 80, 100), (183, 130, 88)]
  17. }
  18. # dataset settings
  19. dataset_type = 'CocoDataset'
  20. data_root = 'data/VOCdevkit/'
  21. train_pipeline = [
  22. dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}),
  23. dict(type='LoadAnnotations', with_bbox=True),
  24. dict(type='Resize', scale=(1000, 600), keep_ratio=True),
  25. dict(type='RandomFlip', prob=0.5),
  26. dict(type='PackDetInputs')
  27. ]
  28. test_pipeline = [
  29. dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}),
  30. dict(type='Resize', scale=(1000, 600), keep_ratio=True),
  31. # avoid bboxes being resized
  32. dict(type='LoadAnnotations', with_bbox=True),
  33. dict(
  34. type='PackDetInputs',
  35. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  36. 'scale_factor'))
  37. ]
  38. train_dataloader = dict(
  39. dataset=dict(
  40. type='RepeatDataset',
  41. times=3,
  42. dataset=dict(
  43. _delete_=True,
  44. type=dataset_type,
  45. data_root=data_root,
  46. ann_file='annotations/voc0712_trainval.json',
  47. data_prefix=dict(img=''),
  48. metainfo=METAINFO,
  49. filter_cfg=dict(filter_empty_gt=True, min_size=32),
  50. pipeline=train_pipeline,
  51. backend_args={{_base_.backend_args}})))
  52. val_dataloader = dict(
  53. dataset=dict(
  54. type=dataset_type,
  55. ann_file='annotations/voc07_test.json',
  56. data_prefix=dict(img=''),
  57. metainfo=METAINFO,
  58. pipeline=test_pipeline))
  59. test_dataloader = val_dataloader
  60. val_evaluator = dict(
  61. type='CocoMetric',
  62. ann_file=data_root + 'annotations/voc07_test.json',
  63. metric='bbox',
  64. format_only=False,
  65. backend_args={{_base_.backend_args}})
  66. test_evaluator = val_evaluator
  67. # training schedule, the dataset is repeated 3 times, so the
  68. # actual epoch = 4 * 3 = 12
  69. max_epochs = 4
  70. train_cfg = dict(
  71. type='EpochBasedTrainLoop', max_epochs=max_epochs, val_interval=1)
  72. val_cfg = dict(type='ValLoop')
  73. test_cfg = dict(type='TestLoop')
  74. # learning rate
  75. param_scheduler = [
  76. dict(
  77. type='MultiStepLR',
  78. begin=0,
  79. end=max_epochs,
  80. by_epoch=True,
  81. milestones=[3],
  82. gamma=0.1)
  83. ]
  84. # optimizer
  85. optim_wrapper = dict(
  86. type='OptimWrapper',
  87. optimizer=dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001))
  88. # Default setting for scaling LR automatically
  89. # - `enable` means enable scaling LR automatically
  90. # or not by default.
  91. # - `base_batch_size` = (8 GPUs) x (2 samples per GPU).
  92. auto_scale_lr = dict(enable=False, base_batch_size=16)