本文整理汇总了Python中options.test_options.TestOptions方法的典型用法代码示例。如果您正苦于以下问题:Python test_options.TestOptions方法的具体用法?Python test_options.TestOptions怎么用?Python test_options.TestOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类options.test_options
的用法示例。
在下文中一共展示了test_options.TestOptions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from options import test_options [as 别名]
# 或者: from options.test_options import TestOptions [as 别名]
def main():
opt = TestOptions().parse()
opt.no_flip = True
opt.batchSize = 1
data_loader = CreateDataLoader(opt)
model = SingleGAN()
model.initialize(opt)
web_dir = os.path.join(opt.results_dir, 'test')
webpage = html.HTML(web_dir, 'task {}'.format(opt.name))
for i, data in enumerate(islice(data_loader, opt.how_many)):
print('process input image %3.3d/%3.3d' % (i, opt.how_many))
all_images, all_names = model.translation(data)
img_path = 'image%3.3i' % i
save_images(webpage, all_images, all_names, img_path, None, width=opt.fineSize)
webpage.save()
示例2: run_test
# 需要导入模块: from options import test_options [as 别名]
# 或者: from options.test_options import TestOptions [as 别名]
def run_test(epoch=-1):
print('Running Test')
opt = TestOptions().parse()
opt.serial_batches = True # no shuffle
dataset = DataLoader(opt)
model = create_model(opt)
writer = Writer(opt)
# test
writer.reset_counter()
for i, data in enumerate(dataset):
model.set_input(data)
ncorrect, nexamples = model.test()
writer.update_counter(ncorrect, nexamples)
writer.print_acc(epoch, writer.acc)
return writer.acc
示例3: main
# 需要导入模块: from options import test_options [as 别名]
# 或者: from options.test_options import TestOptions [as 别名]
def main():
opt = TestOptions().parse()
opt.is_flip = False
opt.batchSize = 1
data_loader = CreateDataLoader(opt)
model = create_model(opt)
web_dir = os.path.join(opt.results_dir, 'test')
webpage = html.HTML(web_dir, 'task {}'.format(opt.exp_name))
for i, data in enumerate(islice(data_loader, opt.how_many)):
print('process input image %3.3d/%3.3d' % (i, opt.how_many))
results = model.translation(data)
img_path = 'image%3.3i' % i
save_images(webpage, results, img_path, None, width=opt.fine_size)
webpage.save()
示例4: main
# 需要导入模块: from options import test_options [as 别名]
# 或者: from options.test_options import TestOptions [as 别名]
def main():
opt = TestOptions().parse()
if not os.path.isdir(opt.output_dir):
os.makedirs(opt.output_dir)
morph = MorphFacesInTheWild(opt)
image_path = opt.input_path
expression = np.random.uniform(0, 1, opt.cond_nc)
morph.morph_file(image_path, expression)
示例5: prepare_options
# 需要导入模块: from options import test_options [as 别名]
# 或者: from options.test_options import TestOptions [as 别名]
def prepare_options(self, path):
sys.path.append(path)
from options.test_options import TestOptions
from models.models import create_model
sys.argv = [sys.argv[0]]
os.mkdir(self.input_file_grp+"/test_A/")
opt = TestOptions().parse(save=False)
opt.nThreads = 1 # test code only supports nThreads = 1
opt.batchSize = 1 # test code only supports batchSize = 1
opt.serial_batches = True # no shuffle
opt.no_flip = True # no flip
opt.rood_dir = self.input_file_grp # make into proper path
opt.checkpoints_dir = self.parameter['checkpoint_dir']
opt.dataroot = self.input_file_grp
opt.name = self.parameter['model_name']
opt.label_nc = 0
opt.no_instance = True
opt.resize_or_crop = self.parameter['imgresize']
opt.n_blocks_global = 10
opt.n_local_enhancers = 2
opt.gpu_ids = [self.parameter['gpu_id']]
opt.loadSize = self.parameter['resizeHeight']
opt.fineSize = self.parameter['resizeWidth']
model = create_model(opt)
return opt, model