本文整理匯總了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