Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RGB and BGR Mistake with optim in main.py? #6

Open
Paul0M opened this issue Jun 26, 2018 · 0 comments
Open

RGB and BGR Mistake with optim in main.py? #6

Paul0M opened this issue Jun 26, 2018 · 0 comments

Comments

@Paul0M
Copy link

Paul0M commented Jun 26, 2018

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant