MCPcopy Create free account
hub / github.com/AutonomousVehicleLaboratory/SemVecNet / main

Function main

SemVecNet/tools/test.py:110–258  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

test.pyFile · 0.70

Calls 8

build_datasetFunction · 0.90
build_dataloaderFunction · 0.90
build_modelFunction · 0.90
custom_multi_gpu_testFunction · 0.90
parse_argsFunction · 0.70
fuse_conv_bnFunction · 0.50
format_resultsMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected