当前位置: 首页>>代码示例>>Python>>正文


Python utils.preprocess_batch方法代码示例

本文整理汇总了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) 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:18,代码来源:main.py

示例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) 
开发者ID:StacyYang,项目名称:MXNet-Gluon-Style-Transfer,代码行数:18,代码来源:main.py

示例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) 
开发者ID:mahyarnajibi,项目名称:SNIPER-mxnet,代码行数:18,代码来源:main.py

示例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} 
开发者ID:StephanZheng,项目名称:neural-fingerprinting,代码行数:13,代码来源:trainer.py

示例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) 
开发者ID:abhiskk,项目名称:fast-neural-style,代码行数:17,代码来源:neural_style.py

示例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} 
开发者ID:tensorflow,项目名称:cleverhans,代码行数:13,代码来源:trainer.py


注:本文中的utils.preprocess_batch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。