Closed tony2278 closed 6 years ago
Hi,
sorry I don't have easy to read code at hand and I'm too busy to release such formal demo, but I can provide following code for experimental test, assuming you want to upscale an grayscale image by a factor of 2 using MoePhoto/official/super-resolution/a2-symbol.json and a2-0000.params:
import os
os.environ['MXNET_CUDNN_AUTOTUNE_DEFAULT'] = '0' # 0: False 1: Default 2: Full
import mxnet as mx
from collections import namedtuple
# load image
image = ... # assume an image with shape (3, 64, 64) is loaded. The range of the data is in [0, 1].
# params
model_filename = 'a2' # place the two files in the same folder of this script
epoch = 0
is_rgb_model = False
_, h, w = image.shape
# load MXNet model
sym, arg_params, aux_params = mx.model.load_checkpoint(model_filename, epoch)
ctx = mx.gpu(0) # mx.cpu()
data_shape = (1, 3 if is_rgb_model else 1, h, w)
model = mx.mod.Module(symbol=sym, context=ctx)
model.bind(for_training=False, data_shapes=[('data', data_shape)])
model.set_params(arg_params, aux_params, allow_missing=False)
# run the model
Batch = namedtuple('Batch', ['data'])
image = mx.nd.array(image)
model.forward(Batch([h_in]), is_train=False)
output_image = model.get_outputs()[0].asnumpy()
# then you can save 'output_image' to your disk
Or if you are an user of VapourSynth, you can refer to demo at muvsfunc. If you are not familiar with that, just ignore it and read example at muvsfunc's function or type in this issue.
I've prepared a demo python code, that may be used for some of the models out of the box. Other models require reading the original code. Check out the sample demo.
Thank you very much!
best wishes
王承陶 86 13676089376 Sent from my iPhone
On Jun 25, 2019, at 02:57, sa-mustafa notifications@github.com wrote:
I've prepared a demo python code, that may be used for some of the models out of the box. Other models require reading the original code. Check out the [sample demo] (https://github.com/sa-mustafa/super-resolution-mxnet).
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Would you please release one demo.py about how to use models?