MXNet-Gluon-Style-Transfer icon indicating copy to clipboard operation
MXNet-Gluon-Style-Transfer copied to clipboard

RGB and BGR Mistake with optim in main.py?

Open Paul0M opened this issue 6 years ago • 0 comments

Line 145-148 in main.py I think content_image is obtained in RBG fomat. However, utils.subtract_imagenet_mean_preprocess_batch take img in BGR fomat. Is that right?

#main.py
    content_image = utils.tensor_load_rgbimage(args.content_image,ctx, size=args.content_size, keep_asp=True)
    content_image = utils.subtract_imagenet_mean_preprocess_batch(content_image)
    style_image = utils.tensor_load_rgbimage(args.style_image, ctx, size=args.style_size)
    style_image = utils.subtract_imagenet_mean_preprocess_batch(style_image)

#utils.py
def subtract_imagenet_mean_preprocess_batch(batch):
    """Subtract ImageNet mean pixel-wise from a BGR image."""
    batch = F.swapaxes(batch,0, 1)
    (r, g, b) = F.split(batch, num_outputs=3, axis=0)

And I think a better understanding way to transform RGB to BGR or vise versa is to use: F.swapaxes(batch,0, 1) is not that obvious.

rgb_img = bgr_img[::-1,,] # C*H*W
bgr_img = rgb_img[::-1,,] # C*H*W

Paul0M avatar Jun 26 '18 09:06 Paul0M