lvis_v0.5_instance.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # dataset settings
  2. dataset_type = 'LVISV05Dataset'
  3. data_root = 'data/lvis_v0.5/'
  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/lvis_v0.5/'
  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='LoadAnnotations', with_bbox=True, with_mask=True),
  19. dict(
  20. type='RandomChoiceResize',
  21. scales=[(1333, 640), (1333, 672), (1333, 704), (1333, 736),
  22. (1333, 768), (1333, 800)],
  23. keep_ratio=True),
  24. dict(type='RandomFlip', prob=0.5),
  25. dict(type='PackDetInputs')
  26. ]
  27. test_pipeline = [
  28. dict(type='LoadImageFromFile', backend_args=backend_args),
  29. dict(type='Resize', scale=(1333, 800), keep_ratio=True),
  30. dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
  31. dict(
  32. type='PackDetInputs',
  33. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  34. 'scale_factor'))
  35. ]
  36. train_dataloader = dict(
  37. batch_size=2,
  38. num_workers=2,
  39. persistent_workers=True,
  40. sampler=dict(type='DefaultSampler', shuffle=True),
  41. batch_sampler=dict(type='AspectRatioBatchSampler'),
  42. dataset=dict(
  43. type='ClassBalancedDataset',
  44. oversample_thr=1e-3,
  45. dataset=dict(
  46. type=dataset_type,
  47. data_root=data_root,
  48. ann_file='annotations/lvis_v0.5_train.json',
  49. data_prefix=dict(img='train2017/'),
  50. filter_cfg=dict(filter_empty_gt=True, min_size=32),
  51. pipeline=train_pipeline,
  52. backend_args=backend_args)))
  53. val_dataloader = dict(
  54. batch_size=1,
  55. num_workers=2,
  56. persistent_workers=True,
  57. drop_last=False,
  58. sampler=dict(type='DefaultSampler', shuffle=False),
  59. dataset=dict(
  60. type=dataset_type,
  61. data_root=data_root,
  62. ann_file='annotations/lvis_v0.5_val.json',
  63. data_prefix=dict(img='val2017/'),
  64. test_mode=True,
  65. pipeline=test_pipeline,
  66. backend_args=backend_args))
  67. test_dataloader = val_dataloader
  68. val_evaluator = dict(
  69. type='LVISMetric',
  70. ann_file=data_root + 'annotations/lvis_v0.5_val.json',
  71. metric=['bbox', 'segm'],
  72. backend_args=backend_args)
  73. test_evaluator = val_evaluator