MCPcopy
hub / github.com/hustvl/Vim / main

Function main

seg/test.py:120–319  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

118
119
120def main():
121 args = parse_args()
122 assert args.out or args.eval or args.format_only or args.show \
123 or args.show_dir, \
124 ('Please specify at least one operation (save/eval/format/show the '
125 'results / save the results) with the argument "--out", "--eval"'
126 ', "--format-only", "--show" or "--show-dir"')
127
128 if args.eval and args.format_only:
129 raise ValueError('--eval and --format_only cannot be both specified')
130
131 if args.out is not None and not args.out.endswith(('.pkl', '.pickle')):
132 raise ValueError('The output file must be a pkl file.')
133
134 cfg = mmcv.Config.fromfile(args.config)
135 print("cfg: ", cfg)
136 if args.cfg_options is not None:
137 cfg.merge_from_dict(args.cfg_options)
138
139 # set multi-process settings
140 setup_multi_processes(cfg)
141
142 # set cudnn_benchmark
143 if cfg.get('cudnn_benchmark', False):
144 torch.backends.cudnn.benchmark = True
145 if args.aug_test:
146 # hard code index
147 cfg.data.test.pipeline[1].img_ratios = [
148 0.5, 0.75, 1.0, 1.25, 1.5, 1.75
149 ]
150 cfg.data.test.pipeline[1].flip = True
151 cfg.model.pretrained = None
152 cfg.data.test.test_mode = True
153
154 if args.gpu_id is not None:
155 cfg.gpu_ids = [args.gpu_id]
156
157 # init distributed env first, since logger depends on the dist info.
158 if args.launcher == 'none':
159 cfg.gpu_ids = [args.gpu_id]
160 distributed = False
161 if len(cfg.gpu_ids) > 1:
162 warnings.warn(f'The gpu-ids is reset from {cfg.gpu_ids} to '
163 f'{cfg.gpu_ids[0:1]} to avoid potential error in '
164 'non-distribute testing time.')
165 cfg.gpu_ids = cfg.gpu_ids[0:1]
166 else:
167 distributed = True
168 init_dist(args.launcher, **cfg.dist_params)
169
170 rank, _ = get_dist_info()
171 # allows not to create
172 if args.work_dir is not None and rank == 0:
173 mmcv.mkdir_or_exist(osp.abspath(args.work_dir))
174 timestamp = time.strftime('%Y%m%d_%H%M%S', time.localtime())
175 if args.aug_test:
176 json_file = osp.join(args.work_dir,
177 f'eval_multi_scale_{timestamp}.json')

Callers 1

test.pyFile · 0.70

Calls 8

build_datasetFunction · 0.90
printFunction · 0.85
load_checkpointFunction · 0.85
dumpMethod · 0.80
parse_argsFunction · 0.70
getMethod · 0.45
updateMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected