Python utils.preprocess_batch() Examples
The following are 7
code examples of utils.preprocess_batch().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
utils
, or try the search function
.
Example #1
Source File: main.py From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 | 6 votes |
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)
Example #2
Source File: main.py From training_results_v0.6 with Apache License 2.0 | 6 votes |
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)
Example #3
Source File: main.py From MXNet-Gluon-Style-Transfer with MIT License | 6 votes |
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)
Example #4
Source File: main.py From SNIPER-mxnet with Apache License 2.0 | 6 votes |
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)
Example #5
Source File: trainer.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 5 votes |
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}
Example #6
Source File: neural_style.py From fast-neural-style with MIT License | 5 votes |
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)
Example #7
Source File: trainer.py From cleverhans with MIT License | 5 votes |
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}