本文整理汇总了Python中models.get_option_setter方法的典型用法代码示例。如果您正苦于以下问题:Python models.get_option_setter方法的具体用法?Python models.get_option_setter怎么用?Python models.get_option_setter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models
的用法示例。
在下文中一共展示了models.get_option_setter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gather_options
# 需要导入模块: import models [as 别名]
# 或者: from models import get_option_setter [as 别名]
def gather_options(self):
# initialize parser with basic options
if not self.initialized:
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser = self.initialize(parser)
# get the basic options
opt, _ = parser.parse_known_args()
# modify model-related parser options
model_name = opt.model
model_option_setter = models.get_option_setter(model_name)
parser = model_option_setter(parser, self.isTrain)
opt, _ = parser.parse_known_args() # parse again with the new defaults
# modify dataset-related parser options
dataset_name = opt.dataset_mode
dataset_option_setter = data.get_option_setter(dataset_name)
parser = dataset_option_setter(parser, self.isTrain)
self.parser = parser
return parser.parse_args()
示例2: gather_options
# 需要导入模块: import models [as 别名]
# 或者: from models import get_option_setter [as 别名]
def gather_options(self):
# get the basic options
opt, _ = self.parser.parse_known_args()
# load task module and task-specific options
task_name = opt.task
task_options = importlib.import_module("{}.options.task_options".format(task_name)) # must be defined in each task folder
self.parser = argparse.ArgumentParser(parents=[self.parser, task_options.TaskOptions().parser])
opt, _ = self.parser.parse_known_args()
# modify model-related parser options
model_name = opt.model
model_option_setter = models.get_option_setter(model_name, task_name)
parser = model_option_setter(self.parser, self.is_train)
opt, _ = parser.parse_known_args() # parse again with the new defaults
# modify dataset-related parser options fsldkn
dataset_name = opt.dataset_name
print(dataset_name, task_name)
dataset_option_setter = data.get_option_setter(dataset_name, task_name)
parser = dataset_option_setter(parser, self.is_train)
self.parser = parser
return parser.parse_args()
示例3: gather_options
# 需要导入模块: import models [as 别名]
# 或者: from models import get_option_setter [as 别名]
def gather_options(self):
"""Initialize our parser with basic options(only once).
Add additional model-specific and dataset-specific options.
These options are defined in the <modify_commandline_options> function
in model and dataset classes.
"""
if not self.initialized: # check if it has been initialized
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser = self.initialize(parser)
# get the basic options
opt, _ = parser.parse_known_args()
# modify model-related parser options
model_name = opt.model
model_option_setter = models.get_option_setter(model_name)
parser = model_option_setter(parser, self.isTrain)
opt, _ = parser.parse_known_args() # parse again with new defaults
# modify dataset-related parser options
dataset_name = opt.dataset_mode
dataset_option_setter = data.get_option_setter(dataset_name)
parser = dataset_option_setter(parser, self.isTrain)
# save and return the parser
self.parser = parser
return parser.parse_args()