openimages_detection.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. # dataset settings
  2. dataset_type = 'OpenImagesDataset'
  3. data_root = 'data/OpenImages/'
  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='LoadAnnotations', with_bbox=True),
  19. dict(type='Resize', scale=(1024, 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=(1024, 800), keep_ratio=True),
  26. # avoid bboxes being resized
  27. dict(type='LoadAnnotations', with_bbox=True),
  28. # TODO: find a better way to collect image_level_labels
  29. dict(
  30. type='PackDetInputs',
  31. meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
  32. 'scale_factor', 'instances', 'image_level_labels'))
  33. ]
  34. train_dataloader = dict(
  35. batch_size=2,
  36. num_workers=0, # workers_per_gpu > 0 may occur out of memory
  37. persistent_workers=False,
  38. sampler=dict(type='DefaultSampler', shuffle=True),
  39. batch_sampler=dict(type='AspectRatioBatchSampler'),
  40. dataset=dict(
  41. type=dataset_type,
  42. data_root=data_root,
  43. ann_file='annotations/oidv6-train-annotations-bbox.csv',
  44. data_prefix=dict(img='OpenImages/train/'),
  45. label_file='annotations/class-descriptions-boxable.csv',
  46. hierarchy_file='annotations/bbox_labels_600_hierarchy.json',
  47. meta_file='annotations/train-image-metas.pkl',
  48. pipeline=train_pipeline,
  49. backend_args=backend_args))
  50. val_dataloader = dict(
  51. batch_size=1,
  52. num_workers=0,
  53. persistent_workers=False,
  54. drop_last=False,
  55. sampler=dict(type='DefaultSampler', shuffle=False),
  56. dataset=dict(
  57. type=dataset_type,
  58. data_root=data_root,
  59. ann_file='annotations/validation-annotations-bbox.csv',
  60. data_prefix=dict(img='OpenImages/validation/'),
  61. label_file='annotations/class-descriptions-boxable.csv',
  62. hierarchy_file='annotations/bbox_labels_600_hierarchy.json',
  63. meta_file='annotations/validation-image-metas.pkl',
  64. image_level_ann_file='annotations/validation-'
  65. 'annotations-human-imagelabels-boxable.csv',
  66. pipeline=test_pipeline,
  67. backend_args=backend_args))
  68. test_dataloader = val_dataloader
  69. val_evaluator = dict(
  70. type='OpenImagesMetric',
  71. iou_thrs=0.5,
  72. ioa_thrs=0.5,
  73. use_group_of=True,
  74. get_supercategory=True)
  75. test_evaluator = val_evaluator