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

Upsample LR images with F.interpolate will cause color changes #10

Closed
Shaw95 opened this issue Oct 30, 2020 · 1 comment
Closed

Upsample LR images with F.interpolate will cause color changes #10

Shaw95 opened this issue Oct 30, 2020 · 1 comment

Comments

@Shaw95
Copy link

Shaw95 commented Oct 30, 2020

Hi, in your code, you seem to use F.interpolate to upsample the LR image to match the resolution of HR in order to apply Cutblur. But have you checked the upsampled image? Cause when I do it in your way, I will get an image with server color shift, and that should not be the case in your paper.

Due to some unkown reasons, I cannot upload the images, but I can share with you my testing code.

HR = io.imread('data/DIV2K/DIV2K_train_HR/0159.png')
LR = io.imread('data/DIV2K/DIV2K_train_LR_bicubic/X4/0159x4.png')
HR_plot = HR[0:400, 200:600]
LR_plot = LR[0:100, 50:150]
LR_tensor = im2tensor(LR_plot).unsqueeze(0)
LR_plot = F.interpolate(LR_tensor, scale_factor=4, mode="nearest")[0].numpy().transpose(1,2,0)

f, axarr = plt.subplots(1, 2, figsize=(10, 5))
axarr[0].imshow(LR_plot)
axarr[1].imshow(HR_plot)

Hope you can try this, and tell me where I did wrong.

Thank you so much!

@nmhkahn
Copy link
Collaborator

nmhkahn commented Oct 30, 2020

I think that you miss the .byte() to change dtype from float to uint. For example, print(LR_plot.max(), HR_plot.max()) says 255.0, 255 which can cause color shift of LR_plot since float type of image has to be in range [0.0, 1.0].

LR_plot = F.interpolate(LR_tensor, scale_factor=4, mode="nearest")[0].byte().numpy().transpose(1,2,0)

will work.

@nmhkahn nmhkahn closed this as completed Dec 18, 2020
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

2 participants