本文整理汇总了Python中utils.preprocess_batch方法的典型用法代码示例。如果您正苦于以下问题:Python utils.preprocess_batch方法的具体用法?Python utils.preprocess_batch怎么用?Python utils.preprocess_batch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils.preprocess_batch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: evaluate
# 需要导入模块: import utils [as 别名]
# 或者: from utils import preprocess_batch [as 别名]
def evaluate(args):
if args.cuda:
ctx = mx.gpu(0)
else:
ctx = mx.cpu(0)
# images
content_image = utils.tensor_load_rgbimage(args.content_image,ctx, size=args.content_size, keep_asp=True)
style_image = utils.tensor_load_rgbimage(args.style_image, ctx, size=args.style_size)
style_image = utils.preprocess_batch(style_image)
# model
style_model = net.Net(ngf=args.ngf)
style_model.load_parameters(args.model, ctx=ctx)
# forward
style_model.set_target(style_image)
output = style_model(content_image)
utils.tensor_save_bgrimage(output[0], args.output_image, args.cuda)
示例2: evaluate
# 需要导入模块: import utils [as 别名]
# 或者: from utils import preprocess_batch [as 别名]
def evaluate(args):
if args.cuda:
ctx = mx.gpu(0)
else:
ctx = mx.cpu(0)
# images
content_image = utils.tensor_load_rgbimage(args.content_image,ctx, size=args.content_size, keep_asp=True)
style_image = utils.tensor_load_rgbimage(args.style_image, ctx, size=args.style_size)
style_image = utils.preprocess_batch(style_image)
# model
style_model = net.Net(ngf=args.ngf)
style_model.load_params(args.model, ctx=ctx)
# forward
style_model.set_target(style_image)
output = style_model(content_image)
utils.tensor_save_bgrimage(output[0], args.output_image, args.cuda)
示例3: evaluate
# 需要导入模块: import utils [as 别名]
# 或者: from utils import preprocess_batch [as 别名]
def evaluate(args):
if args.cuda:
ctx = mx.gpu(0)
else:
ctx = mx.cpu(0)
# images
content_image = utils.tensor_load_rgbimage(args.content_image,ctx, size=args.content_size, keep_asp=True)
style_image = utils.tensor_load_rgbimage(args.style_image, ctx, size=args.style_size)
style_image = utils.preprocess_batch(style_image)
# model
style_model = net.Net(ngf=args.ngf)
style_model.load_params(args.model, ctx=ctx)
# forward
style_model.setTarget(style_image)
output = style_model(content_image)
utils.tensor_save_bgrimage(output[0], args.output_image, args.cuda)
示例4: _init_inputs
# 需要导入模块: import utils [as 别名]
# 或者: from utils import preprocess_batch [as 别名]
def _init_inputs(self):
preproc_func = self.preproc_func
input_shape = self.input_shape
# Define input TF placeholder
with tf.device('/gpu:0'):
x_pre = tf.placeholder(tf.float32, shape=input_shape, name='x')
x = preprocess_batch(x_pre, preproc_func)
y = tf.placeholder(tf.float32, shape=(self.batch_size, 10),
name='y')
self.g0_inputs = {'x_pre': x_pre, 'x': x, 'y': y}
示例5: stylize
# 需要导入模块: import utils [as 别名]
# 或者: from utils import preprocess_batch [as 别名]
def stylize(args):
content_image = utils.tensor_load_rgbimage(args.content_image, scale=args.content_scale)
content_image = content_image.unsqueeze(0)
if args.cuda:
content_image = content_image.cuda()
content_image = Variable(utils.preprocess_batch(content_image), volatile=True)
style_model = TransformerNet()
style_model.load_state_dict(torch.load(args.model))
if args.cuda:
style_model.cuda()
output = style_model(content_image)
utils.tensor_save_bgrimage(output.data[0], args.output_image, args.cuda)
示例6: _init_inputs
# 需要导入模块: import utils [as 别名]
# 或者: from utils import preprocess_batch [as 别名]
def _init_inputs(self):
preproc_func = self.preproc_func
input_shape = self.input_shape
# Define input TF placeholder
with tf.device('/gpu:0'):
x_pre = tf.placeholder(tf.float32, shape=input_shape, name='x')
x = preprocess_batch(x_pre, preproc_func)
y = tf.placeholder(tf.float32, shape=(self.batch_size, 10),
name='y')
self.g0_inputs = {'x_pre': x_pre, 'x': x, 'y': y}