coco_panoptic.py 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # dataset settings
  2. dataset_type = 'CocoPanopticDataset'
  3. # data_root = 'data/coco/'
  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/coco/'
  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/detection/',
  13. # 'data/': 's3://openmmlab/datasets/detection/'
  14. # }))
  15. backend_args = None
  16. train_pipeline = [
  17. dict(type='LoadImageFromFile', backend_args=backend_args),
  18. dict(type='LoadPanopticAnnotations', backend_args=backend_args),
  19. dict(type='Resize', scale=(1333, 800), 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=(1333, 800), keep_ratio=True),
  26. dict(type='LoadPanopticAnnotations', backend_args=backend_args),
  27. dict(
  28. type='PackDetInputs',
  29. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  30. 'scale_factor'))
  31. ]
  32. train_dataloader = dict(
  33. batch_size=2,
  34. num_workers=2,
  35. persistent_workers=True,
  36. sampler=dict(type='DefaultSampler', shuffle=True),
  37. batch_sampler=dict(type='AspectRatioBatchSampler'),
  38. dataset=dict(
  39. type=dataset_type,
  40. data_root=data_root,
  41. ann_file='annotations/panoptic_train2017.json',
  42. data_prefix=dict(
  43. img='train2017/', seg='annotations/panoptic_train2017/'),
  44. filter_cfg=dict(filter_empty_gt=True, min_size=32),
  45. pipeline=train_pipeline,
  46. backend_args=backend_args))
  47. val_dataloader = dict(
  48. batch_size=1,
  49. num_workers=2,
  50. persistent_workers=True,
  51. drop_last=False,
  52. sampler=dict(type='DefaultSampler', shuffle=False),
  53. dataset=dict(
  54. type=dataset_type,
  55. data_root=data_root,
  56. ann_file='annotations/panoptic_val2017.json',
  57. data_prefix=dict(img='val2017/', seg='annotations/panoptic_val2017/'),
  58. test_mode=True,
  59. pipeline=test_pipeline,
  60. backend_args=backend_args))
  61. test_dataloader = val_dataloader
  62. val_evaluator = dict(
  63. type='CocoPanopticMetric',
  64. ann_file=data_root + 'annotations/panoptic_val2017.json',
  65. seg_prefix=data_root + 'annotations/panoptic_val2017/',
  66. backend_args=backend_args)
  67. test_evaluator = val_evaluator
  68. # inference on test dataset and
  69. # format the output results for submission.
  70. # test_dataloader = dict(
  71. # batch_size=1,
  72. # num_workers=1,
  73. # persistent_workers=True,
  74. # drop_last=False,
  75. # sampler=dict(type='DefaultSampler', shuffle=False),
  76. # dataset=dict(
  77. # type=dataset_type,
  78. # data_root=data_root,
  79. # ann_file='annotations/panoptic_image_info_test-dev2017.json',
  80. # data_prefix=dict(img='test2017/'),
  81. # test_mode=True,
  82. # pipeline=test_pipeline))
  83. # test_evaluator = dict(
  84. # type='CocoPanopticMetric',
  85. # format_only=True,
  86. # ann_file=data_root + 'annotations/panoptic_image_info_test-dev2017.json',
  87. # outfile_prefix='./work_dirs/coco_panoptic/test')