Skip to content

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

Description

@Paul0M

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions