本文整理汇总了Python中opts.parse_opts方法的典型用法代码示例。如果您正苦于以下问题:Python opts.parse_opts方法的具体用法?Python opts.parse_opts怎么用?Python opts.parse_opts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opts
的用法示例。
在下文中一共展示了opts.parse_opts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_opt
# 需要导入模块: import opts [as 别名]
# 或者: from opts import parse_opts [as 别名]
def get_opt():
opt = parse_opts()
if opt.root_path is not None:
opt.video_path = opt.root_path / opt.video_path
opt.annotation_path = opt.root_path / opt.annotation_path
opt.result_path = opt.root_path / opt.result_path
if opt.resume_path is not None:
opt.resume_path = opt.root_path / opt.resume_path
if opt.pretrain_path is not None:
opt.pretrain_path = opt.root_path / opt.pretrain_path
if opt.pretrain_path is not None:
opt.n_finetune_classes = opt.n_classes
opt.n_classes = opt.n_pretrain_classes
if opt.output_topk <= 0:
opt.output_topk = opt.n_classes
if opt.inference_batch_size == 0:
opt.inference_batch_size = opt.batch_size
opt.arch = '{}-{}'.format(opt.model, opt.model_depth)
opt.begin_epoch = 1
opt.mean, opt.std = get_mean_std(opt.value_scale, dataset=opt.mean_dataset)
opt.n_input_channels = 3
if opt.input_type == 'flow':
opt.n_input_channels = 2
opt.mean = opt.mean[:2]
opt.std = opt.std[:2]
if opt.distributed:
opt.dist_rank = int(os.environ["OMPI_COMM_WORLD_RANK"])
if opt.dist_rank == 0:
print(opt)
with (opt.result_path / 'opts.json').open('w') as opt_file:
json.dump(vars(opt), opt_file, default=json_serial)
else:
print(opt)
with (opt.result_path / 'opts.json').open('w') as opt_file:
json.dump(vars(opt), opt_file, default=json_serial)
return opt