MCPcopy Create free account
hub / github.com/OpenDriveLab/OccNet / main

Function main

tools/test.py:113–263  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111
112 assert args.out or args.eval or args.format_only or args.show \
113 or args.show_dir, \
114 ('Please specify at least one operation (save/eval/format/show the '
115 'results / save the results) with the argument "--out", "--eval"'
116 ', "--format-only", "--show" or "--show-dir"')
117
118 if args.eval and args.format_only:
119 raise ValueError('--eval and --format_only cannot be both specified')
120
121 if args.out is not None and not args.out.endswith(('.pkl', '.pickle')):
122 raise ValueError('The output file must be a pkl file.')
123
124 cfg = Config.fromfile(args.config)
125 if args.cfg_options is not None:
126 cfg.merge_from_dict(args.cfg_options)
127 # import modules from string list.
128 if cfg.get('custom_imports', None):
129 from mmcv.utils import import_modules_from_strings
130 import_modules_from_strings(**cfg['custom_imports'])
131
132 # import modules from plguin/xx, registry will be updated
133 if hasattr(cfg, 'plugin'):
134 if cfg.plugin:
135 import importlib
136 if hasattr(cfg, 'plugin_dir'):
137 plugin_dir = cfg.plugin_dir
138 _module_dir = os.path.dirname(plugin_dir)
139 _module_dir = _module_dir.split('/')
140 _module_path = _module_dir[0]
141
142 for m in _module_dir[1:]:
143 _module_path = _module_path + '.' + m
144 print(_module_path)
145 plg_lib = importlib.import_module(_module_path)
146 else:
147 # import dir is the dirpath for the config file
148 _module_dir = os.path.dirname(args.config)
149 _module_dir = _module_dir.split('/')
150 _module_path = _module_dir[0]
151 for m in _module_dir[1:]:
152 _module_path = _module_path + '.' + m
153 print(_module_path)
154 plg_lib = importlib.import_module(_module_path)
155
156 # set cudnn_benchmark
157 if cfg.get('cudnn_benchmark', False):
158 torch.backends.cudnn.benchmark = True
159
160 cfg.model.pretrained = None
161 # in case the test dataset is concatenated
162 samples_per_gpu = 1
163 if isinstance(cfg.data.test, dict):
164 cfg.data.test.test_mode = True
165 samples_per_gpu = cfg.data.test.pop('samples_per_gpu', 1)
166 if samples_per_gpu > 1:
167 # Replace 'ImageToTensor' to 'DefaultFormatBundle'
168 cfg.data.test.pipeline = replace_ImageToTensor(
169 cfg.data.test.pipeline)
170 elif isinstance(cfg.data.test, list):

Callers 1

test.pyFile · 0.70

Calls 5

build_dataloaderFunction · 0.90
custom_multi_gpu_testFunction · 0.90
format_resultsMethod · 0.80
evaluate_miouMethod · 0.80
parse_argsFunction · 0.70

Tested by

no test coverage detected