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