diff --git a/configs/_base_/datasets/cityscapes_detection.py b/configs/_base_/datasets/cityscapes_detection.py index a037fb838fa..caeba6bfcd2 100644 --- a/configs/_base_/datasets/cityscapes_detection.py +++ b/configs/_base_/datasets/cityscapes_detection.py @@ -2,8 +2,23 @@ dataset_type = 'CityscapesDataset' data_root = 'data/cityscapes/' +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/segmentation/cityscapes/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( +# backend='petrel', +# path_mapping=dict({ +# './data/': 's3://openmmlab/datasets/segmentation/', +# 'data/': 's3://openmmlab/datasets/segmentation/' +# })) +backend_args = None + train_pipeline = [ - dict(type='LoadImageFromFile'), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', @@ -14,7 +29,7 @@ ] test_pipeline = [ - dict(type='LoadImageFromFile'), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(2048, 1024), keep_ratio=True), # If you don't have a gt annotation, delete the pipeline dict(type='LoadAnnotations', with_bbox=True), @@ -39,7 +54,8 @@ ann_file='annotations/instancesonly_filtered_gtFine_train.json', data_prefix=dict(img='leftImg8bit/train/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline))) + pipeline=train_pipeline, + backend_args=backend_args))) val_dataloader = dict( batch_size=1, @@ -54,13 +70,15 @@ data_prefix=dict(img='leftImg8bit/val/'), test_mode=True, filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instancesonly_filtered_gtFine_val.json', - metric='bbox') + metric='bbox', + backend_args=backend_args) test_evaluator = val_evaluator diff --git a/configs/_base_/datasets/cityscapes_instance.py b/configs/_base_/datasets/cityscapes_instance.py index 0254af3f97a..136403136c6 100644 --- a/configs/_base_/datasets/cityscapes_instance.py +++ b/configs/_base_/datasets/cityscapes_instance.py @@ -2,8 +2,23 @@ dataset_type = 'CityscapesDataset' data_root = 'data/cityscapes/' +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/segmentation/cityscapes/' + +# Method 2: Use backend_args, file_client_args in versions before 3.0.0rc6 +# backend_args = dict( +# backend='petrel', +# path_mapping=dict({ +# './data/': 's3://openmmlab/datasets/segmentation/', +# 'data/': 's3://openmmlab/datasets/segmentation/' +# })) +backend_args = None + train_pipeline = [ - dict(type='LoadImageFromFile'), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomResize', @@ -14,7 +29,7 @@ ] test_pipeline = [ - dict(type='LoadImageFromFile'), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(2048, 1024), keep_ratio=True), # If you don't have a gt annotation, delete the pipeline dict(type='LoadAnnotations', with_bbox=True, with_mask=True), @@ -39,7 +54,8 @@ ann_file='annotations/instancesonly_filtered_gtFine_train.json', data_prefix=dict(img='leftImg8bit/train/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline))) + pipeline=train_pipeline, + backend_args=backend_args))) val_dataloader = dict( batch_size=1, @@ -54,7 +70,8 @@ data_prefix=dict(img='leftImg8bit/val/'), test_mode=True, filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader @@ -63,13 +80,13 @@ type='CocoMetric', ann_file=data_root + 'annotations/instancesonly_filtered_gtFine_val.json', - metric=['bbox', 'segm']), + metric=['bbox', 'segm'], + backend_args=backend_args), dict( type='CityScapesMetric', - ann_file=data_root + - 'annotations/instancesonly_filtered_gtFine_val.json', - seg_prefix=data_root + '/gtFine/val', - outfile_prefix='./work_dirs/cityscapes_metric/instance') + seg_prefix=data_root + 'gtFine/val', + outfile_prefix='./work_dirs/cityscapes_metric/instance', + backend_args=backend_args) ] test_evaluator = val_evaluator diff --git a/configs/_base_/datasets/coco_detection.py b/configs/_base_/datasets/coco_detection.py index fcd9859f135..fdf8dfad947 100644 --- a/configs/_base_/datasets/coco_detection.py +++ b/configs/_base_/datasets/coco_detection.py @@ -2,23 +2,30 @@ dataset_type = 'CocoDataset' data_root = 'data/coco/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='RandomFlip', prob=0.5), dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), # If you don't have a gt annotation, delete the pipeline dict(type='LoadAnnotations', with_bbox=True), @@ -39,7 +46,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( batch_size=1, num_workers=2, @@ -52,14 +60,16 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', metric='bbox', - format_only=False) + format_only=False, + backend_args=backend_args) test_evaluator = val_evaluator # inference on test dataset and diff --git a/configs/_base_/datasets/coco_instance.py b/configs/_base_/datasets/coco_instance.py index 878d8b4915e..e91cb354038 100644 --- a/configs/_base_/datasets/coco_instance.py +++ b/configs/_base_/datasets/coco_instance.py @@ -2,23 +2,30 @@ dataset_type = 'CocoDataset' data_root = 'data/coco/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='RandomFlip', prob=0.5), dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), # If you don't have a gt annotation, delete the pipeline dict(type='LoadAnnotations', with_bbox=True, with_mask=True), @@ -39,7 +46,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( batch_size=1, num_workers=2, @@ -52,14 +60,16 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', metric=['bbox', 'segm'], - format_only=False) + format_only=False, + backend_args=backend_args) test_evaluator = val_evaluator # inference on test dataset and diff --git a/configs/_base_/datasets/coco_instance_semantic.py b/configs/_base_/datasets/coco_instance_semantic.py index 12652d02c6b..cc961863306 100644 --- a/configs/_base_/datasets/coco_instance_semantic.py +++ b/configs/_base_/datasets/coco_instance_semantic.py @@ -2,16 +2,23 @@ dataset_type = 'CocoDataset' data_root = 'data/coco/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict( type='LoadAnnotations', with_bbox=True, with_mask=True, with_seg=True), dict(type='Resize', scale=(1333, 800), keep_ratio=True), @@ -19,7 +26,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), # If you don't have a gt annotation, delete the pipeline dict( @@ -42,7 +49,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/', seg='stuffthingmaps/train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( batch_size=1, @@ -56,7 +64,8 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader @@ -64,5 +73,6 @@ type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', metric=['bbox', 'segm'], - format_only=False) + format_only=False, + backend_args=backend_args) test_evaluator = val_evaluator diff --git a/configs/_base_/datasets/coco_panoptic.py b/configs/_base_/datasets/coco_panoptic.py index 021d80b2807..2d75660f4b4 100644 --- a/configs/_base_/datasets/coco_panoptic.py +++ b/configs/_base_/datasets/coco_panoptic.py @@ -1,26 +1,33 @@ # dataset settings dataset_type = 'CocoPanopticDataset' -data_root = 'data/coco/' +# data_root = 'data/coco/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), - dict(type='LoadPanopticAnnotations', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), + dict(type='LoadPanopticAnnotations', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='RandomFlip', prob=0.5), dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), - dict(type='LoadPanopticAnnotations', file_client_args=file_client_args), + dict(type='LoadPanopticAnnotations', backend_args=backend_args), dict( type='PackDetInputs', meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', @@ -40,7 +47,8 @@ data_prefix=dict( img='train2017/', seg='annotations/panoptic_train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( batch_size=1, num_workers=2, @@ -53,15 +61,15 @@ ann_file='annotations/panoptic_val2017.json', data_prefix=dict(img='val2017/', seg='annotations/panoptic_val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoPanopticMetric', ann_file=data_root + 'annotations/panoptic_val2017.json', seg_prefix=data_root + 'annotations/panoptic_val2017/', - file_client_args=file_client_args, -) + backend_args=backend_args) test_evaluator = val_evaluator # inference on test dataset and diff --git a/configs/_base_/datasets/deepfashion.py b/configs/_base_/datasets/deepfashion.py index bb70eeed7d0..a93dc7152f7 100644 --- a/configs/_base_/datasets/deepfashion.py +++ b/configs/_base_/datasets/deepfashion.py @@ -2,23 +2,30 @@ dataset_type = 'DeepFashionDataset' data_root = 'data/DeepFashion/In-shop/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict(type='Resize', scale=(750, 1101), keep_ratio=True), dict(type='RandomFlip', prob=0.5), dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(750, 1101), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( @@ -41,7 +48,8 @@ ann_file='Anno/segmentation/DeepFashion_segmentation_train.json', data_prefix=dict(img='Img/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline))) + pipeline=train_pipeline, + backend_args=backend_args))) val_dataloader = dict( batch_size=1, num_workers=2, @@ -54,7 +62,8 @@ ann_file='Anno/segmentation/DeepFashion_segmentation_query.json', data_prefix=dict(img='Img/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = dict( batch_size=1, num_workers=2, @@ -67,17 +76,20 @@ ann_file='Anno/segmentation/DeepFashion_segmentation_gallery.json', data_prefix=dict(img='Img/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'Anno/segmentation/DeepFashion_segmentation_query.json', metric=['bbox', 'segm'], - format_only=False) + format_only=False, + backend_args=backend_args) test_evaluator = dict( type='CocoMetric', ann_file=data_root + 'Anno/segmentation/DeepFashion_segmentation_gallery.json', metric=['bbox', 'segm'], - format_only=False) + format_only=False, + backend_args=backend_args) diff --git a/configs/_base_/datasets/lvis_v0.5_instance.py b/configs/_base_/datasets/lvis_v0.5_instance.py index f8f65f2b5e8..d0ca44efb6d 100644 --- a/configs/_base_/datasets/lvis_v0.5_instance.py +++ b/configs/_base_/datasets/lvis_v0.5_instance.py @@ -2,16 +2,23 @@ dataset_type = 'LVISV05Dataset' data_root = 'data/lvis_v0.5/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/lvis_v0.5/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomChoiceResize', @@ -22,7 +29,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( @@ -46,7 +53,8 @@ ann_file='annotations/lvis_v0.5_train.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline))) + pipeline=train_pipeline, + backend_args=backend_args))) val_dataloader = dict( batch_size=1, num_workers=2, @@ -59,11 +67,13 @@ ann_file='annotations/lvis_v0.5_val.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='LVISMetric', ann_file=data_root + 'annotations/lvis_v0.5_val.json', - metric=['bbox', 'segm']) + metric=['bbox', 'segm'], + backend_args=backend_args) test_evaluator = val_evaluator diff --git a/configs/_base_/datasets/objects365v1_detection.py b/configs/_base_/datasets/objects365v1_detection.py index 7112f67c338..ee398698608 100644 --- a/configs/_base_/datasets/objects365v1_detection.py +++ b/configs/_base_/datasets/objects365v1_detection.py @@ -2,23 +2,30 @@ dataset_type = 'Objects365V1Dataset' data_root = 'data/Objects365/Obj365_v1/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='RandomFlip', prob=0.5), dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), # If you don't have a gt annotation, delete the pipeline dict(type='LoadAnnotations', with_bbox=True), @@ -39,7 +46,8 @@ ann_file='annotations/objects365_train.json', data_prefix=dict(img='train/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( batch_size=1, num_workers=2, @@ -52,7 +60,8 @@ ann_file='annotations/objects365_val.json', data_prefix=dict(img='val/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( @@ -60,5 +69,6 @@ ann_file=data_root + 'annotations/objects365_val.json', metric='bbox', sort_categories=True, - format_only=False) + format_only=False, + backend_args=backend_args) test_evaluator = val_evaluator diff --git a/configs/_base_/datasets/objects365v2_detection.py b/configs/_base_/datasets/objects365v2_detection.py index 017d8c01a62..b25a7ba901b 100644 --- a/configs/_base_/datasets/objects365v2_detection.py +++ b/configs/_base_/datasets/objects365v2_detection.py @@ -2,23 +2,30 @@ dataset_type = 'Objects365V2Dataset' data_root = 'data/Objects365/Obj365_v2/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='RandomFlip', prob=0.5), dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), # If you don't have a gt annotation, delete the pipeline dict(type='LoadAnnotations', with_bbox=True), @@ -39,7 +46,8 @@ ann_file='annotations/zhiyuan_objv2_train.json', data_prefix=dict(img='train/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( batch_size=1, num_workers=2, @@ -52,12 +60,14 @@ ann_file='annotations/zhiyuan_objv2_val.json', data_prefix=dict(img='val/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/zhiyuan_objv2_val.json', metric='bbox', - format_only=False) + format_only=False, + backend_args=backend_args) test_evaluator = val_evaluator diff --git a/configs/_base_/datasets/openimages_detection.py b/configs/_base_/datasets/openimages_detection.py index 9d99fb27800..129661b405c 100644 --- a/configs/_base_/datasets/openimages_detection.py +++ b/configs/_base_/datasets/openimages_detection.py @@ -2,24 +2,30 @@ dataset_type = 'OpenImagesDataset' data_root = 'data/OpenImages/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) - -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', scale=(1024, 800), keep_ratio=True), dict(type='RandomFlip', prob=0.5), dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1024, 800), keep_ratio=True), # avoid bboxes being resized dict(type='LoadAnnotations', with_bbox=True), @@ -44,7 +50,8 @@ label_file='annotations/class-descriptions-boxable.csv', hierarchy_file='annotations/bbox_labels_600_hierarchy.json', meta_file='annotations/train-image-metas.pkl', - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( batch_size=1, num_workers=0, @@ -61,7 +68,8 @@ meta_file='annotations/validation-image-metas.pkl', image_level_ann_file='annotations/validation-' 'annotations-human-imagelabels-boxable.csv', - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( diff --git a/configs/_base_/datasets/semi_coco_detection.py b/configs/_base_/datasets/semi_coco_detection.py index 02b729804a2..694f25f841e 100644 --- a/configs/_base_/datasets/semi_coco_detection.py +++ b/configs/_base_/datasets/semi_coco_detection.py @@ -2,13 +2,20 @@ dataset_type = 'CocoDataset' data_root = 'data/coco/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None color_space = [ [dict(type='ColorTransform')], @@ -36,7 +43,7 @@ # pipeline used to augment labeled data, # which will be sent to student model for supervised training. sup_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict(type='RandomResize', scale=scale, keep_ratio=True), dict(type='RandomFlip', prob=0.5), @@ -82,7 +89,7 @@ # pipeline used to augment unlabeled data into different views unsup_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadEmptyAnnotations'), dict( type='MultiBranch', @@ -93,7 +100,7 @@ ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict( type='PackDetInputs', @@ -122,7 +129,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=sup_pipeline) + pipeline=sup_pipeline, + backend_args=backend_args) unlabeled_dataset = dict( type=dataset_type, @@ -130,7 +138,8 @@ ann_file='annotations/instances_unlabeled2017.json', data_prefix=dict(img='unlabeled2017/'), filter_cfg=dict(filter_empty_gt=False), - pipeline=unsup_pipeline) + pipeline=unsup_pipeline, + backend_args=backend_args) train_dataloader = dict( batch_size=batch_size, @@ -155,7 +164,8 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader @@ -163,5 +173,6 @@ type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', metric='bbox', - format_only=False) + format_only=False, + backend_args=backend_args) test_evaluator = val_evaluator diff --git a/configs/_base_/datasets/voc0712.py b/configs/_base_/datasets/voc0712.py index 34330e40400..47f5e6563b7 100644 --- a/configs/_base_/datasets/voc0712.py +++ b/configs/_base_/datasets/voc0712.py @@ -2,23 +2,30 @@ dataset_type = 'VOCDataset' data_root = 'data/VOCdevkit/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically Infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/segmentation/VOCdevkit/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ -# './data/': 's3://openmmlab/datasets/detection/', -# 'data/': 's3://openmmlab/datasets/detection/' +# './data/': 's3://openmmlab/datasets/segmentation/', +# 'data/': 's3://openmmlab/datasets/segmentation/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', scale=(1000, 600), keep_ratio=True), dict(type='RandomFlip', prob=0.5), dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1000, 600), keep_ratio=True), # avoid bboxes being resized dict(type='LoadAnnotations', with_bbox=True), @@ -50,7 +57,8 @@ data_prefix=dict(sub_data_root='VOC2007/'), filter_cfg=dict( filter_empty_gt=True, min_size=32, bbox_min_size=32), - pipeline=train_pipeline), + pipeline=train_pipeline, + backend_args=backend_args), dict( type=dataset_type, data_root=data_root, @@ -58,7 +66,8 @@ data_prefix=dict(sub_data_root='VOC2012/'), filter_cfg=dict( filter_empty_gt=True, min_size=32, bbox_min_size=32), - pipeline=train_pipeline) + pipeline=train_pipeline, + backend_args=backend_args) ]))) val_dataloader = dict( @@ -73,7 +82,8 @@ ann_file='VOC2007/ImageSets/Main/test.txt', data_prefix=dict(sub_data_root='VOC2007/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader # Pascal VOC2007 uses `11points` as default evaluate mode, while PASCAL diff --git a/configs/albu_example/mask-rcnn_r50_fpn_albu-1x_coco.py b/configs/albu_example/mask-rcnn_r50_fpn_albu-1x_coco.py index 8a797d41fe5..b8a2780e99b 100644 --- a/configs/albu_example/mask-rcnn_r50_fpn_albu-1x_coco.py +++ b/configs/albu_example/mask-rcnn_r50_fpn_albu-1x_coco.py @@ -41,9 +41,7 @@ p=0.1), ] train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict( diff --git a/configs/centernet/centernet-update_r50-caffe_fpn_ms-1x_coco.py b/configs/centernet/centernet-update_r50-caffe_fpn_ms-1x_coco.py index 5e5a24ee5e4..1f6e2b3919d 100644 --- a/configs/centernet/centernet-update_r50-caffe_fpn_ms-1x_coco.py +++ b/configs/centernet/centernet-update_r50-caffe_fpn_ms-1x_coco.py @@ -64,9 +64,7 @@ # single-scale training is about 39.3 train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomChoiceResize', diff --git a/configs/centernet/centernet_r18-dcnv2_8xb16-crop512-140e_coco.py b/configs/centernet/centernet_r18-dcnv2_8xb16-crop512-140e_coco.py index 83b07195971..732a55d59ad 100644 --- a/configs/centernet/centernet_r18-dcnv2_8xb16-crop512-140e_coco.py +++ b/configs/centernet/centernet_r18-dcnv2_8xb16-crop512-140e_coco.py @@ -39,9 +39,7 @@ test_cfg=dict(topk=100, local_maximum_kernel=3, max_per_img=100)) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='PhotoMetricDistortion', @@ -67,8 +65,8 @@ test_pipeline = [ dict( type='LoadImageFromFile', - to_float32=True, - file_client_args={{_base_.file_client_args}}), + backend_args={{_base_.backend_args}}, + to_float32=True), # don't need Resize dict( type='RandomCenterCropPad', @@ -102,7 +100,9 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline))) + pipeline=train_pipeline, + backend_args={{_base_.backend_args}}, + ))) val_dataloader = dict(dataset=dict(pipeline=test_pipeline)) test_dataloader = val_dataloader diff --git a/configs/centernet/centernet_tta.py b/configs/centernet/centernet_tta.py index 0c68914267e..edd7b03ecde 100644 --- a/configs/centernet/centernet_tta.py +++ b/configs/centernet/centernet_tta.py @@ -5,10 +5,7 @@ tta_cfg=dict(nms=dict(type='nms', iou_threshold=0.5), max_per_img=100)) tta_pipeline = [ - dict( - type='LoadImageFromFile', - to_float32=True, - file_client_args=dict(backend='disk')), + dict(type='LoadImageFromFile', to_float32=True, backend_args=None), dict( type='TestTimeAug', transforms=[ diff --git a/configs/centripetalnet/centripetalnet_hourglass104_16xb6-crop511-210e-mstest_coco.py b/configs/centripetalnet/centripetalnet_hourglass104_16xb6-crop511-210e-mstest_coco.py index 043496f3da2..dd629edb2e8 100644 --- a/configs/centripetalnet/centripetalnet_hourglass104_16xb6-crop511-210e-mstest_coco.py +++ b/configs/centripetalnet/centripetalnet_hourglass104_16xb6-crop511-210e-mstest_coco.py @@ -45,9 +45,7 @@ # data settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='PhotoMetricDistortion', @@ -77,7 +75,7 @@ dict( type='LoadImageFromFile', to_float32=True, - file_client_args={{_base_.file_client_args}}), + backend_args={{_base_.backend_args}}), # don't need Resize dict( type='RandomCenterCropPad', diff --git a/configs/common/lsj-100e_coco-detection.py b/configs/common/lsj-100e_coco-detection.py index b03e33809da..bb631e5d5c1 100644 --- a/configs/common/lsj-100e_coco-detection.py +++ b/configs/common/lsj-100e_coco-detection.py @@ -4,17 +4,23 @@ data_root = 'data/coco/' image_size = (1024, 1024) -file_client_args = dict(backend='disk') -# comment out the code below to use different file client -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', @@ -32,7 +38,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( @@ -56,7 +62,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline))) + pipeline=train_pipeline, + backend_args=backend_args))) val_dataloader = dict( batch_size=1, num_workers=2, @@ -69,14 +76,16 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', metric='bbox', - format_only=False) + format_only=False, + backend_args=backend_args) test_evaluator = val_evaluator max_epochs = 25 diff --git a/configs/common/lsj-100e_coco-instance.py b/configs/common/lsj-100e_coco-instance.py index b00ab686126..6e62729d639 100644 --- a/configs/common/lsj-100e_coco-instance.py +++ b/configs/common/lsj-100e_coco-instance.py @@ -4,17 +4,23 @@ data_root = 'data/coco/' image_size = (1024, 1024) -file_client_args = dict(backend='disk') -# comment out the code below to use different file client -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomResize', @@ -32,7 +38,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( @@ -56,7 +62,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline))) + pipeline=train_pipeline, + backend_args=backend_args))) val_dataloader = dict( batch_size=1, num_workers=2, @@ -69,14 +76,16 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', metric=['bbox', 'segm'], - format_only=False) + format_only=False, + backend_args=backend_args) test_evaluator = val_evaluator max_epochs = 25 diff --git a/configs/common/ms-90k_coco.py b/configs/common/ms-90k_coco.py index 7d7b5f35975..e2d6c3dafb6 100644 --- a/configs/common/ms-90k_coco.py +++ b/configs/common/ms-90k_coco.py @@ -3,20 +3,27 @@ # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None # Align with Detectron2 backend = 'pillow' train_pipeline = [ dict( type='LoadImageFromFile', - file_client_args=file_client_args, + backend_args=backend_args, imdecode_backend=backend), dict(type='LoadAnnotations', with_bbox=True), dict( @@ -31,7 +38,7 @@ test_pipeline = [ dict( type='LoadImageFromFile', - file_client_args=file_client_args, + backend_args=backend_args, imdecode_backend=backend), dict(type='Resize', scale=(1333, 800), keep_ratio=True, backend=backend), dict(type='LoadAnnotations', with_bbox=True), @@ -53,7 +60,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( batch_size=1, num_workers=2, @@ -67,14 +75,16 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', metric='bbox', - format_only=False) + format_only=False, + backend_args=backend_args) test_evaluator = val_evaluator # training schedule for 90k diff --git a/configs/common/ms-poly-90k_coco-instance.py b/configs/common/ms-poly-90k_coco-instance.py index 2a2deb5bf00..d5566b3c3b8 100644 --- a/configs/common/ms-poly-90k_coco-instance.py +++ b/configs/common/ms-poly-90k_coco-instance.py @@ -3,20 +3,27 @@ # dataset settings dataset_type = 'CocoDataset' data_root = 'data/coco/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None # Align with Detectron2 backend = 'pillow' train_pipeline = [ dict( type='LoadImageFromFile', - file_client_args=file_client_args, + backend_args=backend_args, imdecode_backend=backend), dict( type='LoadAnnotations', @@ -35,7 +42,7 @@ test_pipeline = [ dict( type='LoadImageFromFile', - file_client_args=file_client_args, + backend_args=backend_args, imdecode_backend=backend), dict(type='Resize', scale=(1333, 800), keep_ratio=True, backend=backend), dict( @@ -61,7 +68,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( batch_size=1, num_workers=2, @@ -75,14 +83,16 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', metric=['bbox', 'segm'], - format_only=False) + format_only=False, + backend_args=backend_args) test_evaluator = val_evaluator # training schedule for 90k diff --git a/configs/common/ms-poly_3x_coco-instance.py b/configs/common/ms-poly_3x_coco-instance.py index 6a3d5e5569d..04072f9b84c 100644 --- a/configs/common/ms-poly_3x_coco-instance.py +++ b/configs/common/ms-poly_3x_coco-instance.py @@ -3,18 +3,25 @@ dataset_type = 'CocoDataset' data_root = 'data/coco/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None # In mstrain 3x config, img_scale=[(1333, 640), (1333, 800)], # multiscale_mode='range' train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict( type='LoadAnnotations', with_bbox=True, @@ -27,7 +34,7 @@ dict(type='PackDetInputs'), ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict( type='LoadAnnotations', @@ -55,7 +62,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline))) + pipeline=train_pipeline, + backend_args=backend_args))) val_dataloader = dict( batch_size=2, num_workers=2, @@ -68,13 +76,15 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', - metric=['bbox', 'segm']) + metric=['bbox', 'segm'], + backend_args=backend_args) test_evaluator = val_evaluator # training schedule for 3x with `RepeatDataset` diff --git a/configs/common/ms_3x_coco-instance.py b/configs/common/ms_3x_coco-instance.py index cae37d176ac..840a2437b30 100644 --- a/configs/common/ms_3x_coco-instance.py +++ b/configs/common/ms_3x_coco-instance.py @@ -4,16 +4,23 @@ dataset_type = 'CocoDataset' data_root = 'data/coco/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomResize', scale=[(1333, 640), (1333, 800)], @@ -22,7 +29,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( @@ -42,7 +49,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( batch_size=2, num_workers=2, @@ -58,13 +66,15 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline))) + pipeline=test_pipeline, + backend_args=backend_args))) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', - metric='bbox') + metric='bbox', + backend_args=backend_args) test_evaluator = val_evaluator # training schedule for 3x with `RepeatDataset` diff --git a/configs/common/ms_3x_coco.py b/configs/common/ms_3x_coco.py index 0ca42634478..facbb34cf05 100644 --- a/configs/common/ms_3x_coco.py +++ b/configs/common/ms_3x_coco.py @@ -4,16 +4,23 @@ dataset_type = 'CocoDataset' data_root = 'data/coco/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', scale=[(1333, 640), (1333, 800)], @@ -22,7 +29,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( @@ -45,7 +52,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline))) + pipeline=train_pipeline, + backend_args=backend_args))) val_dataloader = dict( batch_size=1, num_workers=2, @@ -58,13 +66,15 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', - metric='bbox') + metric='bbox', + backend_args=backend_args) test_evaluator = val_evaluator # training schedule for 3x with `RepeatDataset` diff --git a/configs/common/ssj_270k_coco-instance.py b/configs/common/ssj_270k_coco-instance.py index 677f375e1a1..7407644fd59 100644 --- a/configs/common/ssj_270k_coco-instance.py +++ b/configs/common/ssj_270k_coco-instance.py @@ -5,19 +5,25 @@ image_size = (1024, 1024) -file_client_args = dict(backend='disk') -# comment out the code below to use different file client -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) +backend_args = None # Standard Scale Jittering (SSJ) resizes and crops an image # with a resize range of 0.8 to 1.25 of the original image size. train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomResize', @@ -35,7 +41,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( @@ -55,7 +61,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( batch_size=1, num_workers=2, @@ -68,14 +75,16 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', metric=['bbox', 'segm'], - format_only=False) + format_only=False, + backend_args=backend_args) test_evaluator = val_evaluator # The model is trained by 270k iterations with batch_size 64, diff --git a/configs/common/ssj_scp_270k_coco-instance.py b/configs/common/ssj_scp_270k_coco-instance.py index 2289f2f6234..06159dd4031 100644 --- a/configs/common/ssj_scp_270k_coco-instance.py +++ b/configs/common/ssj_scp_270k_coco-instance.py @@ -5,19 +5,25 @@ image_size = (1024, 1024) -file_client_args = dict(backend='disk') -# comment out the code below to use different file client -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) +backend_args = None # Standard Scale Jittering (SSJ) resizes and crops an image # with a resize range of 0.8 to 1.25 of the original image size. load_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomResize', @@ -49,5 +55,6 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=load_pipeline), + pipeline=load_pipeline, + backend_args=backend_args), pipeline=train_pipeline)) diff --git a/configs/convnext/cascade-mask-rcnn_convnext-t-p4-w7_fpn_4conv1fc-giou_amp-ms-crop-3x_coco.py b/configs/convnext/cascade-mask-rcnn_convnext-t-p4-w7_fpn_4conv1fc-giou_amp-ms-crop-3x_coco.py index 53edb391921..1e031e90d52 100644 --- a/configs/convnext/cascade-mask-rcnn_convnext-t-p4-w7_fpn_4conv1fc-giou_amp-ms-crop-3x_coco.py +++ b/configs/convnext/cascade-mask-rcnn_convnext-t-p4-w7_fpn_4conv1fc-giou_amp-ms-crop-3x_coco.py @@ -85,9 +85,7 @@ # augmentation strategy originates from DETR / Sparse RCNN train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict(type='RandomFlip', prob=0.5), dict( diff --git a/configs/convnext/mask-rcnn_convnext-t-p4-w7_fpn_amp-ms-crop-3x_coco.py b/configs/convnext/mask-rcnn_convnext-t-p4-w7_fpn_amp-ms-crop-3x_coco.py index e9932c44b03..23d46e289eb 100644 --- a/configs/convnext/mask-rcnn_convnext-t-p4-w7_fpn_amp-ms-crop-3x_coco.py +++ b/configs/convnext/mask-rcnn_convnext-t-p4-w7_fpn_amp-ms-crop-3x_coco.py @@ -26,9 +26,7 @@ # augmentation strategy originates from DETR / Sparse RCNN train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict(type='RandomFlip', prob=0.5), dict( diff --git a/configs/cornernet/cornernet_hourglass104_8xb6-210e-mstest_coco.py b/configs/cornernet/cornernet_hourglass104_8xb6-210e-mstest_coco.py index 38c43a1c9f2..20751ef4af1 100644 --- a/configs/cornernet/cornernet_hourglass104_8xb6-210e-mstest_coco.py +++ b/configs/cornernet/cornernet_hourglass104_8xb6-210e-mstest_coco.py @@ -45,9 +45,7 @@ # data settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='PhotoMetricDistortion', @@ -78,7 +76,8 @@ dict( type='LoadImageFromFile', to_float32=True, - file_client_args={{_base_.file_client_args}}), + backend_args={{_base_.backend_args}}, + ), # don't need Resize dict( type='RandomCenterCropPad', diff --git a/configs/crowddet/crowddet-rcnn_r50_fpn_8xb2-30e_crowdhuman.py b/configs/crowddet/crowddet-rcnn_r50_fpn_8xb2-30e_crowdhuman.py index 97ec2db3c01..8815be77d49 100644 --- a/configs/crowddet/crowddet-rcnn_r50_fpn_8xb2-30e_crowdhuman.py +++ b/configs/crowddet/crowddet-rcnn_r50_fpn_8xb2-30e_crowdhuman.py @@ -132,9 +132,24 @@ dataset_type = 'CrowdHumanDataset' data_root = 'data/CrowdHuman/' -file_client_args = dict(backend='disk') + +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/tracking/CrowdHuman/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( +# backend='petrel', +# path_mapping=dict({ +# './data/': 's3://openmmlab/datasets/tracking/', +# 'data/': 's3://openmmlab/datasets/tracking/' +# })) +backend_args = None + train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict(type='RandomFlip', prob=0.5), dict( @@ -143,7 +158,7 @@ 'flip_direction')) ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(1400, 800), keep_ratio=True), # avoid bboxes being resized dict(type='LoadAnnotations', with_bbox=True), @@ -165,7 +180,8 @@ ann_file='annotation_train.odgt', data_prefix=dict(img='Images/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( batch_size=1, num_workers=2, @@ -178,13 +194,15 @@ ann_file='annotation_val.odgt', data_prefix=dict(img='Images/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CrowdHumanMetric', ann_file=data_root + 'annotation_val.odgt', - metric=['AP', 'MR', 'JI']) + metric=['AP', 'MR', 'JI'], + backend_args=backend_args) test_evaluator = val_evaluator train_cfg = dict(type='EpochBasedTrainLoop', max_epochs=30, val_interval=1) diff --git a/configs/dab_detr/dab-detr_r50_8xb2-50e_coco.py b/configs/dab_detr/dab-detr_r50_8xb2-50e_coco.py index 723f7b1340e..314ed97e2d8 100644 --- a/configs/dab_detr/dab-detr_r50_8xb2-50e_coco.py +++ b/configs/dab_detr/dab-detr_r50_8xb2-50e_coco.py @@ -93,9 +93,7 @@ # train_pipeline, NOTE the img_scale and the Pad's size_divisor is different # from the default setting in mmdet. train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict(type='RandomFlip', prob=0.5), dict( diff --git a/configs/deformable_detr/deformable-detr_r50_16xb2-50e_coco.py b/configs/deformable_detr/deformable-detr_r50_16xb2-50e_coco.py index b2f064cc511..e0dee411c8e 100644 --- a/configs/deformable_detr/deformable-detr_r50_16xb2-50e_coco.py +++ b/configs/deformable_detr/deformable-detr_r50_16xb2-50e_coco.py @@ -81,9 +81,7 @@ # train_pipeline, NOTE the img_scale and the Pad's size_divisor is different # from the default setting in mmdet. train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict(type='RandomFlip', prob=0.5), dict( diff --git a/configs/detr/detr_r50_8xb2-150e_coco.py b/configs/detr/detr_r50_8xb2-150e_coco.py index 1aba1c3c1ca..aaa15410532 100644 --- a/configs/detr/detr_r50_8xb2-150e_coco.py +++ b/configs/detr/detr_r50_8xb2-150e_coco.py @@ -89,9 +89,7 @@ # train_pipeline, NOTE the img_scale and the Pad's size_divisor is different # from the default setting in mmdet. train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict(type='RandomFlip', prob=0.5), dict( diff --git a/configs/dino/dino-4scale_r50_8xb2-12e_coco.py b/configs/dino/dino-4scale_r50_8xb2-12e_coco.py index eb5f2a44704..5831f898b4a 100644 --- a/configs/dino/dino-4scale_r50_8xb2-12e_coco.py +++ b/configs/dino/dino-4scale_r50_8xb2-12e_coco.py @@ -88,9 +88,7 @@ # train_pipeline, NOTE the img_scale and the Pad's size_divisor is different # from the default setting in mmdet. train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict(type='RandomFlip', prob=0.5), dict( diff --git a/configs/dyhead/atss_r50-caffe_fpn_dyhead_1x_coco.py b/configs/dyhead/atss_r50-caffe_fpn_dyhead_1x_coco.py index cbaf9a7c9b3..8716f1226cb 100644 --- a/configs/dyhead/atss_r50-caffe_fpn_dyhead_1x_coco.py +++ b/configs/dyhead/atss_r50-caffe_fpn_dyhead_1x_coco.py @@ -82,18 +82,14 @@ optim_wrapper = dict(optimizer=dict(lr=0.01)) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', scale=(1333, 800), keep_ratio=True, backend='pillow'), dict(type='RandomFlip', prob=0.5), dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(1333, 800), keep_ratio=True, backend='pillow'), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/configs/dyhead/atss_swin-l-p4-w12_fpn_dyhead_ms-2x_coco.py b/configs/dyhead/atss_swin-l-p4-w12_fpn_dyhead_ms-2x_coco.py index ffc7f44a745..f537b9dc9b1 100644 --- a/configs/dyhead/atss_swin-l-p4-w12_fpn_dyhead_ms-2x_coco.py +++ b/configs/dyhead/atss_swin-l-p4-w12_fpn_dyhead_ms-2x_coco.py @@ -90,9 +90,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', @@ -103,9 +101,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(2000, 1200), keep_ratio=True, backend='pillow'), dict(type='LoadAnnotations', with_bbox=True), dict( @@ -124,7 +120,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline))) + pipeline=train_pipeline, + backend_args={{_base_.backend_args}}))) val_dataloader = dict(dataset=dict(pipeline=test_pipeline)) test_dataloader = val_dataloader diff --git a/configs/efficientnet/retinanet_effb3_fpn_8xb4-crop896-1x_coco.py b/configs/efficientnet/retinanet_effb3_fpn_8xb4-crop896-1x_coco.py index 039ed5fdc05..2d0d9cefd0b 100644 --- a/configs/efficientnet/retinanet_effb3_fpn_8xb4-crop896-1x_coco.py +++ b/configs/efficientnet/retinanet_effb3_fpn_8xb4-crop896-1x_coco.py @@ -41,9 +41,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', @@ -55,9 +53,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=image_size, keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/configs/fast_rcnn/README.md b/configs/fast_rcnn/README.md index 91342474482..cd582ec8c6f 100644 --- a/configs/fast_rcnn/README.md +++ b/configs/fast_rcnn/README.md @@ -68,7 +68,7 @@ The `pred_instance` is an `InstanceData` containing the sorted boxes and scores train_pipeline = [ dict( type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + backend_args={{_base_.backend_args}}), dict(type='LoadProposals', num_max_proposals=2000), dict(type='LoadAnnotations', with_bbox=True), dict( @@ -82,7 +82,7 @@ The `pred_instance` is an `InstanceData` containing the sorted boxes and scores test_pipeline = [ dict( type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + backend_args={{_base_.backend_args}}), dict(type='LoadProposals', num_max_proposals=None), dict( type='ProposalBroadcaster', diff --git a/configs/fast_rcnn/fast-rcnn_r50_fpn_1x_coco.py b/configs/fast_rcnn/fast-rcnn_r50_fpn_1x_coco.py index 5008292330f..daefe2d2d28 100644 --- a/configs/fast_rcnn/fast-rcnn_r50_fpn_1x_coco.py +++ b/configs/fast_rcnn/fast-rcnn_r50_fpn_1x_coco.py @@ -4,9 +4,7 @@ '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadProposals', num_max_proposals=2000), dict(type='LoadAnnotations', with_bbox=True), dict( @@ -18,9 +16,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadProposals', num_max_proposals=None), dict( type='ProposalBroadcaster', diff --git a/configs/fcos/fcos_r101-caffe_fpn_gn-head_ms-640-800-2x_coco.py b/configs/fcos/fcos_r101-caffe_fpn_gn-head_ms-640-800-2x_coco.py index 0b8039c1e71..859b45c94b2 100644 --- a/configs/fcos/fcos_r101-caffe_fpn_gn-head_ms-640-800-2x_coco.py +++ b/configs/fcos/fcos_r101-caffe_fpn_gn-head_ms-640-800-2x_coco.py @@ -10,9 +10,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomChoiceResize', diff --git a/configs/fcos/fcos_r50-caffe_fpn_gn-head_ms-640-800-2x_coco.py b/configs/fcos/fcos_r50-caffe_fpn_gn-head_ms-640-800-2x_coco.py index 9888dd8f25f..12e9160d812 100644 --- a/configs/fcos/fcos_r50-caffe_fpn_gn-head_ms-640-800-2x_coco.py +++ b/configs/fcos/fcos_r50-caffe_fpn_gn-head_ms-640-800-2x_coco.py @@ -2,9 +2,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomChoiceResize', diff --git a/configs/fcos/fcos_x101-64x4d_fpn_gn-head_ms-640-800-2x_coco.py b/configs/fcos/fcos_x101-64x4d_fpn_gn-head_ms-640-800-2x_coco.py index 3f58665dce5..aae1fceea58 100644 --- a/configs/fcos/fcos_x101-64x4d_fpn_gn-head_ms-640-800-2x_coco.py +++ b/configs/fcos/fcos_x101-64x4d_fpn_gn-head_ms-640-800-2x_coco.py @@ -24,9 +24,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomChoiceResize', diff --git a/configs/foveabox/fovea_r101_fpn_gn-head-align_ms-640-800-4xb4-2x_coco.py b/configs/foveabox/fovea_r101_fpn_gn-head-align_ms-640-800-4xb4-2x_coco.py index 1ab77bf7458..e1852d581fc 100644 --- a/configs/foveabox/fovea_r101_fpn_gn-head-align_ms-640-800-4xb4-2x_coco.py +++ b/configs/foveabox/fovea_r101_fpn_gn-head-align_ms-640-800-4xb4-2x_coco.py @@ -8,9 +8,7 @@ with_deform=True, norm_cfg=dict(type='GN', num_groups=32, requires_grad=True))) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomChoiceResize', diff --git a/configs/foveabox/fovea_r50_fpn_gn-head-align_ms-640-800-4xb4-2x_coco.py b/configs/foveabox/fovea_r50_fpn_gn-head-align_ms-640-800-4xb4-2x_coco.py index be240259f3a..5690bcae08c 100644 --- a/configs/foveabox/fovea_r50_fpn_gn-head-align_ms-640-800-4xb4-2x_coco.py +++ b/configs/foveabox/fovea_r50_fpn_gn-head-align_ms-640-800-4xb4-2x_coco.py @@ -4,9 +4,7 @@ with_deform=True, norm_cfg=dict(type='GN', num_groups=32, requires_grad=True))) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomChoiceResize', diff --git a/configs/fpg/faster-rcnn_r50_fpn_crop640-50e_coco.py b/configs/fpg/faster-rcnn_r50_fpn_crop640-50e_coco.py index 019105dbfac..46211de03f3 100644 --- a/configs/fpg/faster-rcnn_r50_fpn_crop640-50e_coco.py +++ b/configs/fpg/faster-rcnn_r50_fpn_crop640-50e_coco.py @@ -16,9 +16,7 @@ data_root = 'data/coco/' train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', @@ -35,9 +33,7 @@ ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=image_size, keep_ratio=True), dict( type='PackDetInputs', diff --git a/configs/fpg/mask-rcnn_r50_fpn_crop640-50e_coco.py b/configs/fpg/mask-rcnn_r50_fpn_crop640-50e_coco.py index baaf9a4b1e5..08ca5b6ffd8 100644 --- a/configs/fpg/mask-rcnn_r50_fpn_crop640-50e_coco.py +++ b/configs/fpg/mask-rcnn_r50_fpn_crop640-50e_coco.py @@ -22,9 +22,7 @@ data_root = 'data/coco/' train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomResize', @@ -41,9 +39,7 @@ ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=image_size, keep_ratio=True), dict( type='PackDetInputs', diff --git a/configs/gfl/gfl_r50_fpn_ms-2x_coco.py b/configs/gfl/gfl_r50_fpn_ms-2x_coco.py index cb1137e01df..22770eb1019 100644 --- a/configs/gfl/gfl_r50_fpn_ms-2x_coco.py +++ b/configs/gfl/gfl_r50_fpn_ms-2x_coco.py @@ -17,9 +17,7 @@ # multi-scale training train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', scale=[(1333, 480), (1333, 800)], diff --git a/configs/guided_anchoring/ga-retinanet_r101-caffe_fpn_ms-2x.py b/configs/guided_anchoring/ga-retinanet_r101-caffe_fpn_ms-2x.py index 459a1900241..012e89b8338 100644 --- a/configs/guided_anchoring/ga-retinanet_r101-caffe_fpn_ms-2x.py +++ b/configs/guided_anchoring/ga-retinanet_r101-caffe_fpn_ms-2x.py @@ -1,9 +1,7 @@ _base_ = './ga-retinanet_r101-caffe_fpn_1x_coco.py' train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', scale=[(1333, 480), (1333, 960)], diff --git a/configs/hrnet/fcos_hrnetv2p-w32-gn-head_ms-640-800-4xb4-2x_coco.py b/configs/hrnet/fcos_hrnetv2p-w32-gn-head_ms-640-800-4xb4-2x_coco.py index 3c107c8f1b7..4c977bf31ed 100644 --- a/configs/hrnet/fcos_hrnetv2p-w32-gn-head_ms-640-800-4xb4-2x_coco.py +++ b/configs/hrnet/fcos_hrnetv2p-w32-gn-head_ms-640-800-4xb4-2x_coco.py @@ -7,9 +7,7 @@ bgr_to_rgb=False)) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomChoiceResize', diff --git a/configs/htc/htc_r50_fpn_1x_coco.py b/configs/htc/htc_r50_fpn_1x_coco.py index 03ddb61ab1d..3573f1f6980 100644 --- a/configs/htc/htc_r50_fpn_1x_coco.py +++ b/configs/htc/htc_r50_fpn_1x_coco.py @@ -20,9 +20,7 @@ type='CrossEntropyLoss', ignore_index=255, loss_weight=0.2)))) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict( type='LoadAnnotations', with_bbox=True, with_mask=True, with_seg=True), dict(type='Resize', scale=(1333, 800), keep_ratio=True), diff --git a/configs/instaboost/cascade-mask-rcnn_r50_fpn_instaboost-4x_coco.py b/configs/instaboost/cascade-mask-rcnn_r50_fpn_instaboost-4x_coco.py index 00165fb0342..f7736cf5756 100644 --- a/configs/instaboost/cascade-mask-rcnn_r50_fpn_instaboost-4x_coco.py +++ b/configs/instaboost/cascade-mask-rcnn_r50_fpn_instaboost-4x_coco.py @@ -1,9 +1,7 @@ _base_ = '../cascade_rcnn/cascade-mask-rcnn_r50_fpn_1x_coco.py' train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict( type='InstaBoost', action_candidate=('normal', 'horizontal', 'skip'), diff --git a/configs/instaboost/mask-rcnn_r50_fpn_instaboost-4x_coco.py b/configs/instaboost/mask-rcnn_r50_fpn_instaboost-4x_coco.py index 4e90eda8387..0a8c9be81f0 100644 --- a/configs/instaboost/mask-rcnn_r50_fpn_instaboost-4x_coco.py +++ b/configs/instaboost/mask-rcnn_r50_fpn_instaboost-4x_coco.py @@ -1,9 +1,7 @@ _base_ = '../mask_rcnn/mask-rcnn_r50_fpn_1x_coco.py' train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict( type='InstaBoost', action_candidate=('normal', 'horizontal', 'skip'), diff --git a/configs/ld/ld_r101-gflv1-r101-dcn_fpn_2x_coco.py b/configs/ld/ld_r101-gflv1-r101-dcn_fpn_2x_coco.py index 681c9e086c2..a7e928bdc23 100644 --- a/configs/ld/ld_r101-gflv1-r101-dcn_fpn_2x_coco.py +++ b/configs/ld/ld_r101-gflv1-r101-dcn_fpn_2x_coco.py @@ -38,9 +38,7 @@ # multi-scale training train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', scale=[(1333, 480), (1333, 800)], diff --git a/configs/mask2former/mask2former_r50_8xb2-lsj-50e_coco-panoptic.py b/configs/mask2former/mask2former_r50_8xb2-lsj-50e_coco-panoptic.py index 1a20244299b..c53e981bf0d 100644 --- a/configs/mask2former/mask2former_r50_8xb2-lsj-50e_coco-panoptic.py +++ b/configs/mask2former/mask2former_r50_8xb2-lsj-50e_coco-panoptic.py @@ -150,12 +150,16 @@ # dataset settings data_root = 'data/coco/' train_pipeline = [ - dict(type='LoadImageFromFile', to_float32=True), + dict( + type='LoadImageFromFile', + to_float32=True, + backend_args={{_base_.backend_args}}), dict( type='LoadPanopticAnnotations', with_bbox=True, with_mask=True, - with_seg=True), + with_seg=True, + backend_args={{_base_.backend_args}}), dict(type='RandomFlip', prob=0.5), # large scale jittering dict( @@ -179,12 +183,12 @@ type='CocoPanopticMetric', ann_file=data_root + 'annotations/panoptic_val2017.json', seg_prefix=data_root + 'annotations/panoptic_val2017/', - ), + backend_args={{_base_.backend_args}}), dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', metric=['bbox', 'segm'], - ) + backend_args={{_base_.backend_args}}) ] test_evaluator = val_evaluator diff --git a/configs/mask2former/mask2former_r50_8xb2-lsj-50e_coco.py b/configs/mask2former/mask2former_r50_8xb2-lsj-50e_coco.py index 6bc9fd7472a..24a17f58c54 100644 --- a/configs/mask2former/mask2former_r50_8xb2-lsj-50e_coco.py +++ b/configs/mask2former/mask2former_r50_8xb2-lsj-50e_coco.py @@ -36,7 +36,10 @@ # dataset settings train_pipeline = [ - dict(type='LoadImageFromFile', to_float32=True), + dict( + type='LoadImageFromFile', + to_float32=True, + backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict(type='RandomFlip', prob=0.5), # large scale jittering @@ -57,7 +60,10 @@ ] test_pipeline = [ - dict(type='LoadImageFromFile', to_float32=True), + dict( + type='LoadImageFromFile', + to_float32=True, + backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(1333, 800), keep_ratio=True), # If you don't have a gt annotation, delete the pipeline dict(type='LoadAnnotations', with_bbox=True, with_mask=True), @@ -89,5 +95,6 @@ type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', metric=['bbox', 'segm'], - format_only=False) + format_only=False, + backend_args={{_base_.backend_args}}) test_evaluator = val_evaluator diff --git a/configs/mask_rcnn/mask-rcnn_r50-caffe_fpn_ms-1x_coco.py b/configs/mask_rcnn/mask-rcnn_r50-caffe_fpn_ms-1x_coco.py index 6c0f1bde7aa..7702ae14a9c 100644 --- a/configs/mask_rcnn/mask-rcnn_r50-caffe_fpn_ms-1x_coco.py +++ b/configs/mask_rcnn/mask-rcnn_r50-caffe_fpn_ms-1x_coco.py @@ -14,9 +14,7 @@ checkpoint='open-mmlab://detectron2/resnet50_caffe'))) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomChoiceResize', diff --git a/configs/mask_rcnn/mask-rcnn_r50-caffe_fpn_ms-poly-1x_coco.py b/configs/mask_rcnn/mask-rcnn_r50-caffe_fpn_ms-poly-1x_coco.py index dd57d035f08..94d94dd3613 100644 --- a/configs/mask_rcnn/mask-rcnn_r50-caffe_fpn_ms-poly-1x_coco.py +++ b/configs/mask_rcnn/mask-rcnn_r50-caffe_fpn_ms-poly-1x_coco.py @@ -13,9 +13,7 @@ type='Pretrained', checkpoint='open-mmlab://detectron2/resnet50_caffe'))) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict( type='LoadAnnotations', with_bbox=True, diff --git a/configs/mask_rcnn/mask-rcnn_r50_fpn_poly-1x_coco.py b/configs/mask_rcnn/mask-rcnn_r50_fpn_poly-1x_coco.py index 193dcd1930f..826180ce0a8 100644 --- a/configs/mask_rcnn/mask-rcnn_r50_fpn_poly-1x_coco.py +++ b/configs/mask_rcnn/mask-rcnn_r50_fpn_poly-1x_coco.py @@ -5,9 +5,7 @@ ] train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict( type='LoadAnnotations', with_bbox=True, diff --git a/configs/mask_rcnn/mask-rcnn_x101-32x8d_fpn_ms-poly-1x_coco.py b/configs/mask_rcnn/mask-rcnn_x101-32x8d_fpn_ms-poly-1x_coco.py index a743aaea952..6ee204d9000 100644 --- a/configs/mask_rcnn/mask-rcnn_x101-32x8d_fpn_ms-poly-1x_coco.py +++ b/configs/mask_rcnn/mask-rcnn_x101-32x8d_fpn_ms-poly-1x_coco.py @@ -22,9 +22,7 @@ checkpoint='open-mmlab://detectron2/resnext101_32x8d'))) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict( type='LoadAnnotations', with_bbox=True, diff --git a/configs/nas_fpn/retinanet_r50_fpn_crop640-50e_coco.py b/configs/nas_fpn/retinanet_r50_fpn_crop640-50e_coco.py index 6062a7601f4..11c34f6758a 100644 --- a/configs/nas_fpn/retinanet_r50_fpn_crop640-50e_coco.py +++ b/configs/nas_fpn/retinanet_r50_fpn_crop640-50e_coco.py @@ -24,9 +24,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', @@ -38,9 +36,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(640, 640), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/configs/openimages/ssd300_32xb8-36e_openimages.py b/configs/openimages/ssd300_32xb8-36e_openimages.py index 9847ef5302b..9cb51cae00a 100644 --- a/configs/openimages/ssd300_32xb8-36e_openimages.py +++ b/configs/openimages/ssd300_32xb8-36e_openimages.py @@ -11,9 +11,7 @@ data_root = 'data/OpenImages/' input_size = 300 train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='PhotoMetricDistortion', @@ -35,7 +33,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile'), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(input_size, input_size), keep_ratio=False), # avoid bboxes being resized dict(type='LoadAnnotations', with_bbox=True), diff --git a/configs/paa/paa_r50_fpn_ms-3x_coco.py b/configs/paa/paa_r50_fpn_ms-3x_coco.py index 803ceeca0ec..fed8b90a0fd 100644 --- a/configs/paa/paa_r50_fpn_ms-3x_coco.py +++ b/configs/paa/paa_r50_fpn_ms-3x_coco.py @@ -18,9 +18,7 @@ train_cfg = dict(max_epochs=max_epochs) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', scale=[(1333, 640), (1333, 800)], diff --git a/configs/pascal_voc/faster-rcnn_r50-caffe-c4_ms-18k_voc0712.py b/configs/pascal_voc/faster-rcnn_r50-caffe-c4_ms-18k_voc0712.py index 7a3c34367d7..dddc0bbdf33 100644 --- a/configs/pascal_voc/faster-rcnn_r50-caffe-c4_ms-18k_voc0712.py +++ b/configs/pascal_voc/faster-rcnn_r50-caffe-c4_ms-18k_voc0712.py @@ -7,9 +7,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomChoiceResize', @@ -21,9 +19,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(1333, 800), keep_ratio=True), # avoid bboxes being resized dict(type='LoadAnnotations', with_bbox=True), @@ -45,14 +41,16 @@ ann_file='VOC2007/ImageSets/Main/trainval.txt', data_prefix=dict(sub_data_root='VOC2007/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline), + pipeline=train_pipeline, + backend_args={{_base_.backend_args}}), dict( type='VOCDataset', data_root={{_base_.data_root}}, ann_file='VOC2012/ImageSets/Main/trainval.txt', data_prefix=dict(sub_data_root='VOC2012/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline) + pipeline=train_pipeline, + backend_args={{_base_.backend_args}}) ])) val_dataloader = dict(dataset=dict(pipeline=test_pipeline)) diff --git a/configs/pascal_voc/faster-rcnn_r50_fpn_1x_voc0712-cocofmt.py b/configs/pascal_voc/faster-rcnn_r50_fpn_1x_voc0712-cocofmt.py index d8bfd043a2e..0b0aa41d67f 100644 --- a/configs/pascal_voc/faster-rcnn_r50_fpn_1x_voc0712-cocofmt.py +++ b/configs/pascal_voc/faster-rcnn_r50_fpn_1x_voc0712-cocofmt.py @@ -22,18 +22,14 @@ data_root = 'data/VOCdevkit/' train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', scale=(1000, 600), keep_ratio=True), dict(type='RandomFlip', prob=0.5), dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(1000, 600), keep_ratio=True), # avoid bboxes being resized dict(type='LoadAnnotations', with_bbox=True), @@ -54,7 +50,8 @@ data_prefix=dict(img=''), metainfo=METAINFO, filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline))) + pipeline=train_pipeline, + backend_args={{_base_.backend_args}}))) val_dataloader = dict( dataset=dict( type=dataset_type, @@ -68,7 +65,8 @@ type='CocoMetric', ann_file=data_root + 'annotations/voc07_test.json', metric='bbox', - format_only=False) + format_only=False, + backend_args={{_base_.backend_args}}) test_evaluator = val_evaluator # training schedule, the dataset is repeated 3 times, so the diff --git a/configs/queryinst/queryinst_r50_fpn_300-proposals_crop-ms-480-800-3x_coco.py b/configs/queryinst/queryinst_r50_fpn_300-proposals_crop-ms-480-800-3x_coco.py index 1f5ada6ead4..33ab061267b 100644 --- a/configs/queryinst/queryinst_r50_fpn_300-proposals_crop-ms-480-800-3x_coco.py +++ b/configs/queryinst/queryinst_r50_fpn_300-proposals_crop-ms-480-800-3x_coco.py @@ -9,9 +9,7 @@ # augmentation strategy originates from DETR. train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict(type='RandomFlip', prob=0.5), dict( diff --git a/configs/queryinst/queryinst_r50_fpn_ms-480-800-3x_coco.py b/configs/queryinst/queryinst_r50_fpn_ms-480-800-3x_coco.py index 4e4434982bc..6b99374ef43 100644 --- a/configs/queryinst/queryinst_r50_fpn_ms-480-800-3x_coco.py +++ b/configs/queryinst/queryinst_r50_fpn_ms-480-800-3x_coco.py @@ -1,9 +1,7 @@ _base_ = './queryinst_r50_fpn_1x_coco.py' train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomChoiceResize', diff --git a/configs/regnet/mask-rcnn_regnetx-3.2GF_fpn_ms-3x_coco.py b/configs/regnet/mask-rcnn_regnetx-3.2GF_fpn_ms-3x_coco.py index 3fc02ffbbdb..36482c939dc 100644 --- a/configs/regnet/mask-rcnn_regnetx-3.2GF_fpn_ms-3x_coco.py +++ b/configs/regnet/mask-rcnn_regnetx-3.2GF_fpn_ms-3x_coco.py @@ -27,9 +27,7 @@ num_outs=5)) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomChoiceResize', diff --git a/configs/resnest/cascade-mask-rcnn_s50_fpn_syncbn-backbone+head_ms-1x_coco.py b/configs/resnest/cascade-mask-rcnn_s50_fpn_syncbn-backbone+head_ms-1x_coco.py index 25ddc7a1a60..c6ef41c05cd 100644 --- a/configs/resnest/cascade-mask-rcnn_s50_fpn_syncbn-backbone+head_ms-1x_coco.py +++ b/configs/resnest/cascade-mask-rcnn_s50_fpn_syncbn-backbone+head_ms-1x_coco.py @@ -83,9 +83,7 @@ mask_head=dict(norm_cfg=norm_cfg))) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict( type='LoadAnnotations', with_bbox=True, diff --git a/configs/resnest/cascade-rcnn_s50_fpn_syncbn-backbone+head_ms-range-1x_coco.py b/configs/resnest/cascade-rcnn_s50_fpn_syncbn-backbone+head_ms-range-1x_coco.py index 97a3970e8b2..7ce7b56320a 100644 --- a/configs/resnest/cascade-rcnn_s50_fpn_syncbn-backbone+head_ms-range-1x_coco.py +++ b/configs/resnest/cascade-rcnn_s50_fpn_syncbn-backbone+head_ms-range-1x_coco.py @@ -81,9 +81,7 @@ ], )) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', scale=[(1333, 640), (1333, 800)], diff --git a/configs/resnest/faster-rcnn_s50_fpn_syncbn-backbone+head_ms-range-1x_coco.py b/configs/resnest/faster-rcnn_s50_fpn_syncbn-backbone+head_ms-range-1x_coco.py index f64dcdc2518..8f0ec6e07af 100644 --- a/configs/resnest/faster-rcnn_s50_fpn_syncbn-backbone+head_ms-range-1x_coco.py +++ b/configs/resnest/faster-rcnn_s50_fpn_syncbn-backbone+head_ms-range-1x_coco.py @@ -27,9 +27,7 @@ norm_cfg=norm_cfg))) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', scale=[(1333, 640), (1333, 800)], diff --git a/configs/resnest/mask-rcnn_s50_fpn_syncbn-backbone+head_ms-1x_coco.py b/configs/resnest/mask-rcnn_s50_fpn_syncbn-backbone+head_ms-1x_coco.py index 309228fea62..c6f27000862 100644 --- a/configs/resnest/mask-rcnn_s50_fpn_syncbn-backbone+head_ms-1x_coco.py +++ b/configs/resnest/mask-rcnn_s50_fpn_syncbn-backbone+head_ms-1x_coco.py @@ -28,9 +28,7 @@ mask_head=dict(norm_cfg=norm_cfg))) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict( type='LoadAnnotations', with_bbox=True, diff --git a/configs/retinanet/retinanet_tta.py b/configs/retinanet/retinanet_tta.py index d56563ea780..d0f37e0ab25 100644 --- a/configs/retinanet/retinanet_tta.py +++ b/configs/retinanet/retinanet_tta.py @@ -4,7 +4,7 @@ img_scales = [(1333, 800), (666, 400), (2000, 1200)] tta_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')), + dict(type='LoadImageFromFile', backend_args=None), dict( type='TestTimeAug', transforms=[[ diff --git a/configs/rpn/rpn_r50_fpn_1x_coco.py b/configs/rpn/rpn_r50_fpn_1x_coco.py index 692ff9e6650..7fe88d395b8 100644 --- a/configs/rpn/rpn_r50_fpn_1x_coco.py +++ b/configs/rpn/rpn_r50_fpn_1x_coco.py @@ -17,7 +17,7 @@ # type='CocoMetric', # ann_file=data_root + 'annotations/instances_val2017.json', # metric='proposal_fast', -# file_client_args={{_base_.file_client_args}}, +# backend_args={{_base_.backend_args}}, # format_only=False) # ] diff --git a/configs/rtmdet/rtmdet-ins_l_8xb32-300e_coco.py b/configs/rtmdet/rtmdet-ins_l_8xb32-300e_coco.py index 1ecacab8044..6b4b9240a64 100644 --- a/configs/rtmdet/rtmdet-ins_l_8xb32-300e_coco.py +++ b/configs/rtmdet/rtmdet-ins_l_8xb32-300e_coco.py @@ -32,9 +32,7 @@ ) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict( type='LoadAnnotations', with_bbox=True, @@ -67,9 +65,7 @@ train_dataloader = dict(pin_memory=True, dataset=dict(pipeline=train_pipeline)) train_pipeline_stage2 = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict( type='LoadAnnotations', with_bbox=True, diff --git a/configs/rtmdet/rtmdet-ins_s_8xb32-300e_coco.py b/configs/rtmdet/rtmdet-ins_s_8xb32-300e_coco.py index 7785f2ff208..28bc21cc93b 100644 --- a/configs/rtmdet/rtmdet-ins_s_8xb32-300e_coco.py +++ b/configs/rtmdet/rtmdet-ins_s_8xb32-300e_coco.py @@ -10,9 +10,7 @@ bbox_head=dict(in_channels=128, feat_channels=128)) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict( type='LoadAnnotations', with_bbox=True, @@ -43,9 +41,7 @@ ] train_pipeline_stage2 = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict( type='LoadAnnotations', with_bbox=True, diff --git a/configs/rtmdet/rtmdet-ins_tiny_8xb32-300e_coco.py b/configs/rtmdet/rtmdet-ins_tiny_8xb32-300e_coco.py index 33b62878027..954f911614e 100644 --- a/configs/rtmdet/rtmdet-ins_tiny_8xb32-300e_coco.py +++ b/configs/rtmdet/rtmdet-ins_tiny_8xb32-300e_coco.py @@ -12,9 +12,7 @@ bbox_head=dict(in_channels=96, feat_channels=96)) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict( type='LoadAnnotations', with_bbox=True, diff --git a/configs/rtmdet/rtmdet_l_8xb32-300e_coco.py b/configs/rtmdet/rtmdet_l_8xb32-300e_coco.py index fc623fcc635..e4c46aadbda 100644 --- a/configs/rtmdet/rtmdet_l_8xb32-300e_coco.py +++ b/configs/rtmdet/rtmdet_l_8xb32-300e_coco.py @@ -62,9 +62,7 @@ ) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict(type='CachedMosaic', img_scale=(640, 640), pad_val=114.0), dict( @@ -86,9 +84,7 @@ ] train_pipeline_stage2 = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', @@ -103,9 +99,7 @@ ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(640, 640), keep_ratio=True), dict(type='Pad', size=(640, 640), pad_val=dict(img=(114, 114, 114))), dict( diff --git a/configs/rtmdet/rtmdet_s_8xb32-300e_coco.py b/configs/rtmdet/rtmdet_s_8xb32-300e_coco.py index 355918147cb..cbf76247b74 100644 --- a/configs/rtmdet/rtmdet_s_8xb32-300e_coco.py +++ b/configs/rtmdet/rtmdet_s_8xb32-300e_coco.py @@ -10,9 +10,7 @@ bbox_head=dict(in_channels=128, feat_channels=128, exp_on_reg=False)) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict(type='CachedMosaic', img_scale=(640, 640), pad_val=114.0), dict( @@ -34,9 +32,7 @@ ] train_pipeline_stage2 = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', diff --git a/configs/rtmdet/rtmdet_tiny_8xb32-300e_coco.py b/configs/rtmdet/rtmdet_tiny_8xb32-300e_coco.py index e05c4b169c1..a686f4a7f0c 100644 --- a/configs/rtmdet/rtmdet_tiny_8xb32-300e_coco.py +++ b/configs/rtmdet/rtmdet_tiny_8xb32-300e_coco.py @@ -12,9 +12,7 @@ bbox_head=dict(in_channels=96, feat_channels=96, exp_on_reg=False)) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='CachedMosaic', diff --git a/configs/rtmdet/rtmdet_tta.py b/configs/rtmdet/rtmdet_tta.py index f4e003541e9..f7adcbc712a 100644 --- a/configs/rtmdet/rtmdet_tta.py +++ b/configs/rtmdet/rtmdet_tta.py @@ -4,7 +4,7 @@ img_scales = [(640, 640), (320, 320), (960, 960)] tta_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')), + dict(type='LoadImageFromFile', backend_args=None), dict( type='TestTimeAug', transforms=[ diff --git a/configs/sabl/sabl-retinanet_r101-gn_fpn_ms-480-960-2x_coco.py b/configs/sabl/sabl-retinanet_r101-gn_fpn_ms-480-960-2x_coco.py index 6d6e932d177..dc7209aebad 100644 --- a/configs/sabl/sabl-retinanet_r101-gn_fpn_ms-480-960-2x_coco.py +++ b/configs/sabl/sabl-retinanet_r101-gn_fpn_ms-480-960-2x_coco.py @@ -54,9 +54,7 @@ debug=False)) # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', scale=[(1333, 480), (1333, 960)], diff --git a/configs/sabl/sabl-retinanet_r101-gn_fpn_ms-640-800-2x_coco.py b/configs/sabl/sabl-retinanet_r101-gn_fpn_ms-640-800-2x_coco.py index 083c0c129c6..ac5f6d9811d 100644 --- a/configs/sabl/sabl-retinanet_r101-gn_fpn_ms-640-800-2x_coco.py +++ b/configs/sabl/sabl-retinanet_r101-gn_fpn_ms-640-800-2x_coco.py @@ -54,9 +54,7 @@ debug=False)) # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', scale=[(1333, 480), (1333, 800)], diff --git a/configs/seesaw_loss/cascade-mask-rcnn_r101_fpn_seesaw-loss_random-ms-2x_lvis-v1.py b/configs/seesaw_loss/cascade-mask-rcnn_r101_fpn_seesaw-loss_random-ms-2x_lvis-v1.py index 9bb8df4cfb3..2a1a87d4203 100644 --- a/configs/seesaw_loss/cascade-mask-rcnn_r101_fpn_seesaw-loss_random-ms-2x_lvis-v1.py +++ b/configs/seesaw_loss/cascade-mask-rcnn_r101_fpn_seesaw-loss_random-ms-2x_lvis-v1.py @@ -80,9 +80,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomChoiceResize', diff --git a/configs/seesaw_loss/cascade-mask-rcnn_r101_fpn_seesaw-loss_sample1e-3-ms-2x_lvis-v1.py b/configs/seesaw_loss/cascade-mask-rcnn_r101_fpn_seesaw-loss_sample1e-3-ms-2x_lvis-v1.py index dd02b596675..0e7b4df9136 100644 --- a/configs/seesaw_loss/cascade-mask-rcnn_r101_fpn_seesaw-loss_sample1e-3-ms-2x_lvis-v1.py +++ b/configs/seesaw_loss/cascade-mask-rcnn_r101_fpn_seesaw-loss_sample1e-3-ms-2x_lvis-v1.py @@ -80,9 +80,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomChoiceResize', diff --git a/configs/seesaw_loss/mask-rcnn_r50_fpn_seesaw-loss_random-ms-2x_lvis-v1.py b/configs/seesaw_loss/mask-rcnn_r50_fpn_seesaw-loss_random-ms-2x_lvis-v1.py index 6f103768235..25c646c9c75 100644 --- a/configs/seesaw_loss/mask-rcnn_r50_fpn_seesaw-loss_random-ms-2x_lvis-v1.py +++ b/configs/seesaw_loss/mask-rcnn_r50_fpn_seesaw-loss_random-ms-2x_lvis-v1.py @@ -23,9 +23,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomChoiceResize', diff --git a/configs/seesaw_loss/mask-rcnn_r50_fpn_seesaw-loss_sample1e-3-ms-2x_lvis-v1.py b/configs/seesaw_loss/mask-rcnn_r50_fpn_seesaw-loss_sample1e-3-ms-2x_lvis-v1.py index 3106cc55bc7..d60320e0b78 100644 --- a/configs/seesaw_loss/mask-rcnn_r50_fpn_seesaw-loss_sample1e-3-ms-2x_lvis-v1.py +++ b/configs/seesaw_loss/mask-rcnn_r50_fpn_seesaw-loss_sample1e-3-ms-2x_lvis-v1.py @@ -23,9 +23,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomChoiceResize', diff --git a/configs/selfsup_pretrain/mask-rcnn_r50-mocov2-pre_fpn_ms-2x_coco.py b/configs/selfsup_pretrain/mask-rcnn_r50-mocov2-pre_fpn_ms-2x_coco.py index c73bf9e1a17..ddaebf5558a 100644 --- a/configs/selfsup_pretrain/mask-rcnn_r50-mocov2-pre_fpn_ms-2x_coco.py +++ b/configs/selfsup_pretrain/mask-rcnn_r50-mocov2-pre_fpn_ms-2x_coco.py @@ -13,9 +13,7 @@ type='Pretrained', checkpoint='./mocov2_r50_800ep_pretrain.pth'))) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomResize', scale=[(1333, 640), (1333, 800)], diff --git a/configs/selfsup_pretrain/mask-rcnn_r50-swav-pre_fpn_ms-2x_coco.py b/configs/selfsup_pretrain/mask-rcnn_r50-swav-pre_fpn_ms-2x_coco.py index 8182cab1936..c393e0b3604 100644 --- a/configs/selfsup_pretrain/mask-rcnn_r50-swav-pre_fpn_ms-2x_coco.py +++ b/configs/selfsup_pretrain/mask-rcnn_r50-swav-pre_fpn_ms-2x_coco.py @@ -13,9 +13,7 @@ type='Pretrained', checkpoint='./swav_800ep_pretrain.pth.tar'))) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomResize', scale=[(1333, 640), (1333, 800)], diff --git a/configs/solo/decoupled-solo-light_r50_fpn_3x_coco.py b/configs/solo/decoupled-solo-light_r50_fpn_3x_coco.py index 47b0cc1f09c..fc35df3c3cb 100644 --- a/configs/solo/decoupled-solo-light_r50_fpn_3x_coco.py +++ b/configs/solo/decoupled-solo-light_r50_fpn_3x_coco.py @@ -25,9 +25,7 @@ norm_cfg=dict(type='GN', num_groups=32, requires_grad=True))) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomChoiceResize', @@ -38,9 +36,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(852, 512), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( diff --git a/configs/solo/solo_r50_fpn_3x_coco.py b/configs/solo/solo_r50_fpn_3x_coco.py index c30d41f6d92..98a9505538c 100644 --- a/configs/solo/solo_r50_fpn_3x_coco.py +++ b/configs/solo/solo_r50_fpn_3x_coco.py @@ -1,9 +1,7 @@ _base_ = './solo_r50_fpn_1x_coco.py' train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomChoiceResize', diff --git a/configs/solov2/solov2-light_r50_fpn_ms-3x_coco.py b/configs/solov2/solov2-light_r50_fpn_ms-3x_coco.py index eb1e854d5ae..cf0a7f779c0 100644 --- a/configs/solov2/solov2-light_r50_fpn_ms-3x_coco.py +++ b/configs/solov2/solov2-light_r50_fpn_ms-3x_coco.py @@ -10,9 +10,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomChoiceResize', @@ -23,9 +21,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(448, 768), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( diff --git a/configs/solov2/solov2_r50_fpn_ms-3x_coco.py b/configs/solov2/solov2_r50_fpn_ms-3x_coco.py index b51cff8e594..ec20b7dd6b9 100644 --- a/configs/solov2/solov2_r50_fpn_ms-3x_coco.py +++ b/configs/solov2/solov2_r50_fpn_ms-3x_coco.py @@ -1,9 +1,7 @@ _base_ = './solov2_r50_fpn_1x_coco.py' train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomChoiceResize', diff --git a/configs/sparse_rcnn/sparse-rcnn_r50_fpn_300-proposals_crop-ms-480-800-3x_coco.py b/configs/sparse_rcnn/sparse-rcnn_r50_fpn_300-proposals_crop-ms-480-800-3x_coco.py index 98a7398f969..93edc0314b5 100644 --- a/configs/sparse_rcnn/sparse-rcnn_r50_fpn_300-proposals_crop-ms-480-800-3x_coco.py +++ b/configs/sparse_rcnn/sparse-rcnn_r50_fpn_300-proposals_crop-ms-480-800-3x_coco.py @@ -7,9 +7,7 @@ # augmentation strategy originates from DETR. train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict(type='RandomFlip', prob=0.5), dict( diff --git a/configs/sparse_rcnn/sparse-rcnn_r50_fpn_ms-480-800-3x_coco.py b/configs/sparse_rcnn/sparse-rcnn_r50_fpn_ms-480-800-3x_coco.py index f7c7a4a4de5..156028d7cdd 100644 --- a/configs/sparse_rcnn/sparse-rcnn_r50_fpn_ms-480-800-3x_coco.py +++ b/configs/sparse_rcnn/sparse-rcnn_r50_fpn_ms-480-800-3x_coco.py @@ -1,9 +1,7 @@ _base_ = './sparse-rcnn_r50_fpn_1x_coco.py' train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomChoiceResize', diff --git a/configs/ssd/ssd300_coco.py b/configs/ssd/ssd300_coco.py index 4ce1a3c314b..796d25c9053 100644 --- a/configs/ssd/ssd300_coco.py +++ b/configs/ssd/ssd300_coco.py @@ -6,7 +6,7 @@ # dataset settings input_size = 300 train_pipeline = [ - dict(type='LoadImageFromFile'), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='Expand', @@ -28,7 +28,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile'), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(input_size, input_size), keep_ratio=False), dict(type='LoadAnnotations', with_bbox=True), dict( @@ -50,7 +50,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline))) + pipeline=train_pipeline, + backend_args={{_base_.backend_args}}))) val_dataloader = dict(batch_size=8, dataset=dict(pipeline=test_pipeline)) test_dataloader = val_dataloader diff --git a/configs/ssd/ssd512_coco.py b/configs/ssd/ssd512_coco.py index 16140be2d24..7acd6144202 100644 --- a/configs/ssd/ssd512_coco.py +++ b/configs/ssd/ssd512_coco.py @@ -20,7 +20,7 @@ # dataset settings train_pipeline = [ - dict(type='LoadImageFromFile'), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='Expand', @@ -42,7 +42,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile'), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(input_size, input_size), keep_ratio=False), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/configs/strong_baselines/mask-rcnn_r50-caffe_fpn_rpn-2conv_4conv1fc_syncbn-all_lsj-100e_coco.py b/configs/strong_baselines/mask-rcnn_r50-caffe_fpn_rpn-2conv_4conv1fc_syncbn-all_lsj-100e_coco.py index 3f809cc5ad8..70e92a82e0c 100644 --- a/configs/strong_baselines/mask-rcnn_r50-caffe_fpn_rpn-2conv_4conv1fc_syncbn-all_lsj-100e_coco.py +++ b/configs/strong_baselines/mask-rcnn_r50-caffe_fpn_rpn-2conv_4conv1fc_syncbn-all_lsj-100e_coco.py @@ -37,9 +37,7 @@ mask_head=dict(norm_cfg=head_norm_cfg))) train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomResize', @@ -57,9 +55,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( diff --git a/configs/swin/mask-rcnn_swin-t-p4-w7_fpn_ms-crop-3x_coco.py b/configs/swin/mask-rcnn_swin-t-p4-w7_fpn_ms-crop-3x_coco.py index 37448b0b77d..7024b73249c 100644 --- a/configs/swin/mask-rcnn_swin-t-p4-w7_fpn_ms-crop-3x_coco.py +++ b/configs/swin/mask-rcnn_swin-t-p4-w7_fpn_ms-crop-3x_coco.py @@ -30,9 +30,7 @@ # augmentation strategy originates from DETR / Sparse RCNN train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict(type='RandomFlip', prob=0.5), dict( diff --git a/configs/tood/tood_r50_fpn_ms-2x_coco.py b/configs/tood/tood_r50_fpn_ms-2x_coco.py index 93d1d47521d..ffb296dccee 100644 --- a/configs/tood/tood_r50_fpn_ms-2x_coco.py +++ b/configs/tood/tood_r50_fpn_ms-2x_coco.py @@ -19,9 +19,7 @@ # multi-scale training train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', scale=[(1333, 480), (1333, 800)], diff --git a/configs/tridentnet/tridentnet_r50-caffe_ms-1x_coco.py b/configs/tridentnet/tridentnet_r50-caffe_ms-1x_coco.py index a3a88908b9e..806d20b90c9 100644 --- a/configs/tridentnet/tridentnet_r50-caffe_ms-1x_coco.py +++ b/configs/tridentnet/tridentnet_r50-caffe_ms-1x_coco.py @@ -1,9 +1,7 @@ _base_ = 'tridentnet_r50-caffe_1x_coco.py' train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomChoiceResize', diff --git a/configs/vfnet/vfnet_r50_fpn_1x_coco.py b/configs/vfnet/vfnet_r50_fpn_1x_coco.py index d45e5824086..99bc3b5f4c7 100644 --- a/configs/vfnet/vfnet_r50_fpn_1x_coco.py +++ b/configs/vfnet/vfnet_r50_fpn_1x_coco.py @@ -64,18 +64,14 @@ # data setting train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='RandomFlip', prob=0.5), dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/configs/vfnet/vfnet_r50_fpn_ms-2x_coco.py b/configs/vfnet/vfnet_r50_fpn_ms-2x_coco.py index 95ce40fa1ac..0f8eed298e8 100644 --- a/configs/vfnet/vfnet_r50_fpn_ms-2x_coco.py +++ b/configs/vfnet/vfnet_r50_fpn_ms-2x_coco.py @@ -1,8 +1,6 @@ _base_ = './vfnet_r50_fpn_1x_coco.py' train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', scale=[(1333, 480), (1333, 960)], @@ -11,9 +9,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/configs/yolact/yolact_r50_1xb8-55e_coco.py b/configs/yolact/yolact_r50_1xb8-55e_coco.py index 4866f04ddf4..b7dabf1548a 100644 --- a/configs/yolact/yolact_r50_1xb8-55e_coco.py +++ b/configs/yolact/yolact_r50_1xb8-55e_coco.py @@ -95,9 +95,7 @@ mask_thr_binary=0.5)) # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict(type='FilterAnnotations', min_gt_bbox_wh=(4.0, 4.0)), dict( @@ -120,7 +118,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile'), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(input_size, input_size), keep_ratio=False), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( diff --git a/configs/yolo/yolov3_d53_8xb8-320-273e_coco.py b/configs/yolo/yolov3_d53_8xb8-320-273e_coco.py index f1ae4248a8d..a3d08dd7706 100644 --- a/configs/yolo/yolov3_d53_8xb8-320-273e_coco.py +++ b/configs/yolo/yolov3_d53_8xb8-320-273e_coco.py @@ -1,17 +1,8 @@ _base_ = './yolov3_d53_8xb8-ms-608-273e_coco.py' -# dataset settings -# file_client_args = dict( -# backend='petrel', -# path_mapping=dict({ -# './data/': 's3://openmmlab/datasets/detection/', -# 'data/': 's3://openmmlab/datasets/detection/' -# })) - -file_client_args = dict(backend='disk') input_size = (320, 320) train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), # `mean` and `to_rgb` should be the same with the `preprocess_cfg` dict(type='Expand', mean=[0, 0, 0], to_rgb=True, ratio_range=(1, 2)), @@ -25,7 +16,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=input_size, keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/configs/yolo/yolov3_d53_8xb8-ms-416-273e_coco.py b/configs/yolo/yolov3_d53_8xb8-ms-416-273e_coco.py index be098c8352d..ca0127e83ed 100644 --- a/configs/yolo/yolov3_d53_8xb8-ms-416-273e_coco.py +++ b/configs/yolo/yolov3_d53_8xb8-ms-416-273e_coco.py @@ -1,15 +1,7 @@ _base_ = './yolov3_d53_8xb8-ms-608-273e_coco.py' -# dataset settings -# file_client_args = dict( -# backend='petrel', -# path_mapping=dict({ -# './data/': 's3://openmmlab/datasets/detection/', -# 'data/': 's3://openmmlab/datasets/detection/' -# })) -file_client_args = dict(backend='disk') train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), # `mean` and `to_rgb` should be the same with the `preprocess_cfg` dict(type='Expand', mean=[0, 0, 0], to_rgb=True, ratio_range=(1, 2)), @@ -23,7 +15,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(416, 416), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/configs/yolo/yolov3_d53_8xb8-ms-608-273e_coco.py b/configs/yolo/yolov3_d53_8xb8-ms-608-273e_coco.py index 287e09485cb..d4a36dfdaaf 100644 --- a/configs/yolo/yolov3_d53_8xb8-ms-608-273e_coco.py +++ b/configs/yolo/yolov3_d53_8xb8-ms-608-273e_coco.py @@ -66,16 +66,23 @@ dataset_type = 'CocoDataset' data_root = 'data/coco/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict( type='Expand', @@ -92,7 +99,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(608, 608), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( @@ -113,7 +120,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( batch_size=1, num_workers=2, @@ -126,13 +134,15 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', - metric='bbox') + metric='bbox', + backend_args=backend_args) test_evaluator = val_evaluator train_cfg = dict(max_epochs=273, val_interval=7) diff --git a/configs/yolo/yolov3_mobilenetv2_8xb24-320-300e_coco.py b/configs/yolo/yolov3_mobilenetv2_8xb24-320-300e_coco.py index a8eb5dd1647..07b39373432 100644 --- a/configs/yolo/yolov3_mobilenetv2_8xb24-320-300e_coco.py +++ b/configs/yolo/yolov3_mobilenetv2_8xb24-320-300e_coco.py @@ -9,17 +9,9 @@ [(10, 15), (24, 36), (72, 42)]]))) # yapf:enable -# file_client_args = dict( -# backend='petrel', -# path_mapping=dict({ -# './data/': 's3://openmmlab/datasets/detection/', -# 'data/': 's3://openmmlab/datasets/detection/' -# })) -file_client_args = dict(backend='disk') - input_size = (320, 320) train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), # `mean` and `to_rgb` should be the same with the `preprocess_cfg` dict( @@ -37,7 +29,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=input_size, keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/configs/yolo/yolov3_mobilenetv2_8xb24-ms-416-300e_coco.py b/configs/yolo/yolov3_mobilenetv2_8xb24-ms-416-300e_coco.py index 67116f4000f..9a161b66fe9 100644 --- a/configs/yolo/yolov3_mobilenetv2_8xb24-ms-416-300e_coco.py +++ b/configs/yolo/yolov3_mobilenetv2_8xb24-ms-416-300e_coco.py @@ -67,16 +67,23 @@ dataset_type = 'CocoDataset' data_root = 'data/coco/' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict( type='Expand', @@ -93,7 +100,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=(416, 416), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( @@ -117,7 +124,8 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), filter_cfg=dict(filter_empty_gt=True, min_size=32), - pipeline=train_pipeline))) + pipeline=train_pipeline, + backend_args=backend_args))) val_dataloader = dict( batch_size=24, num_workers=4, @@ -130,13 +138,15 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', - metric='bbox') + metric='bbox', + backend_args=backend_args) test_evaluator = val_evaluator train_cfg = dict(max_epochs=30) diff --git a/configs/yolof/yolof_r50-c5_8xb8-1x_coco.py b/configs/yolof/yolof_r50-c5_8xb8-1x_coco.py index b2637799712..5ea228e3e32 100644 --- a/configs/yolof/yolof_r50-c5_8xb8-1x_coco.py +++ b/configs/yolof/yolof_r50-c5_8xb8-1x_coco.py @@ -89,9 +89,7 @@ ] train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='RandomFlip', prob=0.5), @@ -99,9 +97,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/configs/yolox/yolox_s_8xb8-300e_coco.py b/configs/yolox/yolox_s_8xb8-300e_coco.py index 0e6bb2d1dc8..3e324eb5b99 100644 --- a/configs/yolox/yolox_s_8xb8-300e_coco.py +++ b/configs/yolox/yolox_s_8xb8-300e_coco.py @@ -73,13 +73,20 @@ data_root = 'data/coco/' dataset_type = 'CocoDataset' -# file_client_args = dict( +# Example to use different file client +# Method 1: simply set the data root and let the file I/O module +# automatically infer from prefix (not support LMDB and Memcache yet) + +# data_root = 's3://openmmlab/datasets/detection/coco/' + +# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6 +# backend_args = dict( # backend='petrel', # path_mapping=dict({ # './data/': 's3://openmmlab/datasets/detection/', # 'data/': 's3://openmmlab/datasets/detection/' # })) -file_client_args = dict(backend='disk') +backend_args = None train_pipeline = [ dict(type='Mosaic', img_scale=img_scale, pad_val=114.0), @@ -120,14 +127,15 @@ ann_file='annotations/instances_train2017.json', data_prefix=dict(img='train2017/'), pipeline=[ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True) ], - filter_cfg=dict(filter_empty_gt=False, min_size=32)), + filter_cfg=dict(filter_empty_gt=False, min_size=32), + backend_args=backend_args), pipeline=train_pipeline) test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='Resize', scale=img_scale, keep_ratio=True), dict( type='Pad', @@ -158,13 +166,15 @@ ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader val_evaluator = dict( type='CocoMetric', ann_file=data_root + 'annotations/instances_val2017.json', - metric='bbox') + metric='bbox', + backend_args=backend_args) test_evaluator = val_evaluator # training settings diff --git a/configs/yolox/yolox_tiny_8xb8-300e_coco.py b/configs/yolox/yolox_tiny_8xb8-300e_coco.py index b15480bed0a..86f7e9a6191 100644 --- a/configs/yolox/yolox_tiny_8xb8-300e_coco.py +++ b/configs/yolox/yolox_tiny_8xb8-300e_coco.py @@ -15,14 +15,6 @@ img_scale = (640, 640) # width, height -# file_client_args = dict( -# backend='petrel', -# path_mapping=dict({ -# './data/': 's3://openmmlab/datasets/detection/', -# 'data/': 's3://openmmlab/datasets/detection/' -# })) -file_client_args = dict(backend='disk') - train_pipeline = [ dict(type='Mosaic', img_scale=img_scale, pad_val=114.0), dict( @@ -44,7 +36,7 @@ ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(416, 416), keep_ratio=True), dict( type='Pad', diff --git a/configs/yolox/yolox_tta.py b/configs/yolox/yolox_tta.py index 8e86f26f5ac..e65244be6e1 100644 --- a/configs/yolox/yolox_tta.py +++ b/configs/yolox/yolox_tta.py @@ -4,7 +4,7 @@ img_scales = [(640, 640), (320, 320), (960, 960)] tta_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')), + dict(type='LoadImageFromFile', backend_args=None), dict( type='TestTimeAug', transforms=[ diff --git a/docs/en/advanced_guides/customize_transforms.md b/docs/en/advanced_guides/customize_transforms.md index 870861b7d74..ae4ff47ef7e 100644 --- a/docs/en/advanced_guides/customize_transforms.md +++ b/docs/en/advanced_guides/customize_transforms.md @@ -32,7 +32,7 @@ custom_imports = dict(imports=['path.to.my_pipeline'], allow_failed_imports=False) train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict(type='RandomFlip', prob=0.5), diff --git a/docs/en/advanced_guides/transforms.md b/docs/en/advanced_guides/transforms.md index 8820a3cf129..034621c9fc5 100644 --- a/docs/en/advanced_guides/transforms.md +++ b/docs/en/advanced_guides/transforms.md @@ -17,7 +17,7 @@ Here is a pipeline example for Faster R-CNN. ```python train_pipeline = [ # Training data processing pipeline - dict(type='LoadImageFromFile'), # First pipeline to load images from file path + dict(type='LoadImageFromFile', backend_args=backend_args), # First pipeline to load images from file path dict( type='LoadAnnotations', # Second pipeline to load annotations for current image with_bbox=True), # Whether to use bounding box, True for detection @@ -32,7 +32,7 @@ train_pipeline = [ # Training data processing pipeline dict(type='PackDetInputs') # Pipeline that formats the annotation data and decides which keys in the data should be packed into data_samples ] test_pipeline = [ # Testing data processing pipeline - dict(type='LoadImageFromFile', file_client_args=file_client_args), # First pipeline to load images from file path + dict(type='LoadImageFromFile', backend_args=backend_args), # First pipeline to load images from file path dict(type='Resize', scale=(1333, 800), keep_ratio=True), # Pipeline that resize the images dict( type='PackDetInputs', # Pipeline that formats the annotation data and decides which keys in the data should be packed into data_samples diff --git a/docs/en/user_guides/config.md b/docs/en/user_guides/config.md index d08b2a731eb..2ee3bc9bf68 100644 --- a/docs/en/user_guides/config.md +++ b/docs/en/user_guides/config.md @@ -176,10 +176,10 @@ model = dict( ```python dataset_type = 'CocoDataset' # Dataset type, this will be used to define the dataset data_root = 'data/coco/' # Root path of data -file_client_args = dict(backend='disk') # file client arguments +backend_args = None # Arguments to instantiate the corresponding file backend train_pipeline = [ # Training data processing pipeline - dict(type='LoadImageFromFile', file_client_args=file_client_args), # First pipeline to load images from file path + dict(type='LoadImageFromFile', backend_args=backend_args), # First pipeline to load images from file path dict( type='LoadAnnotations', # Second pipeline to load annotations for current image with_bbox=True, # Whether to use bounding box, True for detection @@ -196,7 +196,7 @@ train_pipeline = [ # Training data processing pipeline dict(type='PackDetInputs') # Pipeline that formats the annotation data and decides which keys in the data should be packed into data_samples ] test_pipeline = [ # Testing data processing pipeline - dict(type='LoadImageFromFile', file_client_args=file_client_args), # First pipeline to load images from file path + dict(type='LoadImageFromFile', backend_args=backend_args), # First pipeline to load images from file path dict(type='Resize', scale=(1333, 800), keep_ratio=True), # Pipeline that resizes the images dict( type='PackDetInputs', # Pipeline that formats the annotation data and decides which keys in the data should be packed into data_samples @@ -217,7 +217,8 @@ train_dataloader = dict( # Train dataloader config ann_file='annotations/instances_train2017.json', # Path of annotation file data_prefix=dict(img='train2017/'), # Prefix of image path filter_cfg=dict(filter_empty_gt=True, min_size=32), # Config of filtering images and annotations - pipeline=train_pipeline)) + pipeline=train_pipeline, + backend_args=backend_args)) val_dataloader = dict( # Validation dataloader config batch_size=1, # Batch size of a single GPU. If batch-size > 1, the extra padding area may influence the performance. num_workers=2, # Worker to pre-fetch data for each single GPU @@ -232,7 +233,8 @@ val_dataloader = dict( # Validation dataloader config ann_file='annotations/instances_val2017.json', data_prefix=dict(img='val2017/'), test_mode=True, # Turn on the test mode of the dataset to avoid filtering annotations or images - pipeline=test_pipeline)) + pipeline=test_pipeline, + backend_args=backend_args)) test_dataloader = val_dataloader # Testing dataloader config ``` @@ -243,7 +245,8 @@ val_evaluator = dict( # Validation evaluator config type='CocoMetric', # The coco metric used to evaluate AR, AP, and mAP for detection and instance segmentation ann_file=data_root + 'annotations/instances_val2017.json', # Annotation file path metric=['bbox', 'segm'], # Metrics to be evaluated, `bbox` for detection and `segm` for instance segmentation - format_only=False) + format_only=False, + backend_args=backend_args) test_evaluator = val_evaluator # Testing evaluator config ``` @@ -529,7 +532,7 @@ train_pipeline = [ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile'), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict( type='PackDetInputs', diff --git a/docs/en/user_guides/semi_det.md b/docs/en/user_guides/semi_det.md index 6cf5538e539..94ec3d670c8 100644 --- a/docs/en/user_guides/semi_det.md +++ b/docs/en/user_guides/semi_det.md @@ -117,7 +117,7 @@ We adopt a teacher-student joint training semi-supervised object detection frame # pipeline used to augment labeled data, # which will be sent to student model for supervised training. sup_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadAnnotations', with_bbox=True), dict(type='RandomResize', scale=scale, keep_ratio=True), dict(type='RandomFlip', prob=0.5), @@ -164,7 +164,7 @@ strong_pipeline = [ # pipeline used to augment unlabeled data into different views unsup_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args=backend_args), dict(type='LoadEmptyAnnotations'), dict( type='MultiBranch', diff --git a/docs/en/user_guides/test.md b/docs/en/user_guides/test.md index 333ccfbed1b..4a0d77b0f5f 100644 --- a/docs/en/user_guides/test.md +++ b/docs/en/user_guides/test.md @@ -219,7 +219,7 @@ tta_model = dict( tta_pipeline = [ dict(type='LoadImageFromFile', - file_client_args=dict(backend='disk')), + backend_args=None), dict( type='TestTimeAug', transforms=[[ @@ -274,7 +274,7 @@ tta_model = dict( img_scales = [(1333, 800), (666, 400), (2000, 1200)] tta_pipeline = [ dict(type='LoadImageFromFile', - file_client_args=dict(backend='disk')), + backend_args=None), dict( type='TestTimeAug', transforms=[[ diff --git a/docs/zh_cn/user_guides/config.md b/docs/zh_cn/user_guides/config.md index a3dc0f26635..319c78ac312 100644 --- a/docs/zh_cn/user_guides/config.md +++ b/docs/zh_cn/user_guides/config.md @@ -176,10 +176,9 @@ model = dict( ```python dataset_type = 'CocoDataset' # 数据集类型,这将被用来定义数据集。 data_root = 'data/coco/' # 数据的根路径。 -file_client_args = dict(backend='disk') # 文件读取后端的配置,默认从硬盘读取 train_pipeline = [ # 训练数据处理流程 - dict(type='LoadImageFromFile', file_client_args=file_client_args), # 第 1 个流程,从文件路径里加载图像。 + dict(type='LoadImageFromFile'), # 第 1 个流程,从文件路径里加载图像。 dict( type='LoadAnnotations', # 第 2 个流程,对于当前图像,加载它的注释信息。 with_bbox=True, # 是否使用标注框(bounding box), 目标检测需要设置为 True。 @@ -196,7 +195,7 @@ train_pipeline = [ # 训练数据处理流程 dict(type='PackDetInputs') # 将数据转换为检测器输入格式的流程 ] test_pipeline = [ # 测试数据处理流程 - dict(type='LoadImageFromFile', file_client_args=file_client_args), # 第 1 个流程,从文件路径里加载图像。 + dict(type='LoadImageFromFile'), # 第 1 个流程,从文件路径里加载图像。 dict(type='Resize', scale=(1333, 800), keep_ratio=True), # 变化图像大小的流程。 dict( type='PackDetInputs', # 将数据转换为检测器输入格式的流程 @@ -519,7 +518,7 @@ train_pipeline = [ dict(type='PackDetInputs') ] test_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile'), dict(type='Resize', scale=(1333, 800), keep_ratio=True), dict( type='PackDetInputs', diff --git a/docs/zh_cn/user_guides/semi_det.md b/docs/zh_cn/user_guides/semi_det.md index 4665e40260c..a223523705c 100644 --- a/docs/zh_cn/user_guides/semi_det.md +++ b/docs/zh_cn/user_guides/semi_det.md @@ -4,12 +4,13 @@ 按照以下流程进行半监督目标检测: -- [准备和拆分数据集](#准备和拆分数据集) -- [配置多分支数据流程](#配置多分支数据流程) -- [配置加载半监督数据](#配置半监督数据加载) -- [配置半监督模型](#配置半监督模型) -- [配置 MeanTeacherHook](#配置MeanTeacherHook) -- [配置 TeacherStudentValLoop](#配置TeacherStudentValLoop) +- [半监督目标检测](#半监督目标检测) + - [准备和拆分数据集](#准备和拆分数据集) + - [配置多分支数据流程](#配置多分支数据流程) + - [配置半监督数据加载](#配置半监督数据加载) + - [配置半监督模型](#配置半监督模型) + - [配置MeanTeacherHook](#配置meanteacherhook) + - [配置TeacherStudentValLoop](#配置teacherstudentvalloop) ## 准备和拆分数据集 @@ -116,7 +117,7 @@ mmdetection # pipeline used to augment labeled data, # which will be sent to student model for supervised training. sup_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile',backend_args = backend_args), dict(type='LoadAnnotations', with_bbox=True), dict(type='RandomResize', scale=scale, keep_ratio=True), dict(type='RandomFlip', prob=0.5), @@ -163,7 +164,7 @@ strong_pipeline = [ # pipeline used to augment unlabeled data into different views unsup_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=file_client_args), + dict(type='LoadImageFromFile', backend_args = backend_args), dict(type='LoadEmptyAnnotations'), dict( type='MultiBranch', diff --git a/mmdet/datasets/base_det_dataset.py b/mmdet/datasets/base_det_dataset.py index 55598ef267a..379cc4e9f63 100644 --- a/mmdet/datasets/base_det_dataset.py +++ b/mmdet/datasets/base_det_dataset.py @@ -3,7 +3,7 @@ from typing import List, Optional from mmengine.dataset import BaseDataset -from mmengine.fileio import FileClient, load +from mmengine.fileio import load from mmengine.utils import is_abs from ..registry import DATASETS @@ -15,21 +15,28 @@ class BaseDetDataset(BaseDataset): Args: proposal_file (str, optional): Proposals file path. Defaults to None. - file_client_args (dict): Arguments to instantiate a FileClient. - See :class:`mmengine.fileio.FileClient` for details. - Defaults to ``dict(backend='disk')``. + file_client_args (dict): Arguments to instantiate the + corresponding backend in mmdet <= 3.0.0rc6. Defaults to None. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend. Defaults to None. """ def __init__(self, *args, seg_map_suffix: str = '.png', proposal_file: Optional[str] = None, - file_client_args: dict = dict(backend='disk'), + file_client_args: dict = None, + backend_args: dict = None, **kwargs) -> None: self.seg_map_suffix = seg_map_suffix self.proposal_file = proposal_file - self.file_client_args = file_client_args - self.file_client = FileClient(**file_client_args) + self.backend_args = backend_args + if file_client_args is not None: + raise RuntimeError( + 'The `file_client_args` is deprecated, ' + 'please use `backend_args` instead, please refer to' + 'https://github.com/open-mmlab/mmdetection/blob/dev-3.x/configs/_base_/datasets/coco_detection.py' # noqa: E501 + ) super().__init__(*args, **kwargs) def full_init(self) -> None: @@ -88,7 +95,7 @@ def load_proposals(self) -> None: if not is_abs(self.proposal_file): self.proposal_file = osp.join(self.data_root, self.proposal_file) proposals_list = load( - self.proposal_file, file_client_args=self.file_client_args) + self.proposal_file, backend_args=self.backend_args) assert len(self.data_list) == len(proposals_list) for data_info in self.data_list: img_path = data_info['img_path'] diff --git a/mmdet/datasets/coco.py b/mmdet/datasets/coco.py index 873f635d0b0..f95dd8cb414 100644 --- a/mmdet/datasets/coco.py +++ b/mmdet/datasets/coco.py @@ -3,6 +3,8 @@ import os.path as osp from typing import List, Union +from mmengine.fileio import get_local_path + from mmdet.registry import DATASETS from .api_wrappers import COCO from .base_det_dataset import BaseDetDataset @@ -60,7 +62,8 @@ def load_data_list(self) -> List[dict]: Returns: List[dict]: A list of annotation. """ # noqa: E501 - with self.file_client.get_local_path(self.ann_file) as local_path: + with get_local_path( + self.ann_file, backend_args=self.backend_args) as local_path: self.coco = self.COCOAPI(local_path) # The order of returned `cat_ids` will not # change with the order of the `classes` diff --git a/mmdet/datasets/coco_panoptic.py b/mmdet/datasets/coco_panoptic.py index 917456ac137..33d4189e6c4 100644 --- a/mmdet/datasets/coco_panoptic.py +++ b/mmdet/datasets/coco_panoptic.py @@ -168,7 +168,9 @@ def __init__(self, pipeline: List[Union[dict, Callable]] = [], test_mode: bool = False, lazy_init: bool = False, - max_refetch: int = 1000) -> None: + max_refetch: int = 1000, + backend_args: dict = None, + **kwargs) -> None: super().__init__( ann_file=ann_file, metainfo=metainfo, @@ -180,7 +182,9 @@ def __init__(self, pipeline=pipeline, test_mode=test_mode, lazy_init=lazy_init, - max_refetch=max_refetch) + max_refetch=max_refetch, + backend_args=backend_args, + **kwargs) def parse_data_info(self, raw_data_info: dict) -> dict: """Parse raw annotation to target format. diff --git a/mmdet/datasets/crowdhuman.py b/mmdet/datasets/crowdhuman.py index fd67d2a5cc2..650176ee545 100644 --- a/mmdet/datasets/crowdhuman.py +++ b/mmdet/datasets/crowdhuman.py @@ -7,7 +7,7 @@ import mmcv from mmengine.dist import get_rank -from mmengine.fileio import dump, load +from mmengine.fileio import dump, get, get_text, load from mmengine.logging import print_log from mmengine.utils import ProgressBar @@ -66,8 +66,8 @@ def load_data_list(self) -> List[dict]: Returns: List[dict]: A list of annotation. """ # noqa: E501 - anno_strs = self.file_client.get_text( - self.ann_file).strip().split('\n') + anno_strs = get_text( + self.ann_file, backend_args=self.backend_args).strip().split('\n') print_log('loading CrowdHuman annotation...', level=logging.INFO) data_list = [] prog_bar = ProgressBar(len(anno_strs)) @@ -110,7 +110,7 @@ def parse_data_info(self, raw_data_info: dict) -> Union[dict, List[dict]]: data_info['img_id'] = raw_data_info['ID'] if not self.extra_ann_exist: - img_bytes = self.file_client.get(img_path) + img_bytes = get(img_path, backend_args=self.backend_args) img = mmcv.imfrombytes(img_bytes, backend='cv2') data_info['height'], data_info['width'] = img.shape[:2] self.extra_anns[raw_data_info['ID']] = img.shape[:2] diff --git a/mmdet/datasets/lvis.py b/mmdet/datasets/lvis.py index f24fec4971b..b9629f5d463 100644 --- a/mmdet/datasets/lvis.py +++ b/mmdet/datasets/lvis.py @@ -3,6 +3,8 @@ import warnings from typing import List +from mmengine.fileio import get_local_path + from mmdet.registry import DATASETS from .coco import CocoDataset @@ -285,7 +287,8 @@ def load_data_list(self) -> List[dict]: raise ImportError( 'Package lvis is not installed. Please run "pip install git+https://github.com/lvis-dataset/lvis-api.git".' # noqa: E501 ) - with self.file_client.get_local_path(self.ann_file) as local_path: + with get_local_path( + self.ann_file, backend_args=self.backend_args) as local_path: self.lvis = LVIS(local_path) self.cat_ids = self.lvis.get_cat_ids() self.cat2label = {cat_id: i for i, cat_id in enumerate(self.cat_ids)} @@ -597,7 +600,9 @@ def load_data_list(self) -> List[dict]: raise ImportError( 'Package lvis is not installed. Please run "pip install git+https://github.com/lvis-dataset/lvis-api.git".' # noqa: E501 ) - self.lvis = LVIS(self.ann_file) + with get_local_path( + self.ann_file, backend_args=self.backend_args) as local_path: + self.lvis = LVIS(local_path) self.cat_ids = self.lvis.get_cat_ids() self.cat2label = {cat_id: i for i, cat_id in enumerate(self.cat_ids)} self.cat_img_map = copy.deepcopy(self.lvis.cat_img_map) diff --git a/mmdet/datasets/objects365.py b/mmdet/datasets/objects365.py index 92e3fe14325..e99869bfa30 100644 --- a/mmdet/datasets/objects365.py +++ b/mmdet/datasets/objects365.py @@ -3,6 +3,8 @@ import os.path as osp from typing import List +from mmengine.fileio import get_local_path + from mmdet.registry import DATASETS from .api_wrappers import COCO from .coco import CocoDataset @@ -102,7 +104,8 @@ def load_data_list(self) -> List[dict]: Returns: List[dict]: A list of annotation. """ # noqa: E501 - with self.file_client.get_local_path(self.ann_file) as local_path: + with get_local_path( + self.ann_file, backend_args=self.backend_args) as local_path: self.coco = self.COCOAPI(local_path) # 'categories' list in objects365_train.json and objects365_val.json @@ -234,7 +237,8 @@ def load_data_list(self) -> List[dict]: Returns: List[dict]: A list of annotation. """ # noqa: E501 - with self.file_client.get_local_path(self.ann_file) as local_path: + with get_local_path( + self.ann_file, backend_args=self.backend_args) as local_path: self.coco = self.COCOAPI(local_path) # The order of returned `cat_ids` will not # change with the order of the `classes` diff --git a/mmdet/datasets/openimages.py b/mmdet/datasets/openimages.py index a6994071de1..a3c6c8ec44f 100644 --- a/mmdet/datasets/openimages.py +++ b/mmdet/datasets/openimages.py @@ -5,7 +5,7 @@ from typing import Dict, List, Optional import numpy as np -from mmengine.fileio import load +from mmengine.fileio import get_local_path, load from mmengine.utils import is_abs from mmdet.registry import DATASETS @@ -25,9 +25,8 @@ class OpenImagesDataset(BaseDetDataset): hierarchy_file (str): The file path of the class hierarchy. image_level_ann_file (str): Human-verified image level annotation, which is used in evaluation. - file_client_args (dict): Arguments to instantiate a FileClient. - See :class:`mmengine.fileio.FileClient` for details. - Defaults to ``dict(backend='disk')``. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend. Defaults to None. """ METAINFO: dict = dict(dataset_type='oid_v6') @@ -66,7 +65,8 @@ def load_data_list(self) -> List[dict]: self._metainfo['RELATION_MATRIX'] = relation_matrix data_list = [] - with self.file_client.get_local_path(self.ann_file) as local_path: + with get_local_path( + self.ann_file, backend_args=self.backend_args) as local_path: with open(local_path, 'r') as f: reader = csv.reader(f) last_img_id = None @@ -123,9 +123,7 @@ def load_data_list(self) -> List[dict]: # add image metas to data list img_metas = load( - self.meta_file, - file_format='pkl', - file_client_args=self.file_client_args) + self.meta_file, file_format='pkl', backend_args=self.backend_args) assert len(img_metas) == len(data_list) for i, meta in enumerate(img_metas): img_id = data_list[i]['img_id'] @@ -167,7 +165,8 @@ def _parse_label_file(self, label_file: str) -> tuple: index_list = [] classes_names = [] - with self.file_client.get_local_path(label_file) as local_path: + with get_local_path( + label_file, backend_args=self.backend_args) as local_path: with open(local_path, 'r') as f: reader = csv.reader(f) for line in reader: @@ -201,7 +200,9 @@ def _parse_img_level_ann(self, """ item_lists = defaultdict(list) - with self.file_client.get_local_path(img_level_ann_file) as local_path: + with get_local_path( + img_level_ann_file, + backend_args=self.backend_args) as local_path: with open(local_path, 'r') as f: reader = csv.reader(f) for i, line in enumerate(reader): @@ -230,9 +231,7 @@ def _get_relation_matrix(self, hierarchy_file: str) -> np.ndarray: """ # noqa hierarchy = load( - hierarchy_file, - file_format='json', - file_client_args=self.file_client_args) + hierarchy_file, file_format='json', backend_args=self.backend_args) class_num = len(self._metainfo['classes']) relation_matrix = np.eye(class_num, class_num) relation_matrix = self._convert_hierarchy_tree(hierarchy, @@ -336,7 +335,8 @@ def load_data_list(self) -> List[dict]: self._metainfo['RELATION_MATRIX'] = relation_matrix data_list = [] - with self.file_client.get_local_path(self.ann_file) as local_path: + with get_local_path( + self.ann_file, backend_args=self.backend_args) as local_path: with open(local_path, 'r') as f: lines = f.readlines() i = 0 @@ -368,9 +368,7 @@ def load_data_list(self) -> List[dict]: # add image metas to data list img_metas = load( - self.meta_file, - file_format='pkl', - file_client_args=self.file_client_args) + self.meta_file, file_format='pkl', backend_args=self.backend_args) assert len(img_metas) == len(data_list) for i, meta in enumerate(img_metas): img_id = osp.split(data_list[i]['img_path'])[-1][:-4] @@ -413,7 +411,8 @@ def _parse_label_file(self, label_file: str) -> tuple: label_list = [] id_list = [] index_mapping = {} - with self.file_client.get_local_path(label_file) as local_path: + with get_local_path( + label_file, backend_args=self.backend_args) as local_path: with open(local_path, 'r') as f: reader = csv.reader(f) for line in reader: @@ -445,8 +444,9 @@ def _parse_img_level_ann(self, image_level_ann_file): """ item_lists = defaultdict(list) - with self.file_client.get_local_path( - image_level_ann_file) as local_path: + with get_local_path( + image_level_ann_file, + backend_args=self.backend_args) as local_path: with open(local_path, 'r') as f: reader = csv.reader(f) i = -1 @@ -478,6 +478,7 @@ def _get_relation_matrix(self, hierarchy_file: str) -> np.ndarray: relationship between the parent class and the child class, of shape (class_num, class_num). """ - with self.file_client.get_local_path(hierarchy_file) as local_path: + with get_local_path( + hierarchy_file, backend_args=self.backend_args) as local_path: class_label_tree = np.load(local_path, allow_pickle=True) return class_label_tree[1:, 1:] diff --git a/mmdet/datasets/transforms/loading.py b/mmdet/datasets/transforms/loading.py index f3092d40354..69e9a0ac621 100644 --- a/mmdet/datasets/transforms/loading.py +++ b/mmdet/datasets/transforms/loading.py @@ -8,7 +8,7 @@ from mmcv.transforms import BaseTransform from mmcv.transforms import LoadAnnotations as MMCV_LoadAnnotations from mmcv.transforms import LoadImageFromFile -from mmengine.fileio import FileClient +from mmengine.fileio import get from mmengine.structures import BaseDataElement from mmdet.registry import TRANSFORMS @@ -88,9 +88,10 @@ class LoadMultiChannelImageFromFiles(BaseTransform): argument for :func:``mmcv.imfrombytes``. See :func:``mmcv.imfrombytes`` for details. Defaults to 'cv2'. - file_client_args (dict): Arguments to instantiate a FileClient. - See :class:`mmengine.fileio.FileClient` for details. - Defaults to ``dict(backend='disk')``. + file_client_args (dict): Arguments to instantiate the + corresponding backend in mmdet <= 3.0.0rc6. Defaults to None. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend in mmdet >= 3.0.0rc7. Defaults to None. """ def __init__( @@ -98,13 +99,19 @@ def __init__( to_float32: bool = False, color_type: str = 'unchanged', imdecode_backend: str = 'cv2', - file_client_args: dict = dict(backend='disk') + file_client_args: dict = None, + backend_args: dict = None, ) -> None: self.to_float32 = to_float32 self.color_type = color_type self.imdecode_backend = imdecode_backend - self.file_client_args = file_client_args.copy() - self.file_client = FileClient(**self.file_client_args) + self.backend_args = backend_args + if file_client_args is not None: + raise RuntimeError( + 'The `file_client_args` is deprecated, ' + 'please use `backend_args` instead, please refer to' + 'https://github.com/open-mmlab/mmdetection/blob/dev-3.x/configs/_base_/datasets/coco_detection.py' # noqa: E501 + ) def transform(self, results: dict) -> dict: """Transform functions to load multiple images and get images meta @@ -120,7 +127,7 @@ def transform(self, results: dict) -> dict: assert isinstance(results['img_path'], list) img = [] for name in results['img_path']: - img_bytes = self.file_client.get(name) + img_bytes = get(name, backend_args=self.backend_args) img.append( mmcv.imfrombytes( img_bytes, @@ -140,7 +147,7 @@ def __repr__(self): f'to_float32={self.to_float32}, ' f"color_type='{self.color_type}', " f"imdecode_backend='{self.imdecode_backend}', " - f'file_client_args={self.file_client_args})') + f'backend_args={self.backend_args})') return repr_str @@ -236,9 +243,8 @@ class LoadAnnotations(MMCV_LoadAnnotations): argument for :func:``mmcv.imfrombytes``. See :fun:``mmcv.imfrombytes`` for details. Defaults to 'cv2'. - file_client_args (dict): Arguments to instantiate a FileClient. - See :class:``mmengine.fileio.FileClient`` for details. - Defaults to ``dict(backend='disk')``. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend. Defaults to None. """ def __init__(self, @@ -404,7 +410,7 @@ def __repr__(self) -> str: repr_str += f'with_seg={self.with_seg}, ' repr_str += f'poly2mask={self.poly2mask}, ' repr_str += f"imdecode_backend='{self.imdecode_backend}', " - repr_str += f'file_client_args={self.file_client_args})' + repr_str += f'backend_args={self.backend_args})' return repr_str @@ -501,21 +507,18 @@ class LoadPanopticAnnotations(LoadAnnotations): argument for :func:``mmcv.imfrombytes``. See :fun:``mmcv.imfrombytes`` for details. Defaults to 'cv2'. - file_client_args (dict): Arguments to instantiate a FileClient. - See :class:``mmengine.fileio.FileClient`` for details. - Defaults to ``dict(backend='disk')``. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend in mmdet >= 3.0.0rc7. Defaults to None. """ - def __init__( - self, - with_bbox: bool = True, - with_label: bool = True, - with_mask: bool = True, - with_seg: bool = True, - box_type: str = 'hbox', - imdecode_backend: str = 'cv2', - file_client_args: dict = dict(backend='disk') - ) -> None: + def __init__(self, + with_bbox: bool = True, + with_label: bool = True, + with_mask: bool = True, + with_seg: bool = True, + box_type: str = 'hbox', + imdecode_backend: str = 'cv2', + backend_args: dict = None) -> None: try: from panopticapi import utils except ImportError: @@ -525,7 +528,6 @@ def __init__( 'panopticapi.git.') self.rgb2id = utils.rgb2id - self.file_client = FileClient(**file_client_args) super(LoadPanopticAnnotations, self).__init__( with_bbox=with_bbox, with_label=with_label, @@ -534,7 +536,7 @@ def __init__( with_keypoints=False, box_type=box_type, imdecode_backend=imdecode_backend, - file_client_args=file_client_args) + backend_args=backend_args) def _load_masks_and_semantic_segs(self, results: dict) -> None: """Private function to load mask and semantic segmentation annotations. @@ -550,7 +552,8 @@ def _load_masks_and_semantic_segs(self, results: dict) -> None: if results.get('seg_map_path', None) is None: return - img_bytes = self.file_client.get(results['seg_map_path']) + img_bytes = get( + results['seg_map_path'], backend_args=self.backend_args) pan_png = mmcv.imfrombytes( img_bytes, flag='color', channel_order='rgb').squeeze() pan_png = self.rgb2id(pan_png) diff --git a/mmdet/datasets/transforms/wrappers.py b/mmdet/datasets/transforms/wrappers.py index e5daf64fa22..3a17711c06b 100644 --- a/mmdet/datasets/transforms/wrappers.py +++ b/mmdet/datasets/transforms/wrappers.py @@ -28,8 +28,7 @@ class MultiBranch(BaseTransform): Examples: >>> branch_field = ['sup', 'unsup_teacher', 'unsup_student'] >>> sup_pipeline = [ - >>> dict(type='LoadImageFromFile', - >>> file_client_args=dict(backend='disk')), + >>> dict(type='LoadImageFromFile'), >>> dict(type='LoadAnnotations', with_bbox=True), >>> dict(type='Resize', scale=(1333, 800), keep_ratio=True), >>> dict(type='RandomFlip', prob=0.5), @@ -39,8 +38,7 @@ class MultiBranch(BaseTransform): >>> sup=dict(type='PackDetInputs')) >>> ] >>> weak_pipeline = [ - >>> dict(type='LoadImageFromFile', - >>> file_client_args=dict(backend='disk')), + >>> dict(type='LoadImageFromFile'), >>> dict(type='LoadAnnotations', with_bbox=True), >>> dict(type='Resize', scale=(1333, 800), keep_ratio=True), >>> dict(type='RandomFlip', prob=0.0), @@ -50,8 +48,7 @@ class MultiBranch(BaseTransform): >>> sup=dict(type='PackDetInputs')) >>> ] >>> strong_pipeline = [ - >>> dict(type='LoadImageFromFile', - >>> file_client_args=dict(backend='disk')), + >>> dict(type='LoadImageFromFile'), >>> dict(type='LoadAnnotations', with_bbox=True), >>> dict(type='Resize', scale=(1333, 800), keep_ratio=True), >>> dict(type='RandomFlip', prob=1.0), @@ -61,8 +58,7 @@ class MultiBranch(BaseTransform): >>> sup=dict(type='PackDetInputs')) >>> ] >>> unsup_pipeline = [ - >>> dict(type='LoadImageFromFile', - >>> file_client_args=file_client_args), + >>> dict(type='LoadImageFromFile'), >>> dict(type='LoadEmptyAnnotations'), >>> dict( >>> type='MultiBranch', @@ -75,15 +71,15 @@ class MultiBranch(BaseTransform): >>> unsup_branch = Compose(unsup_pipeline) >>> print(sup_branch) >>> Compose( - >>> LoadImageFromFile(ignore_empty=False, to_float32=False, color_type='color', imdecode_backend='cv2', file_client_args={'backend': 'disk'}) # noqa - >>> LoadAnnotations(with_bbox=True, with_label=True, with_mask=False, with_seg=False, poly2mask=True, imdecode_backend='cv2', file_client_args={'backend': 'disk'}) # noqa + >>> LoadImageFromFile(ignore_empty=False, to_float32=False, color_type='color', imdecode_backend='cv2') # noqa + >>> LoadAnnotations(with_bbox=True, with_label=True, with_mask=False, with_seg=False, poly2mask=True, imdecode_backend='cv2') # noqa >>> Resize(scale=(1333, 800), scale_factor=None, keep_ratio=True, clip_object_border=True), backend=cv2), interpolation=bilinear) # noqa >>> RandomFlip(prob=0.5, direction=horizontal) >>> MultiBranch(branch_pipelines=['sup']) >>> ) >>> print(unsup_branch) >>> Compose( - >>> LoadImageFromFile(ignore_empty=False, to_float32=False, color_type='color', imdecode_backend='cv2', file_client_args={'backend': 'disk'}) # noqa + >>> LoadImageFromFile(ignore_empty=False, to_float32=False, color_type='color', imdecode_backend='cv2') # noqa >>> LoadEmptyAnnotations(with_bbox=True, with_label=True, with_mask=False, with_seg=False, seg_ignore_label=255) # noqa >>> MultiBranch(branch_pipelines=['unsup_teacher', 'unsup_student']) >>> ) diff --git a/mmdet/datasets/xml_style.py b/mmdet/datasets/xml_style.py index 4f1ba5965d5..da0d2b261f1 100644 --- a/mmdet/datasets/xml_style.py +++ b/mmdet/datasets/xml_style.py @@ -4,7 +4,7 @@ from typing import List, Optional, Union import mmcv -from mmengine.fileio import list_from_file +from mmengine.fileio import get, get_local_path, list_from_file from mmdet.registry import DATASETS from .base_det_dataset import BaseDetDataset @@ -17,9 +17,8 @@ class XMLDataset(BaseDetDataset): Args: img_subdir (str): Subdir where images are stored. Default: JPEGImages. ann_subdir (str): Subdir where annotations are. Default: Annotations. - file_client_args (dict): Arguments to instantiate a FileClient. - See :class:`mmengine.fileio.FileClient` for details. - Defaults to ``dict(backend='disk')``. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend. Defaults to None. """ def __init__(self, @@ -49,8 +48,7 @@ def load_data_list(self) -> List[dict]: } data_list = [] - img_ids = list_from_file( - self.ann_file, file_client_args=self.file_client_args) + img_ids = list_from_file(self.ann_file, backend_args=self.backend_args) for img_id in img_ids: file_name = osp.join(self.img_subdir, f'{img_id}.jpg') xml_path = osp.join(self.sub_data_root, self.ann_subdir, @@ -90,8 +88,9 @@ def parse_data_info(self, img_info: dict) -> Union[dict, List[dict]]: data_info['xml_path'] = img_info['xml_path'] # deal with xml file - with self.file_client.get_local_path( - img_info['xml_path']) as local_path: + with get_local_path( + img_info['xml_path'], + backend_args=self.backend_args) as local_path: raw_ann_info = ET.parse(local_path) root = raw_ann_info.getroot() size = root.find('size') @@ -99,7 +98,7 @@ def parse_data_info(self, img_info: dict) -> Union[dict, List[dict]]: width = int(size.find('width').text) height = int(size.find('height').text) else: - img_bytes = self.file_client.get(img_path) + img_bytes = get(img_path, backend_args=self.backend_args) img = mmcv.imfrombytes(img_bytes, backend='cv2') height, width = img.shape[:2] del img, img_bytes diff --git a/mmdet/engine/hooks/visualization_hook.py b/mmdet/engine/hooks/visualization_hook.py index 1319ee55ac0..a8372433bd3 100644 --- a/mmdet/engine/hooks/visualization_hook.py +++ b/mmdet/engine/hooks/visualization_hook.py @@ -4,7 +4,7 @@ from typing import Optional, Sequence import mmcv -from mmengine.fileio import FileClient +from mmengine.fileio import get from mmengine.hooks import Hook from mmengine.runner import Runner from mmengine.utils import mkdir_or_exist @@ -42,9 +42,8 @@ class DetVisualizationHook(Hook): wait_time (float): The interval of show (s). Defaults to 0. test_out_dir (str, optional): directory where painted images will be saved in testing process. - file_client_args (dict): Arguments to instantiate a FileClient. - See :class:`mmengine.fileio.FileClient` for details. - Defaults to ``dict(backend='disk')``. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend. Defaults to None. """ def __init__(self, @@ -54,7 +53,7 @@ def __init__(self, show: bool = False, wait_time: float = 0., test_out_dir: Optional[str] = None, - file_client_args: dict = dict(backend='disk')): + backend_args: dict = None): self._visualizer: Visualizer = Visualizer.get_current_instance() self.interval = interval self.score_thr = score_thr @@ -68,8 +67,7 @@ def __init__(self, 'needs to be excluded.') self.wait_time = wait_time - self.file_client_args = file_client_args.copy() - self.file_client = None + self.backend_args = backend_args self.draw = draw self.test_out_dir = test_out_dir self._test_index = 0 @@ -88,16 +86,13 @@ def after_val_iter(self, runner: Runner, batch_idx: int, data_batch: dict, if self.draw is False: return - if self.file_client is None: - self.file_client = FileClient(**self.file_client_args) - # There is no guarantee that the same batch of images # is visualized for each evaluation. total_curr_iter = runner.iter + batch_idx # Visualize only the first data img_path = outputs[0].img_path - img_bytes = self.file_client.get(img_path) + img_bytes = get(img_path, backend_args=self.backend_args) img = mmcv.imfrombytes(img_bytes, channel_order='rgb') if total_curr_iter % self.interval == 0: @@ -129,14 +124,11 @@ def after_test_iter(self, runner: Runner, batch_idx: int, data_batch: dict, self.test_out_dir) mkdir_or_exist(self.test_out_dir) - if self.file_client is None: - self.file_client = FileClient(**self.file_client_args) - for data_sample in outputs: self._test_index += 1 img_path = data_sample.img_path - img_bytes = self.file_client.get(img_path) + img_bytes = get(img_path, backend_args=self.backend_args) img = mmcv.imfrombytes(img_bytes, channel_order='rgb') out_file = None diff --git a/mmdet/evaluation/functional/__init__.py b/mmdet/evaluation/functional/__init__.py index 6125ba74cd5..6f139f7bc4f 100644 --- a/mmdet/evaluation/functional/__init__.py +++ b/mmdet/evaluation/functional/__init__.py @@ -1,5 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. from .bbox_overlaps import bbox_overlaps +from .cityscapes_utils import evaluateImgLists from .class_names import (cityscapes_classes, coco_classes, coco_panoptic_classes, dataset_aliases, get_classes, imagenet_det_classes, imagenet_vid_classes, @@ -18,5 +19,6 @@ 'print_recall_summary', 'plot_num_recall', 'plot_iou_recall', 'oid_v6_classes', 'oid_challenge_classes', 'INSTANCE_OFFSET', 'pq_compute_single_core', 'pq_compute_multi_core', 'bbox_overlaps', - 'objects365v1_classes', 'objects365v2_classes', 'coco_panoptic_classes' + 'objects365v1_classes', 'objects365v2_classes', 'coco_panoptic_classes', + 'evaluateImgLists' ] diff --git a/mmdet/evaluation/functional/cityscapes_utils.py b/mmdet/evaluation/functional/cityscapes_utils.py new file mode 100644 index 00000000000..e72cd171ce2 --- /dev/null +++ b/mmdet/evaluation/functional/cityscapes_utils.py @@ -0,0 +1,270 @@ +# Copyright (c) OpenMMLab. All rights reserved. +# Copyright (c) https://github.com/mcordts/cityscapesScripts +# A wrapper of `cityscapesscripts` which supports loading groundtruth +# image from `backend_args`. +import json +import os +import sys +from pathlib import Path +from typing import Optional, Union + +import cityscapesscripts.evaluation.evalInstanceLevelSemanticLabeling as CSEval # noqa: E501 +import mmcv +import numpy as np +from cityscapesscripts.evaluation.instance import Instance +from cityscapesscripts.helpers.csHelpers import id2label # noqa: E501 +from cityscapesscripts.helpers.csHelpers import labels, writeDict2JSON +from mmengine.fileio import get + + +def evaluateImgLists(prediction_list: list, + groundtruth_list: list, + args: CSEval.CArgs, + backend_args: Optional[dict] = None, + dump_matches: bool = False) -> dict: + """A wrapper of obj:``cityscapesscripts.evaluation. + + evalInstanceLevelSemanticLabeling.evaluateImgLists``. Support loading + groundtruth image from file backend. + Args: + prediction_list (list): A list of prediction txt file. + groundtruth_list (list): A list of groundtruth image file. + args (CSEval.CArgs): A global object setting in + obj:``cityscapesscripts.evaluation. + evalInstanceLevelSemanticLabeling`` + backend_args (dict, optional): Arguments to instantiate the + preifx of uri corresponding backend. Defaults to None. + dump_matches (bool): whether dump matches.json. Defaults to False. + Returns: + dict: The computed metric. + """ + # determine labels of interest + CSEval.setInstanceLabels(args) + # get dictionary of all ground truth instances + gt_instances = getGtInstances( + groundtruth_list, args, backend_args=backend_args) + # match predictions and ground truth + matches = matchGtWithPreds(prediction_list, groundtruth_list, gt_instances, + args, backend_args) + if dump_matches: + CSEval.writeDict2JSON(matches, 'matches.json') + # evaluate matches + apScores = CSEval.evaluateMatches(matches, args) + # averages + avgDict = CSEval.computeAverages(apScores, args) + # result dict + resDict = CSEval.prepareJSONDataForResults(avgDict, apScores, args) + if args.JSONOutput: + # create output folder if necessary + path = os.path.dirname(args.exportFile) + CSEval.ensurePath(path) + # Write APs to JSON + CSEval.writeDict2JSON(resDict, args.exportFile) + + CSEval.printResults(avgDict, args) + + return resDict + + +def matchGtWithPreds(prediction_list: list, + groundtruth_list: list, + gt_instances: dict, + args: CSEval.CArgs, + backend_args=None): + """A wrapper of obj:``cityscapesscripts.evaluation. + + evalInstanceLevelSemanticLabeling.matchGtWithPreds``. Support loading + groundtruth image from file backend. + Args: + prediction_list (list): A list of prediction txt file. + groundtruth_list (list): A list of groundtruth image file. + gt_instances (dict): Groundtruth dict. + args (CSEval.CArgs): A global object setting in + obj:``cityscapesscripts.evaluation. + evalInstanceLevelSemanticLabeling`` + backend_args (dict, optional): Arguments to instantiate the + preifx of uri corresponding backend. Defaults to None. + Returns: + dict: The processed prediction and groundtruth result. + """ + matches: dict = dict() + if not args.quiet: + print(f'Matching {len(prediction_list)} pairs of images...') + + count = 0 + for (pred, gt) in zip(prediction_list, groundtruth_list): + # Read input files + gt_image = readGTImage(gt, backend_args) + pred_info = readPredInfo(pred) + # Get and filter ground truth instances + unfiltered_instances = gt_instances[gt] + cur_gt_instances_orig = CSEval.filterGtInstances( + unfiltered_instances, args) + + # Try to assign all predictions + (cur_gt_instances, + cur_pred_instances) = CSEval.assignGt2Preds(cur_gt_instances_orig, + gt_image, pred_info, args) + + # append to global dict + matches[gt] = {} + matches[gt]['groundTruth'] = cur_gt_instances + matches[gt]['prediction'] = cur_pred_instances + + count += 1 + if not args.quiet: + print(f'\rImages Processed: {count}', end=' ') + sys.stdout.flush() + + if not args.quiet: + print('') + + return matches + + +def readGTImage(image_file: Union[str, Path], + backend_args: Optional[dict] = None) -> np.ndarray: + """Read an image from path. + + Same as obj:``cityscapesscripts.evaluation. + evalInstanceLevelSemanticLabeling.readGTImage``, but support loading + groundtruth image from file backend. + Args: + image_file (str or Path): Either a str or pathlib.Path. + backend_args (dict, optional): Instantiates the corresponding file + backend. It may contain `backend` key to specify the file + backend. If it contains, the file backend corresponding to this + value will be used and initialized with the remaining values, + otherwise the corresponding file backend will be selected + based on the prefix of the file path. Defaults to None. + Returns: + np.ndarray: The groundtruth image. + """ + img_bytes = get(image_file, backend_args=backend_args) + img = mmcv.imfrombytes(img_bytes, flag='unchanged', backend='pillow') + return img + + +def readPredInfo(prediction_file: str) -> dict: + """A wrapper of obj:``cityscapesscripts.evaluation. + + evalInstanceLevelSemanticLabeling.readPredInfo``. + Args: + prediction_file (str): The prediction txt file. + Returns: + dict: The processed prediction results. + """ + + printError = CSEval.printError + + predInfo = {} + if (not os.path.isfile(prediction_file)): + printError(f"Infofile '{prediction_file}' " + 'for the predictions not found.') + with open(prediction_file) as f: + for line in f: + splittedLine = line.split(' ') + if len(splittedLine) != 3: + printError('Invalid prediction file. Expected content: ' + 'relPathPrediction1 labelIDPrediction1 ' + 'confidencePrediction1') + if os.path.isabs(splittedLine[0]): + printError('Invalid prediction file. First entry in each ' + 'line must be a relative path.') + + filename = os.path.join( + os.path.dirname(prediction_file), splittedLine[0]) + + imageInfo = {} + imageInfo['labelID'] = int(float(splittedLine[1])) + imageInfo['conf'] = float(splittedLine[2]) # type: ignore + predInfo[filename] = imageInfo + + return predInfo + + +def getGtInstances(groundtruth_list: list, + args: CSEval.CArgs, + backend_args: Optional[dict] = None) -> dict: + """A wrapper of obj:``cityscapesscripts.evaluation. + + evalInstanceLevelSemanticLabeling.getGtInstances``. Support loading + groundtruth image from file backend. + Args: + groundtruth_list (list): A list of groundtruth image file. + args (CSEval.CArgs): A global object setting in + obj:``cityscapesscripts.evaluation. + evalInstanceLevelSemanticLabeling`` + backend_args (dict, optional): Arguments to instantiate the + preifx of uri corresponding backend. Defaults to None. + Returns: + dict: The computed metric. + """ + # if there is a global statistics json, then load it + if (os.path.isfile(args.gtInstancesFile)): + if not args.quiet: + print('Loading ground truth instances from JSON.') + with open(args.gtInstancesFile) as json_file: + gt_instances = json.load(json_file) + # otherwise create it + else: + if (not args.quiet): + print('Creating ground truth instances from png files.') + gt_instances = instances2dict( + groundtruth_list, args, backend_args=backend_args) + writeDict2JSON(gt_instances, args.gtInstancesFile) + + return gt_instances + + +def instances2dict(image_list: list, + args: CSEval.CArgs, + backend_args: Optional[dict] = None) -> dict: + """A wrapper of obj:``cityscapesscripts.evaluation. + + evalInstanceLevelSemanticLabeling.instances2dict``. Support loading + groundtruth image from file backend. + Args: + image_list (list): A list of image file. + args (CSEval.CArgs): A global object setting in + obj:``cityscapesscripts.evaluation. + evalInstanceLevelSemanticLabeling`` + backend_args (dict, optional): Arguments to instantiate the + preifx of uri corresponding backend. Defaults to None. + Returns: + dict: The processed groundtruth results. + """ + imgCount = 0 + instanceDict = {} + + if not isinstance(image_list, list): + image_list = [image_list] + + if not args.quiet: + print(f'Processing {len(image_list)} images...') + + for image_name in image_list: + # Load image + img_bytes = get(image_name, backend_args=backend_args) + imgNp = mmcv.imfrombytes(img_bytes, flag='unchanged', backend='pillow') + + # Initialize label categories + instances: dict = {} + for label in labels: + instances[label.name] = [] + + # Loop through all instance ids in instance image + for instanceId in np.unique(imgNp): + instanceObj = Instance(imgNp, instanceId) + + instances[id2label[instanceObj.labelID].name].append( + instanceObj.toDict()) + + instanceDict[image_name] = instances + imgCount += 1 + + if not args.quiet: + print(f'\rImages Processed: {imgCount}', end=' ') + sys.stdout.flush() + + return instanceDict diff --git a/mmdet/evaluation/functional/panoptic_utils.py b/mmdet/evaluation/functional/panoptic_utils.py index 77c6cd22ec1..6faa8ed52bc 100644 --- a/mmdet/evaluation/functional/panoptic_utils.py +++ b/mmdet/evaluation/functional/panoptic_utils.py @@ -1,7 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. # Copyright (c) 2018, Alexander Kirillov -# This file supports `file_client` for `panopticapi`, +# This file supports `backend_args` for `panopticapi`, # the source code is copied from `panopticapi`, # only the way to load the gt images is modified. import multiprocessing @@ -9,7 +9,7 @@ import mmcv import numpy as np -from mmengine.fileio import FileClient +from mmengine.fileio import get # A custom value to distinguish instance ID and category ID; need to # be greater than the number of categories. @@ -32,7 +32,7 @@ def pq_compute_single_core(proc_id, gt_folder, pred_folder, categories, - file_client=None, + backend_args=None, print_log=False): """The single core function to evaluate the metric of Panoptic Segmentation. @@ -45,8 +45,8 @@ def pq_compute_single_core(proc_id, gt_folder (str): The path of the ground truth images. pred_folder (str): The path of the prediction images. categories (str): The categories of the dataset. - file_client (object): The file client of the dataset. If None, - the backend will be set to `disk`. + backend_args (object): The Backend of the dataset. If None, + the backend will be set to `local`. print_log (bool): Whether to print the log. Defaults to False. """ if PQStat is None: @@ -55,10 +55,6 @@ def pq_compute_single_core(proc_id, 'pip install git+https://github.com/cocodataset/' 'panopticapi.git.') - if file_client is None: - file_client_args = dict(backend='disk') - file_client = FileClient(**file_client_args) - pq_stat = PQStat() idx = 0 @@ -68,9 +64,10 @@ def pq_compute_single_core(proc_id, proc_id, idx, len(annotation_set))) idx += 1 # The gt images can be on the local disk or `ceph`, so we use - # file_client here. - img_bytes = file_client.get( - os.path.join(gt_folder, gt_ann['file_name'])) + # backend here. + img_bytes = get( + os.path.join(gt_folder, gt_ann['file_name']), + backend_args=backend_args) pan_gt = mmcv.imfrombytes(img_bytes, flag='color', channel_order='rgb') pan_gt = rgb2id(pan_gt) @@ -181,7 +178,7 @@ def pq_compute_multi_core(matched_annotations_list, gt_folder, pred_folder, categories, - file_client=None, + backend_args=None, nproc=32): """Evaluate the metrics of Panoptic Segmentation with multithreading. @@ -194,8 +191,8 @@ def pq_compute_multi_core(matched_annotations_list, gt_folder (str): The path of the ground truth images. pred_folder (str): The path of the prediction images. categories (str): The categories of the dataset. - file_client (object): The file client of the dataset. If None, - the backend will be set to `disk`. + backend_args (object): The file client of the dataset. If None, + the backend will be set to `local`. nproc (int): Number of processes for panoptic quality computing. Defaults to 32. When `nproc` exceeds the number of cpu cores, the number of cpu cores is used. @@ -206,10 +203,6 @@ def pq_compute_multi_core(matched_annotations_list, 'pip install git+https://github.com/cocodataset/' 'panopticapi.git.') - if file_client is None: - file_client_args = dict(backend='disk') - file_client = FileClient(**file_client_args) - cpu_num = min(nproc, multiprocessing.cpu_count()) annotations_split = np.array_split(matched_annotations_list, cpu_num) @@ -220,7 +213,7 @@ def pq_compute_multi_core(matched_annotations_list, for proc_id, annotation_set in enumerate(annotations_split): p = workers.apply_async(pq_compute_single_core, (proc_id, annotation_set, gt_folder, - pred_folder, categories, file_client)) + pred_folder, categories, backend_args)) processes.append(p) # Close the process pool, otherwise it will lead to memory diff --git a/mmdet/evaluation/metrics/cityscapes_metric.py b/mmdet/evaluation/metrics/cityscapes_metric.py index 2b28100aff4..23edbf964b1 100644 --- a/mmdet/evaluation/metrics/cityscapes_metric.py +++ b/mmdet/evaluation/metrics/cityscapes_metric.py @@ -2,26 +2,26 @@ import os import os.path as osp import shutil +import tempfile from collections import OrderedDict from typing import Dict, Optional, Sequence import mmcv import numpy as np -from mmengine.dist import is_main_process, master_only +from mmengine.dist import is_main_process from mmengine.evaluator import BaseMetric from mmengine.logging import MMLogger from mmdet.registry import METRICS try: - import cityscapesscripts - from cityscapesscripts.evaluation import \ - evalInstanceLevelSemanticLabeling as CSEval - from cityscapesscripts.helpers import labels as CSLabels + import cityscapesscripts.evaluation.evalInstanceLevelSemanticLabeling as CSEval # noqa: E501 + import cityscapesscripts.helpers.labels as CSLabels + + from mmdet.evaluation.functional.cityscapes_utils import evaluateImgLists + HAS_CITYSCAPESAPI = True except ImportError: - cityscapesscripts = None - CSLabels = None - CSEval = None + HAS_CITYSCAPESAPI = False @METRICS.register_module() @@ -40,8 +40,6 @@ class CityScapesMetric(BaseMetric): evaluation. It is useful when you want to format the result to a specific format and submit it to the test server. Defaults to False. - keep_results (bool): Whether to keep the results. When ``format_only`` - is True, ``keep_results`` must be True. Defaults to False. collect_device (str): Device name used for collecting results from different ranks during distributed training. Must be 'cpu' or 'gpu'. Defaults to 'cpu'. @@ -49,6 +47,12 @@ class CityScapesMetric(BaseMetric): names to disambiguate homonymous metrics of different evaluators. If prefix is not provided in the argument, self.default_prefix will be used instead. Defaults to None. + dump_matches (bool): Whether dump matches.json file during evaluating. + Defaults to False. + file_client_args (dict, optional): Arguments to instantiate the + corresponding backend in mmdet <= 3.0.0rc6. Defaults to None. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend. Defaults to None. """ default_prefix: Optional[str] = 'cityscapes' @@ -56,33 +60,59 @@ def __init__(self, outfile_prefix: str, seg_prefix: Optional[str] = None, format_only: bool = False, - keep_results: bool = False, collect_device: str = 'cpu', - prefix: Optional[str] = None) -> None: - if cityscapesscripts is None: - raise RuntimeError('Please run "pip install cityscapesscripts" to ' - 'install cityscapesscripts first.') - - assert outfile_prefix, 'outfile_prefix must be not None.' - - if format_only: - assert keep_results, 'keep_results must be True when ' - 'format_only is True' - + prefix: Optional[str] = None, + dump_matches: bool = False, + file_client_args: dict = None, + backend_args: dict = None) -> None: + + if not HAS_CITYSCAPESAPI: + raise RuntimeError('Failed to import `cityscapesscripts`.' + 'Please try to install official ' + 'cityscapesscripts by ' + '"pip install cityscapesscripts"') super().__init__(collect_device=collect_device, prefix=prefix) + + self.tmp_dir = None self.format_only = format_only - self.keep_results = keep_results - self.seg_out_dir = osp.abspath(f'{outfile_prefix}.results') - self.seg_prefix = seg_prefix + if self.format_only: + assert outfile_prefix is not None, 'outfile_prefix must be not' + 'None when format_only is True, otherwise the result files will' + 'be saved to a temp directory which will be cleaned up at the end.' + else: + assert seg_prefix is not None, '`seg_prefix` is necessary when ' + 'computing the CityScapes metrics' + + if outfile_prefix is None: + self.tmp_dir = tempfile.TemporaryDirectory() + self.outfile_prefix = osp.join(self.tmp_dir.name, 'results') + else: + # the directory to save predicted panoptic segmentation mask + self.outfile_prefix = osp.join(outfile_prefix, 'results') # type: ignore # yapf: disable # noqa: E501 + + dir_name = osp.expanduser(self.outfile_prefix) + + if osp.exists(dir_name) and is_main_process(): + logger: MMLogger = MMLogger.get_current_instance() + logger.info('remove previous results.') + shutil.rmtree(dir_name) + os.makedirs(dir_name, exist_ok=True) + + self.backend_args = backend_args + if file_client_args is not None: + raise RuntimeError( + 'The `file_client_args` is deprecated, ' + 'please use `backend_args` instead, please refer to' + 'https://github.com/open-mmlab/mmdetection/blob/dev-3.x/configs/_base_/datasets/coco_detection.py' # noqa: E501 + ) - if is_main_process(): - os.makedirs(self.seg_out_dir, exist_ok=True) + self.seg_prefix = seg_prefix + self.dump_matches = dump_matches - @master_only def __del__(self) -> None: - """Clean up.""" - if not self.keep_results: - shutil.rmtree(self.seg_out_dir) + """Clean up the results if necessary.""" + if self.tmp_dir is not None: + self.tmp_dir.cleanup() # TODO: data_batch is no longer needed, consider adjusting the # parameter position @@ -102,7 +132,7 @@ def process(self, data_batch: dict, data_samples: Sequence[dict]) -> None: pred = data_sample['pred_instances'] filename = data_sample['img_path'] basename = osp.splitext(osp.basename(filename))[0] - pred_txt = osp.join(self.seg_out_dir, basename + '_pred.txt') + pred_txt = osp.join(self.outfile_prefix, basename + '_pred.txt') result['pred_txt'] = pred_txt labels = pred['labels'].cpu().numpy() masks = pred['masks'].cpu().numpy().astype(np.uint8) @@ -118,7 +148,8 @@ def process(self, data_batch: dict, data_samples: Sequence[dict]) -> None: class_name = self.dataset_meta['classes'][label] class_id = CSLabels.name2label[class_name].id png_filename = osp.join( - self.seg_out_dir, basename + f'_{i}_{class_name}.png') + self.outfile_prefix, + basename + f'_{i}_{class_name}.png') mmcv.imwrite(mask, png_filename) f.write(f'{osp.basename(png_filename)} ' f'{class_id} {mask_score}\n') @@ -127,8 +158,7 @@ def process(self, data_batch: dict, data_samples: Sequence[dict]) -> None: gt = dict() img_path = filename.replace('leftImg8bit.png', 'gtFine_instanceIds.png') - img_path = img_path.replace('leftImg8bit', 'gtFine') - gt['file_name'] = osp.join(self.seg_prefix, img_path) + gt['file_name'] = img_path.replace('leftImg8bit', 'gtFine') self.results.append((gt, result)) @@ -146,25 +176,28 @@ def compute_metrics(self, results: list) -> Dict[str, float]: if self.format_only: logger.info( - f'results are saved to {osp.dirname(self.seg_out_dir)}') + f'results are saved to {osp.dirname(self.outfile_prefix)}') return OrderedDict() logger.info('starts to compute metric') gts, preds = zip(*results) # set global states in cityscapes evaluation API - CSEval.args.cityscapesPath = osp.join(self.seg_prefix, '../..') - CSEval.args.predictionPath = self.seg_out_dir - CSEval.args.predictionWalk = None + gt_instances_file = osp.join(self.outfile_prefix, 'gtInstances.json') # type: ignore # yapf: disable # noqa: E501 + # split gt and prediction list + gts, preds = zip(*results) CSEval.args.JSONOutput = False CSEval.args.colorized = False - CSEval.args.gtInstancesFile = osp.join(self.seg_out_dir, - 'gtInstances.json') + CSEval.args.gtInstancesFile = gt_instances_file groundTruthImgList = [gt['file_name'] for gt in gts] predictionImgList = [pred['pred_txt'] for pred in preds] - CSEval_results = CSEval.evaluateImgLists(predictionImgList, - groundTruthImgList, - CSEval.args)['averages'] + CSEval_results = evaluateImgLists( + predictionImgList, + groundTruthImgList, + CSEval.args, + self.backend_args, + dump_matches=self.dump_matches)['averages'] + eval_results = OrderedDict() eval_results['mAP'] = CSEval_results['allAp'] eval_results['AP@50'] = CSEval_results['allAp50%'] diff --git a/mmdet/evaluation/metrics/coco_metric.py b/mmdet/evaluation/metrics/coco_metric.py index bd56803da3d..1ca33c50cfa 100644 --- a/mmdet/evaluation/metrics/coco_metric.py +++ b/mmdet/evaluation/metrics/coco_metric.py @@ -9,7 +9,7 @@ import numpy as np import torch from mmengine.evaluator import BaseMetric -from mmengine.fileio import FileClient, dump, load +from mmengine.fileio import dump, get_local_path, load from mmengine.logging import MMLogger from terminaltables import AsciiTable @@ -50,9 +50,10 @@ class CocoMetric(BaseMetric): outfile_prefix (str, optional): The prefix of json files. It includes the file path and the prefix of filename, e.g., "a/b/prefix". If not specified, a temp file will be created. Defaults to None. - file_client_args (dict): Arguments to instantiate a FileClient. - See :class:`mmengine.fileio.FileClient` for details. - Defaults to ``dict(backend='disk')``. + file_client_args (dict, optional): Arguments to instantiate the + corresponding backend in mmdet <= 3.0.0rc6. Defaults to None. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend. Defaults to None. collect_device (str): Device name used for collecting results from different ranks during distributed training. Must be 'cpu' or 'gpu'. Defaults to 'cpu'. @@ -74,7 +75,8 @@ def __init__(self, metric_items: Optional[Sequence[str]] = None, format_only: bool = False, outfile_prefix: Optional[str] = None, - file_client_args: dict = dict(backend='disk'), + file_client_args: dict = None, + backend_args: dict = None, collect_device: str = 'cpu', prefix: Optional[str] = None, sort_categories: bool = False) -> None: @@ -108,13 +110,19 @@ def __init__(self, self.outfile_prefix = outfile_prefix - self.file_client_args = file_client_args - self.file_client = FileClient(**file_client_args) + self.backend_args = backend_args + if file_client_args is not None: + raise RuntimeError( + 'The `file_client_args` is deprecated, ' + 'please use `backend_args` instead, please refer to' + 'https://github.com/open-mmlab/mmdetection/blob/dev-3.x/configs/_base_/datasets/coco_detection.py' # noqa: E501 + ) # if ann_file is not specified, # initialize coco api with the converted dataset if ann_file is not None: - with self.file_client.get_local_path(ann_file) as local_path: + with get_local_path( + ann_file, backend_args=self.backend_args) as local_path: self._coco_api = COCO(local_path) if sort_categories: # 'categories' list in objects365_train.json and diff --git a/mmdet/evaluation/metrics/coco_panoptic_metric.py b/mmdet/evaluation/metrics/coco_panoptic_metric.py index bafe275925a..1ccf796d917 100644 --- a/mmdet/evaluation/metrics/coco_panoptic_metric.py +++ b/mmdet/evaluation/metrics/coco_panoptic_metric.py @@ -8,7 +8,7 @@ import mmcv import numpy as np from mmengine.evaluator import BaseMetric -from mmengine.fileio import FileClient, dump, load +from mmengine.fileio import dump, get_local_path, load from mmengine.logging import MMLogger, print_log from terminaltables import AsciiTable @@ -56,9 +56,10 @@ class CocoPanopticMetric(BaseMetric): nproc (int): Number of processes for panoptic quality computing. Defaults to 32. When ``nproc`` exceeds the number of cpu cores, the number of cpu cores is used. - file_client_args (dict): Arguments to instantiate a FileClient. - See :class:`mmengine.fileio.FileClient` for details. - Defaults to ``dict(backend='disk')``. + file_client_args (dict, optional): Arguments to instantiate the + corresponding backend in mmdet <= 3.0.0rc6. Defaults to None. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend. Defaults to None. collect_device (str): Device name used for collecting results from different ranks during distributed training. Must be 'cpu' or 'gpu'. Defaults to 'cpu'. @@ -76,7 +77,8 @@ def __init__(self, format_only: bool = False, outfile_prefix: Optional[str] = None, nproc: int = 32, - file_client_args: dict = dict(backend='disk'), + file_client_args: dict = None, + backend_args: dict = None, collect_device: str = 'cpu', prefix: Optional[str] = None) -> None: if panopticapi is None: @@ -108,19 +110,23 @@ def __init__(self, self.cat_ids = None self.cat2label = None - self.file_client_args = file_client_args - self.file_client = FileClient(**file_client_args) + self.backend_args = backend_args + if file_client_args is not None: + raise RuntimeError( + 'The `file_client_args` is deprecated, ' + 'please use `backend_args` instead, please refer to' + 'https://github.com/open-mmlab/mmdetection/blob/dev-3.x/configs/_base_/datasets/coco_detection.py' # noqa: E501 + ) if ann_file: - with self.file_client.get_local_path(ann_file) as local_path: + with get_local_path( + ann_file, backend_args=self.backend_args) as local_path: self._coco_api = COCOPanoptic(local_path) self.categories = self._coco_api.cats else: self._coco_api = None self.categories = None - self.file_client = FileClient(**file_client_args) - def __del__(self) -> None: """Clean up.""" if self.tmp_dir is not None: @@ -370,7 +376,7 @@ def _compute_batch_pq_stats(self, data_samples: Sequence[dict]): gt_folder=self.seg_prefix, pred_folder=self.seg_out_dir, categories=categories, - file_client=self.file_client) + backend_args=self.backend_args) self.results.append(pq_stats) @@ -497,7 +503,7 @@ def compute_metrics(self, results: list) -> Dict[str, float]: gt_folder, pred_folder, self.categories, - file_client=self.file_client, + backend_args=self.backend_args, nproc=self.nproc) else: diff --git a/mmdet/evaluation/metrics/crowdhuman_metric.py b/mmdet/evaluation/metrics/crowdhuman_metric.py index a16f4351cde..3bec5b53685 100644 --- a/mmdet/evaluation/metrics/crowdhuman_metric.py +++ b/mmdet/evaluation/metrics/crowdhuman_metric.py @@ -9,7 +9,7 @@ import numpy as np from mmengine.evaluator import BaseMetric -from mmengine.fileio import FileClient, dump, load +from mmengine.fileio import dump, get_text, load from mmengine.logging import MMLogger from scipy.sparse import csr_matrix from scipy.sparse.csgraph import maximum_bipartite_matching @@ -38,9 +38,10 @@ class CrowdHumanMetric(BaseMetric): outfile_prefix (str, optional): The prefix of json files. It includes the file path and the prefix of filename, e.g., "a/b/prefix". If not specified, a temp file will be created. Defaults to None. - file_client_args (dict): Arguments to instantiate a FileClient. - See :class:`mmengine.fileio.FileClient` for details. - Defaults to ``dict(backend='disk')``. + file_client_args (dict, optional): Arguments to instantiate the + corresponding backend in mmdet <= 3.0.0rc6. Defaults to None. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend. Defaults to None. collect_device (str): Device name used for collecting results from different ranks during distributed training. Must be 'cpu' or 'gpu'. Defaults to 'cpu'. @@ -68,7 +69,8 @@ def __init__(self, metric: Union[str, List[str]] = ['AP', 'MR', 'JI'], format_only: bool = False, outfile_prefix: Optional[str] = None, - file_client_args: dict = dict(backend='disk'), + file_client_args: dict = None, + backend_args: dict = None, collect_device: str = 'cpu', prefix: Optional[str] = None, eval_mode: int = 0, @@ -93,8 +95,13 @@ def __init__(self, 'None when format_only is True, otherwise the result files will' 'be saved to a temp directory which will be cleaned up at the end.' self.outfile_prefix = outfile_prefix - self.file_client_args = file_client_args - self.file_client = FileClient(**file_client_args) + self.backend_args = backend_args + if file_client_args is not None: + raise RuntimeError( + 'The `file_client_args` is deprecated, ' + 'please use `backend_args` instead, please refer to' + 'https://github.com/open-mmlab/mmdetection/blob/dev-3.x/configs/_base_/datasets/coco_detection.py' # noqa: E501 + ) assert eval_mode in [0, 1, 2], \ "Unknown eval mode. mr_ref should be one of '0', '1', '2'." @@ -221,10 +228,11 @@ def load_eval_samples(self, result_file): Returns: Dict[Image]: The detection result packaged by Image """ - gt_str = self.file_client.get_text(self.ann_file).strip().split('\n') + gt_str = get_text( + self.ann_file, backend_args=self.backend_args).strip().split('\n') gt_records = [json.loads(line) for line in gt_str] - pred_records = load(result_file) + pred_records = load(result_file, backend_args=self.backend_args) eval_samples = dict() for gt_record, pred_record in zip(gt_records, pred_records): assert gt_record['ID'] == pred_record['ID'], \ diff --git a/mmdet/evaluation/metrics/dump_proposals_metric.py b/mmdet/evaluation/metrics/dump_proposals_metric.py index 06ecc78d69b..68dc2d5ab84 100644 --- a/mmdet/evaluation/metrics/dump_proposals_metric.py +++ b/mmdet/evaluation/metrics/dump_proposals_metric.py @@ -22,9 +22,10 @@ class DumpProposals(BaseMetric): proposals_file (str): Proposals file path. Defaults to 'proposals.pkl'. num_max_proposals (int, optional): Maximum number of proposals to dump. If not specified, all proposals will be dumped. - file_client_args (dict): Arguments to instantiate a FileClient. - See :class:`mmengine.fileio.FileClient` for details. - Defaults to ``dict(backend='disk')``. + file_client_args (dict, optional): Arguments to instantiate the + corresponding backend in mmdet <= 3.0.0rc6. Defaults to None. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend. Defaults to None. collect_device (str): Device name used for collecting results from different ranks during distributed training. Must be 'cpu' or 'gpu'. Defaults to 'cpu'. @@ -40,13 +41,20 @@ def __init__(self, output_dir: str = '', proposals_file: str = 'proposals.pkl', num_max_proposals: Optional[int] = None, - file_client_args: dict = dict(backend='disk'), + file_client_args: dict = None, + backend_args: dict = None, collect_device: str = 'cpu', prefix: Optional[str] = None) -> None: super().__init__(collect_device=collect_device, prefix=prefix) self.num_max_proposals = num_max_proposals # TODO: update after mmengine finish refactor fileio. - self.file_client_args = file_client_args + self.backend_args = backend_args + if file_client_args is not None: + raise RuntimeError( + 'The `file_client_args` is deprecated, ' + 'please use `backend_args` instead, please refer to' + 'https://github.com/open-mmlab/mmdetection/blob/dev-3.x/configs/_base_/datasets/coco_detection.py' # noqa: E501 + ) self.output_dir = output_dir assert proposals_file.endswith(('.pkl', '.pickle')), \ 'The output file must be a pkl file.' @@ -106,6 +114,6 @@ def compute_metrics(self, results: list) -> dict: dump( dump_results, file=self.proposals_file, - file_client_args=self.file_client_args) + backend_args=self.backend_args) logger.info(f'Results are saved at {self.proposals_file}') return {} diff --git a/mmdet/evaluation/metrics/lvis_metric.py b/mmdet/evaluation/metrics/lvis_metric.py index 388c097d5ff..b4b3dd44f9a 100644 --- a/mmdet/evaluation/metrics/lvis_metric.py +++ b/mmdet/evaluation/metrics/lvis_metric.py @@ -7,6 +7,7 @@ from typing import Dict, List, Optional, Sequence, Union import numpy as np +from mmengine.fileio import get_local_path from mmengine.logging import MMLogger from terminaltables import AsciiTable @@ -62,6 +63,10 @@ class LVISMetric(CocoMetric): names to disambiguate homonymous metrics of different evaluators. If prefix is not provided in the argument, self.default_prefix will be used instead. Defaults to None. + file_client_args (dict, optional): Arguments to instantiate the + corresponding backend in mmdet <= 3.0.0rc6. Defaults to None. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend. Defaults to None. """ default_prefix: Optional[str] = 'lvis' @@ -76,7 +81,9 @@ def __init__(self, format_only: bool = False, outfile_prefix: Optional[str] = None, collect_device: str = 'cpu', - prefix: Optional[str] = None) -> None: + prefix: Optional[str] = None, + file_client_args: dict = None, + backend_args: dict = None) -> None: if lvis is None: raise RuntimeError( 'Package lvis is not installed. Please run "pip install ' @@ -110,10 +117,22 @@ def __init__(self, 'be saved to a temp directory which will be cleaned up at the end.' self.outfile_prefix = outfile_prefix + self.backend_args = backend_args + if file_client_args is not None: + raise RuntimeError( + 'The `file_client_args` is deprecated, ' + 'please use `backend_args` instead, please refer to' + 'https://github.com/open-mmlab/mmdetection/blob/dev-3.x/configs/_base_/datasets/coco_detection.py' # noqa: E501 + ) # if ann_file is not specified, # initialize lvis api with the converted dataset - self._lvis_api = LVIS(ann_file) if ann_file else None + if ann_file is not None: + with get_local_path( + ann_file, backend_args=self.backend_args) as local_path: + self._lvis_api = LVIS(local_path) + else: + self._lvis_api = None # handle dataset lazy init self.cat_ids = None diff --git a/mmdet/models/test_time_augs/det_tta.py b/mmdet/models/test_time_augs/det_tta.py index 66f0817a9f8..95f91db9e12 100644 --- a/mmdet/models/test_time_augs/det_tta.py +++ b/mmdet/models/test_time_augs/det_tta.py @@ -27,7 +27,7 @@ class DetTTAModel(BaseTTAModel): >>> >>> tta_pipeline = [ >>> dict(type='LoadImageFromFile', - >>> file_client_args=dict(backend='disk')), + >>> backend_args=None), >>> dict( >>> type='TestTimeAug', >>> transforms=[[ diff --git a/mmdet/testing/_utils.py b/mmdet/testing/_utils.py index 471a6bd3a7b..ce74376250e 100644 --- a/mmdet/testing/_utils.py +++ b/mmdet/testing/_utils.py @@ -274,7 +274,7 @@ def demo_mm_sampling_results(proposals_list, # TODO: Support full ceph def replace_to_ceph(cfg): - file_client_args = dict( + backend_args = dict( backend='petrel', path_mapping=dict({ './data/': 's3://openmmlab/datasets/detection/', @@ -286,12 +286,12 @@ def _process_pipeline(dataset, name): def replace_img(pipeline): if pipeline['type'] == 'LoadImageFromFile': - pipeline['file_client_args'] = file_client_args + pipeline['backend_args'] = backend_args def replace_ann(pipeline): if pipeline['type'] == 'LoadAnnotations' or pipeline[ 'type'] == 'LoadPanopticAnnotations': - pipeline['file_client_args'] = file_client_args + pipeline['backend_args'] = backend_args if 'pipeline' in dataset: replace_img(dataset.pipeline[0]) @@ -307,7 +307,7 @@ def replace_ann(pipeline): def _process_evaluator(evaluator, name): if evaluator['type'] == 'CocoPanopticMetric': - evaluator['file_client_args'] = file_client_args + evaluator['backend_args'] = backend_args # half ceph _process_pipeline(cfg.train_dataloader.dataset, cfg.filename) diff --git a/projects/ConvNeXt-V2/configs/mask-rcnn_convnext-v2-b_fpn_lsj-3x-fcmae_coco.py b/projects/ConvNeXt-V2/configs/mask-rcnn_convnext-v2-b_fpn_lsj-3x-fcmae_coco.py index f5815d8ecdf..95b960df92f 100644 --- a/projects/ConvNeXt-V2/configs/mask-rcnn_convnext-v2-b_fpn_lsj-3x-fcmae_coco.py +++ b/projects/ConvNeXt-V2/configs/mask-rcnn_convnext-v2-b_fpn_lsj-3x-fcmae_coco.py @@ -31,7 +31,7 @@ rcnn=dict(nms=dict(type='soft_nms')))) train_pipeline = [ - dict(type='LoadImageFromFile', file_client_args=_base_.file_client_args), + dict(type='LoadImageFromFile', backend_args=_base_.backend_args), dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict( type='RandomResize', diff --git a/projects/Detic/configs/detic_centernet2_swin-b_fpn_4x_lvis-coco-in21k.py b/projects/Detic/configs/detic_centernet2_swin-b_fpn_4x_lvis-coco-in21k.py index 19a17aea7bc..d554c40ec20 100644 --- a/projects/Detic/configs/detic_centernet2_swin-b_fpn_4x_lvis-coco-in21k.py +++ b/projects/Detic/configs/detic_centernet2_swin-b_fpn_4x_lvis-coco-in21k.py @@ -252,7 +252,7 @@ test_pipeline = [ dict( type='LoadImageFromFile', - file_client_args=_base_.file_client_args, + backend_args=_base_.backend_args, imdecode_backend=backend), dict(type='Resize', scale=(1333, 800), keep_ratio=True, backend=backend), dict( diff --git a/projects/DiffusionDet/configs/diffusiondet_r50_fpn_500-proposals_1-step_crop-ms-480-800-450k_coco.py b/projects/DiffusionDet/configs/diffusiondet_r50_fpn_500-proposals_1-step_crop-ms-480-800-450k_coco.py index 310cdc4cf2b..187cdc39734 100644 --- a/projects/DiffusionDet/configs/diffusiondet_r50_fpn_500-proposals_1-step_crop-ms-480-800-450k_coco.py +++ b/projects/DiffusionDet/configs/diffusiondet_r50_fpn_500-proposals_1-step_crop-ms-480-800-450k_coco.py @@ -95,7 +95,7 @@ train_pipeline = [ dict( type='LoadImageFromFile', - file_client_args=_base_.file_client_args, + backend_args=_base_.backend_args, imdecode_backend=backend), dict(type='LoadAnnotations', with_bbox=True), dict(type='RandomFlip', prob=0.5), @@ -136,7 +136,7 @@ test_pipeline = [ dict( type='LoadImageFromFile', - file_client_args=_base_.file_client_args, + backend_args=_base_.backend_args, imdecode_backend=backend), dict(type='Resize', scale=(1333, 800), keep_ratio=True, backend=backend), # If you don't have a gt annotation, delete the pipeline diff --git a/projects/EfficientDet/configs/efficientdet_effb0_bifpn_8xb16-crop512-300e_coco.py b/projects/EfficientDet/configs/efficientdet_effb0_bifpn_8xb16-crop512-300e_coco.py index 8ccbc85a479..c7a3b309237 100644 --- a/projects/EfficientDet/configs/efficientdet_effb0_bifpn_8xb16-crop512-300e_coco.py +++ b/projects/EfficientDet/configs/efficientdet_effb0_bifpn_8xb16-crop512-300e_coco.py @@ -94,9 +94,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', @@ -108,9 +106,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(image_size, image_size), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/projects/EfficientDet/configs/efficientdet_effb3_bifpn_8xb16-crop896-300e_coco-90cls.py b/projects/EfficientDet/configs/efficientdet_effb3_bifpn_8xb16-crop896-300e_coco-90cls.py index e1ff4d7d147..fe82a5e1b94 100644 --- a/projects/EfficientDet/configs/efficientdet_effb3_bifpn_8xb16-crop896-300e_coco-90cls.py +++ b/projects/EfficientDet/configs/efficientdet_effb3_bifpn_8xb16-crop896-300e_coco-90cls.py @@ -94,9 +94,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', @@ -108,9 +106,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(image_size, image_size), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/projects/EfficientDet/configs/efficientdet_effb3_bifpn_8xb16-crop896-300e_coco.py b/projects/EfficientDet/configs/efficientdet_effb3_bifpn_8xb16-crop896-300e_coco.py index 5d9a6b6fe93..2079e2ac65a 100644 --- a/projects/EfficientDet/configs/efficientdet_effb3_bifpn_8xb16-crop896-300e_coco.py +++ b/projects/EfficientDet/configs/efficientdet_effb3_bifpn_8xb16-crop896-300e_coco.py @@ -94,9 +94,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', @@ -108,9 +106,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(image_size, image_size), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/projects/EfficientDet/configs/tensorflow/efficientdet_effb0_bifpn_8xb16-crop512-300e_coco_tf.py b/projects/EfficientDet/configs/tensorflow/efficientdet_effb0_bifpn_8xb16-crop512-300e_coco_tf.py index 00200cdf718..bf3d3fc1799 100644 --- a/projects/EfficientDet/configs/tensorflow/efficientdet_effb0_bifpn_8xb16-crop512-300e_coco_tf.py +++ b/projects/EfficientDet/configs/tensorflow/efficientdet_effb0_bifpn_8xb16-crop512-300e_coco_tf.py @@ -94,9 +94,7 @@ # dataset settings train_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='LoadAnnotations', with_bbox=True), dict( type='RandomResize', @@ -108,9 +106,7 @@ dict(type='PackDetInputs') ] test_pipeline = [ - dict( - type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}), + dict(type='LoadImageFromFile', backend_args={{_base_.backend_args}}), dict(type='Resize', scale=(image_size, image_size), keep_ratio=True), dict(type='LoadAnnotations', with_bbox=True), dict( diff --git a/projects/EfficientDet/efficientdet/tensorflow/coco_90class.py b/projects/EfficientDet/efficientdet/tensorflow/coco_90class.py index b0742af0be9..d2996ccb8fc 100644 --- a/projects/EfficientDet/efficientdet/tensorflow/coco_90class.py +++ b/projects/EfficientDet/efficientdet/tensorflow/coco_90class.py @@ -3,6 +3,8 @@ import os.path as osp from typing import List, Union +from mmengine.fileio import get_local_path + from mmdet.datasets.base_det_dataset import BaseDetDataset from mmdet.registry import DATASETS from .api_wrappers import COCO @@ -62,7 +64,8 @@ def load_data_list(self) -> List[dict]: Returns: List[dict]: A list of annotation. """ # noqa: E501 - with self.file_client.get_local_path(self.ann_file) as local_path: + with get_local_path( + self.ann_file, backend_args=self.backend_args) as local_path: self.coco = self.COCOAPI(local_path) # The order of returned `cat_ids` will not # change with the order of the `classes` diff --git a/projects/EfficientDet/efficientdet/tensorflow/coco_90metric.py b/projects/EfficientDet/efficientdet/tensorflow/coco_90metric.py index 7bc12d00956..eed65224018 100644 --- a/projects/EfficientDet/efficientdet/tensorflow/coco_90metric.py +++ b/projects/EfficientDet/efficientdet/tensorflow/coco_90metric.py @@ -8,7 +8,7 @@ import numpy as np from mmengine.evaluator import BaseMetric -from mmengine.fileio import FileClient, dump, load +from mmengine.fileio import dump, get_local_path, load from mmengine.logging import MMLogger from terminaltables import AsciiTable @@ -49,9 +49,8 @@ class Coco90Metric(BaseMetric): outfile_prefix (str, optional): The prefix of json files. It includes the file path and the prefix of filename, e.g., "a/b/prefix". If not specified, a temp file will be created. Defaults to None. - file_client_args (dict): Arguments to instantiate a FileClient. - See :class:`mmengine.fileio.FileClient` for details. - Defaults to ``dict(backend='disk')``. + backend_args (dict, optional): Arguments to instantiate the + corresponding backend. Defaults to None. collect_device (str): Device name used for collecting results from different ranks during distributed training. Must be 'cpu' or 'gpu'. Defaults to 'cpu'. @@ -71,7 +70,7 @@ def __init__(self, metric_items: Optional[Sequence[str]] = None, format_only: bool = False, outfile_prefix: Optional[str] = None, - file_client_args: dict = dict(backend='disk'), + backend_args: dict = None, collect_device: str = 'cpu', prefix: Optional[str] = None) -> None: super().__init__(collect_device=collect_device, prefix=prefix) @@ -104,13 +103,13 @@ def __init__(self, self.outfile_prefix = outfile_prefix - self.file_client_args = file_client_args - self.file_client = FileClient(**file_client_args) + self.backend_args = backend_args # if ann_file is not specified, # initialize coco api with the converted dataset if ann_file is not None: - with self.file_client.get_local_path(ann_file) as local_path: + with get_local_path( + ann_file, backend_args=self.backend_args) as local_path: self._coco_api = COCO(local_path) else: self._coco_api = None diff --git a/projects/SparseInst/configs/sparseinst_r50_iam_8xb8-ms-270k_coco.py b/projects/SparseInst/configs/sparseinst_r50_iam_8xb8-ms-270k_coco.py index 030675d2609..7a85f52398d 100644 --- a/projects/SparseInst/configs/sparseinst_r50_iam_8xb8-ms-270k_coco.py +++ b/projects/SparseInst/configs/sparseinst_r50_iam_8xb8-ms-270k_coco.py @@ -76,7 +76,7 @@ train_pipeline = [ dict( type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}, + backend_args={{_base_.backend_args}}, imdecode_backend=backend), dict( type='LoadAnnotations', @@ -96,7 +96,7 @@ test_pipeline = [ dict( type='LoadImageFromFile', - file_client_args={{_base_.file_client_args}}, + backend_args={{_base_.backend_args}}, imdecode_backend=backend), dict(type='Resize', scale=(640, 853), keep_ratio=True, backend=backend), dict( diff --git a/requirements/mminstall.txt b/requirements/mminstall.txt index 8faef45b260..abe49081a48 100644 --- a/requirements/mminstall.txt +++ b/requirements/mminstall.txt @@ -1,2 +1,2 @@ mmcv>=2.0.0rc4,<2.1.0 -mmengine>=0.4.0,<1.0.0 +mmengine>=0.6.0,<1.0.0 diff --git a/tests/test_datasets/test_transforms/test_loading.py b/tests/test_datasets/test_transforms/test_loading.py index 49d912cc274..a4fcf4e087c 100644 --- a/tests/test_datasets/test_transforms/test_loading.py +++ b/tests/test_datasets/test_transforms/test_loading.py @@ -122,7 +122,7 @@ def test_repr(self): 'with_label=False, with_mask=False, ' 'with_seg=False, poly2mask=True, ' "imdecode_backend='cv2', " - 'file_client_args=None)')) + 'backend_args=None)')) class TestFilterAnnotations(unittest.TestCase): @@ -387,7 +387,7 @@ def test_rper(self): 'to_float32=False, ' "color_type='unchanged', " "imdecode_backend='cv2', " - "file_client_args={'backend': 'disk'})")) + 'backend_args=None)')) class TestLoadProposals(unittest.TestCase): diff --git a/tests/test_evaluation/test_metrics/test_cityscapes_metric.py b/tests/test_evaluation/test_metrics/test_cityscapes_metric.py index 91a4f745dd6..d0ee6eb9ba4 100644 --- a/tests/test_evaluation/test_metrics/test_cityscapes_metric.py +++ b/tests/test_evaluation/test_metrics/test_cityscapes_metric.py @@ -30,13 +30,6 @@ def test_init(self): with self.assertRaises(AssertionError): CityScapesMetric(outfile_prefix=None) - # test with format_only=True, keep_results=False - with self.assertRaises(AssertionError): - CityScapesMetric( - outfile_prefix=self.tmp_dir.name + 'test', - format_only=True, - keep_results=False) - @unittest.skipIf(cityscapesscripts is None, 'cityscapesscripts is not installed.') def test_evaluate(self): @@ -86,7 +79,6 @@ def test_evaluate(self): metric = CityScapesMetric( seg_prefix=self.seg_prefix, format_only=False, - keep_results=False, outfile_prefix=self.outfile_prefix) metric.dataset_meta = dict( classes=('person', 'rider', 'car', 'truck', 'bus', 'train', @@ -101,7 +93,6 @@ def test_evaluate(self): metric = CityScapesMetric( seg_prefix=self.seg_prefix, format_only=True, - keep_results=True, outfile_prefix=self.outfile_prefix) metric.dataset_meta = dict( classes=('person', 'rider', 'car', 'truck', 'bus', 'train', diff --git a/tests/test_evaluation/test_metrics/test_coco_metric.py b/tests/test_evaluation/test_metrics/test_coco_metric.py index 63611a1c3cb..547b8f21e0f 100644 --- a/tests/test_evaluation/test_metrics/test_coco_metric.py +++ b/tests/test_evaluation/test_metrics/test_coco_metric.py @@ -204,6 +204,8 @@ def test_classwise_evaluate(self): # test single coco dataset evaluation coco_metric = CocoMetric( ann_file=fake_json_file, metric='bbox', classwise=True) + # coco_metric1 = CocoMetric( + # ann_file=fake_json_file, metric='bbox', classwise=True) coco_metric.dataset_meta = dict(classes=['car', 'bicycle']) coco_metric.process( {}, diff --git a/tools/misc/get_crowdhuman_id_hw.py b/tools/misc/get_crowdhuman_id_hw.py index b3ab3748daf..8ed9142a423 100644 --- a/tools/misc/get_crowdhuman_id_hw.py +++ b/tools/misc/get_crowdhuman_id_hw.py @@ -15,7 +15,7 @@ import mmcv from mmengine.config import Config -from mmengine.fileio import FileClient, dump +from mmengine.fileio import dump, get, get_text from mmengine.logging import print_log @@ -37,11 +37,10 @@ def parse_args(): def get_image_metas(anno_str, img_prefix): id_hw = {} - file_client = FileClient(backend='disk') anno_dict = json.loads(anno_str) img_path = osp.join(img_prefix, f"{anno_dict['ID']}.jpg") img_id = anno_dict['ID'] - img_bytes = file_client.get(img_path) + img_bytes = get(img_path) img = mmcv.imfrombytes(img_bytes, backend='cv2') id_hw[img_id] = img.shape[:2] return id_hw @@ -52,8 +51,6 @@ def main(): # get ann_file and img_prefix from config files cfg = Config.fromfile(args.config) - file_client_args = cfg.get('file_client_args', dict(backend='disk')) - file_client = FileClient(**file_client_args) dataset = args.dataset dataloader_cfg = cfg.get(f'{dataset}_dataloader') ann_file = osp.join(dataloader_cfg.dataset.data_root, @@ -64,7 +61,7 @@ def main(): # load image metas print_log( f'loading CrowdHuman {dataset} annotation...', level=logging.INFO) - anno_strs = file_client.get_text(ann_file).strip().split('\n') + anno_strs = get_text(ann_file).strip().split('\n') pool = Pool(args.nproc) # get image metas with multiple processes id_hw_temp = pool.starmap( diff --git a/tools/misc/get_image_metas.py b/tools/misc/get_image_metas.py index 03b35cb2c0d..5644fa8c1ab 100644 --- a/tools/misc/get_image_metas.py +++ b/tools/misc/get_image_metas.py @@ -14,7 +14,7 @@ import mmcv from mmengine.config import Config -from mmengine.fileio import FileClient, dump +from mmengine.fileio import dump, get def parse_args(): @@ -69,12 +69,11 @@ def get_metas_from_txt_style_ann_file(ann_file): def get_image_metas(data_info, img_prefix): - file_client = FileClient(backend='disk') filename = data_info.get('filename', None) if filename is not None: if img_prefix is not None: filename = osp.join(img_prefix, filename) - img_bytes = file_client.get(filename) + img_bytes = get(filename) img = mmcv.imfrombytes(img_bytes, flag='color') shape = img.shape meta = dict(filename=filename, ori_shape=shape)