voc0712.py 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # dataset settings
  2. dataset_type = 'VOCDataset'
  3. data_root = 'data/VOCdevkit/'
  4. # Example to use different file client
  5. # Method 1: simply set the data root and let the file I/O module
  6. # automatically Infer from prefix (not support LMDB and Memcache yet)
  7. # data_root = 's3://openmmlab/datasets/detection/segmentation/VOCdevkit/'
  8. # Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6
  9. # backend_args = dict(
  10. # backend='petrel',
  11. # path_mapping=dict({
  12. # './data/': 's3://openmmlab/datasets/segmentation/',
  13. # 'data/': 's3://openmmlab/datasets/segmentation/'
  14. # }))
  15. backend_args = None
  16. train_pipeline = [
  17. dict(type='LoadImageFromFile', backend_args=backend_args),
  18. dict(type='LoadAnnotations', with_bbox=True),
  19. dict(type='Resize', scale=(1000, 600), keep_ratio=True),
  20. dict(type='RandomFlip', prob=0.5),
  21. dict(type='PackDetInputs')
  22. ]
  23. test_pipeline = [
  24. dict(type='LoadImageFromFile', backend_args=backend_args),
  25. dict(type='Resize', scale=(1000, 600), keep_ratio=True),
  26. # avoid bboxes being resized
  27. dict(type='LoadAnnotations', with_bbox=True),
  28. dict(
  29. type='PackDetInputs',
  30. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  31. 'scale_factor'))
  32. ]
  33. train_dataloader = dict(
  34. batch_size=2,
  35. num_workers=2,
  36. persistent_workers=True,
  37. sampler=dict(type='DefaultSampler', shuffle=True),
  38. batch_sampler=dict(type='AspectRatioBatchSampler'),
  39. dataset=dict(
  40. type='RepeatDataset',
  41. times=3,
  42. dataset=dict(
  43. type='ConcatDataset',
  44. # VOCDataset will add different `dataset_type` in dataset.metainfo,
  45. # which will get error if using ConcatDataset. Adding
  46. # `ignore_keys` can avoid this error.
  47. ignore_keys=['dataset_type'],
  48. datasets=[
  49. dict(
  50. type=dataset_type,
  51. data_root=data_root,
  52. ann_file='VOC2007/ImageSets/Main/trainval.txt',
  53. data_prefix=dict(sub_data_root='VOC2007/'),
  54. filter_cfg=dict(
  55. filter_empty_gt=True, min_size=32, bbox_min_size=32),
  56. pipeline=train_pipeline,
  57. backend_args=backend_args),
  58. dict(
  59. type=dataset_type,
  60. data_root=data_root,
  61. ann_file='VOC2012/ImageSets/Main/trainval.txt',
  62. data_prefix=dict(sub_data_root='VOC2012/'),
  63. filter_cfg=dict(
  64. filter_empty_gt=True, min_size=32, bbox_min_size=32),
  65. pipeline=train_pipeline,
  66. backend_args=backend_args)
  67. ])))
  68. val_dataloader = dict(
  69. batch_size=1,
  70. num_workers=2,
  71. persistent_workers=True,
  72. drop_last=False,
  73. sampler=dict(type='DefaultSampler', shuffle=False),
  74. dataset=dict(
  75. type=dataset_type,
  76. data_root=data_root,
  77. ann_file='VOC2007/ImageSets/Main/test.txt',
  78. data_prefix=dict(sub_data_root='VOC2007/'),
  79. test_mode=True,
  80. pipeline=test_pipeline,
  81. backend_args=backend_args))
  82. test_dataloader = val_dataloader
  83. # Pascal VOC2007 uses `11points` as default evaluate mode, while PASCAL
  84. # VOC2012 defaults to use 'area'.
  85. val_evaluator = dict(type='VOCMetric', metric='mAP', eval_mode='11points')
  86. test_evaluator = val_evaluator