MCPcopy Index your code
hub / github.com/OpenGVLab/InternVL / main

Function main

segmentation/test.py:115–274  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

test.pyFile · 0.70

Calls 6

build_datasetFunction · 0.90
load_checkpointFunction · 0.85
updateMethod · 0.80
evaluateMethod · 0.80
parse_argsFunction · 0.70
init_distFunction · 0.50

Tested by

no test coverage detected