From a7a16afbf2a4bdb4d023094da73d325cb864838b Mon Sep 17 00:00:00 2001 From: Charlie Chang Date: Fri, 19 Nov 2021 19:31:47 +0800 Subject: [PATCH] Clean unnecessary custom_imports in entrypoints (#6546) --- mmdet/core/export/pytorch2onnx.py | 4 ---- tools/analysis_tools/analyze_results.py | 4 ---- tools/analysis_tools/eval_metric.py | 4 ---- tools/analysis_tools/get_flops.py | 4 ---- tools/analysis_tools/test_robustness.py | 4 ---- tools/misc/browse_dataset.py | 4 ---- tools/misc/print_config.py | 4 ---- tools/test.py | 4 ---- tools/train.py | 4 ---- 9 files changed, 36 deletions(-) diff --git a/mmdet/core/export/pytorch2onnx.py b/mmdet/core/export/pytorch2onnx.py index 53906f2650d..b8261eed9e8 100644 --- a/mmdet/core/export/pytorch2onnx.py +++ b/mmdet/core/export/pytorch2onnx.py @@ -78,10 +78,6 @@ def build_model_from_cfg(config_path, checkpoint_path, cfg_options=None): cfg = mmcv.Config.fromfile(config_path) if cfg_options is not None: cfg.merge_from_dict(cfg_options) - # import modules from string list. - if cfg.get('custom_imports', None): - from mmcv.utils import import_modules_from_strings - import_modules_from_strings(**cfg['custom_imports']) # set cudnn_benchmark if cfg.get('cudnn_benchmark', False): torch.backends.cudnn.benchmark = True diff --git a/tools/analysis_tools/analyze_results.py b/tools/analysis_tools/analyze_results.py index 60e20fea64b..8265265575c 100644 --- a/tools/analysis_tools/analyze_results.py +++ b/tools/analysis_tools/analyze_results.py @@ -183,10 +183,6 @@ def main(): if args.cfg_options is not None: cfg.merge_from_dict(args.cfg_options) cfg.data.test.test_mode = True - # import modules from string list. - if cfg.get('custom_imports', None): - from mmcv.utils import import_modules_from_strings - import_modules_from_strings(**cfg['custom_imports']) cfg.data.test.pop('samples_per_gpu', 0) cfg.data.test.pipeline = get_loading_pipeline(cfg.data.train.pipeline) diff --git a/tools/analysis_tools/eval_metric.py b/tools/analysis_tools/eval_metric.py index c55bced3a99..1fcdc1c1fa9 100644 --- a/tools/analysis_tools/eval_metric.py +++ b/tools/analysis_tools/eval_metric.py @@ -56,10 +56,6 @@ def main(): if args.cfg_options is not None: cfg.merge_from_dict(args.cfg_options) - # import modules from string list. - if cfg.get('custom_imports', None): - from mmcv.utils import import_modules_from_strings - import_modules_from_strings(**cfg['custom_imports']) cfg.data.test.test_mode = True dataset = build_dataset(cfg.data.test) diff --git a/tools/analysis_tools/get_flops.py b/tools/analysis_tools/get_flops.py index 7f1c3bfc5ad..0ac59a50049 100644 --- a/tools/analysis_tools/get_flops.py +++ b/tools/analysis_tools/get_flops.py @@ -63,10 +63,6 @@ def main(): cfg = Config.fromfile(args.config) if args.cfg_options is not None: cfg.merge_from_dict(args.cfg_options) - # import modules from string list. - if cfg.get('custom_imports', None): - from mmcv.utils import import_modules_from_strings - import_modules_from_strings(**cfg['custom_imports']) model = build_detector( cfg.model, diff --git a/tools/analysis_tools/test_robustness.py b/tools/analysis_tools/test_robustness.py index ab09366d07f..29cb41da657 100644 --- a/tools/analysis_tools/test_robustness.py +++ b/tools/analysis_tools/test_robustness.py @@ -191,10 +191,6 @@ def main(): cfg = mmcv.Config.fromfile(args.config) if args.cfg_options is not None: cfg.merge_from_dict(args.cfg_options) - # import modules from string list. - if cfg.get('custom_imports', None): - from mmcv.utils import import_modules_from_strings - import_modules_from_strings(**cfg['custom_imports']) # set cudnn_benchmark if cfg.get('cudnn_benchmark', False): torch.backends.cudnn.benchmark = True diff --git a/tools/misc/browse_dataset.py b/tools/misc/browse_dataset.py index 3b8b8d60133..aebe9cf9bd8 100644 --- a/tools/misc/browse_dataset.py +++ b/tools/misc/browse_dataset.py @@ -56,10 +56,6 @@ def skip_pipeline_steps(config): cfg = Config.fromfile(config_path) if cfg_options is not None: cfg.merge_from_dict(cfg_options) - # import modules from string list. - if cfg.get('custom_imports', None): - from mmcv.utils import import_modules_from_strings - import_modules_from_strings(**cfg['custom_imports']) train_data_cfg = cfg.data.train while 'dataset' in train_data_cfg and train_data_cfg[ 'type'] != 'MultiImageMixDataset': diff --git a/tools/misc/print_config.py b/tools/misc/print_config.py index e44cda06234..1b2cb30c24c 100644 --- a/tools/misc/print_config.py +++ b/tools/misc/print_config.py @@ -44,10 +44,6 @@ def main(): cfg = Config.fromfile(args.config) if args.cfg_options is not None: cfg.merge_from_dict(args.cfg_options) - # import modules from string list. - if cfg.get('custom_imports', None): - from mmcv.utils import import_modules_from_strings - import_modules_from_strings(**cfg['custom_imports']) print(f'Config:\n{cfg.pretty_text}') diff --git a/tools/test.py b/tools/test.py index f16ac635cd5..31bb3be3474 100644 --- a/tools/test.py +++ b/tools/test.py @@ -122,10 +122,6 @@ def main(): cfg = Config.fromfile(args.config) if args.cfg_options is not None: cfg.merge_from_dict(args.cfg_options) - # import modules from string list. - if cfg.get('custom_imports', None): - from mmcv.utils import import_modules_from_strings - import_modules_from_strings(**cfg['custom_imports']) # set cudnn_benchmark if cfg.get('cudnn_benchmark', False): torch.backends.cudnn.benchmark = True diff --git a/tools/train.py b/tools/train.py index 45fa03bfad6..95db9fbbc01 100644 --- a/tools/train.py +++ b/tools/train.py @@ -90,10 +90,6 @@ def main(): cfg = Config.fromfile(args.config) if args.cfg_options is not None: cfg.merge_from_dict(args.cfg_options) - # import modules from string list. - if cfg.get('custom_imports', None): - from mmcv.utils import import_modules_from_strings - import_modules_from_strings(**cfg['custom_imports']) # set cudnn_benchmark if cfg.get('cudnn_benchmark', False): torch.backends.cudnn.benchmark = True