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

Dosen't work with LQ mode #4

Open
ajuanzju opened this issue Jul 21, 2020 · 10 comments
Open

Dosen't work with LQ mode #4

ajuanzju opened this issue Jul 21, 2020 · 10 comments

Comments

@ajuanzju
Copy link

Hi @pkuxmq
Thanks for your amazing work.
I am trying to run the test code with LQ mode, ie. merely low resolution images are provided. it seems that this mode hasn't been tested, say, LQ_dataset is not defined. Could you please update your code later?

Thanks,
Lei

@pkuxmq
Copy link
Owner

pkuxmq commented Jul 27, 2020

Thanks for pointing out this. I have modified the code, and please use 'LR' instead of 'LQ' in this mode to create dataset. Thanks.

@ajuanzju
Copy link
Author

thanks for your update~~~
I resync with the latest code, but it still doesn't work. The error shows:
assert self.paths_LR, 'Error: LR paths are empty.'
AssertionError: Error: LR paths are empty.

@pkuxmq
Copy link
Owner

pkuxmq commented Jul 28, 2020

Sorry about it. I have updated the code. Please still use 'LQ' now. Thanks!

@ajuanzju
Copy link
Author

thank you so much.
If I only specify LQ path, which, I think, is the real case that only low quality image is provided, then current code doesn't handle this case.
error message shows that in current version, GT data is required in IRN_model.
./Invertible-Image-Rescaling/codes/models/IRN_model.py", line 83, in feed_data
self.real_H = data['GT'].to(self.device) # GT
KeyError: 'GT'

@pkuxmq
Copy link
Owner

pkuxmq commented Jul 28, 2020

Image rescaling is a different task from super-resolution (see 'Difference from SR' in the paper). IRN downscales HR images and reconstruct them from the downscaled LR images, while the ultimate goal of super-resolution is to upscale arbitrary LR images. So in our test code, we only need HR images to verify the performance.
If you want to test with only downscaled images, you may modified the test.py, do not use model.feed_data() and model.test(), but use model.downscale() or model.upscale() functions. Details please refer to 'models/IRN_model.py'

@ajuanzju
Copy link
Author

get it.
Thanks~~~~

@inconst
Copy link

inconst commented Jul 28, 2020

@pkuxmq Have you tested how IRN performs on just super resolution task (i.e. upscale arbitrary LR image)?

@pkuxmq
Copy link
Owner

pkuxmq commented Jul 30, 2020

If we just use the architecture of IRN for paired training of bicubic-downscaled LR images and HR images (latent variable z as padding 0), which is the setting of many sr methods, the performance is not as good as them. Reasons include that our invertible architecture is not mainly designed for prior learning, and the parameters are fewer. The improvement of IRN comes from our invertible modeling for downscaling and upscaling.

@peiyaoooo
Copy link

peiyaoooo commented Sep 20, 2020

thank you so much.
If I only specify LQ path, which, I think, is the real case that only low quality image is provided, then current code doesn't handle this case.
error message shows that in current version, GT data is required in IRN_model.
./Invertible-Image-Rescaling/codes/models/IRN_model.py", line 83, in feed_data
self.real_H = data['GT'].to(self.device) # GT
KeyError: 'GT'

Hi, I successfully test for just super resolution task with bicubic downsampled LR images. Just provide my test code for reference.
in the test option config:
name: val_DIV2K mode: LQ dataroot_LQ: ./DIV2K_valid_bicubic_LR

in the test.py:
after Line 55, insert
` img_path = data['LQ_path'][0]
img_name = osp.splitext(osp.basename(img_path))[0]

    output_img = model.upscale(data['LQ'].cuda(),4).detach()[0].float().cpu()
    sr_img = util.tensor2img(output_img)

    # save images
    suffix = opt['suffix']
    if suffix:
        save_img_path = osp.join(dataset_dir, img_name + suffix + '.png')
    else:
        save_img_path = osp.join(dataset_dir, img_name + '.png')
    util.save_img(sr_img, save_img_path)`

and comment following codes. Then you could save the fake-HR images for quantitative measurement.

At last, thanks for the author's amazing work @pkuxmq .

@sym1998
Copy link

sym1998 commented Apr 10, 2021

太感谢了。
如果我仅指定LQ路径(我认为这是仅提供低质量图像的真实情况),则当前代码无法处理这种情况。
错误消息表明,在当前版本中,IRN_model中需要GT数据。
./Invertible-Image-Rescaling/codes/models/IRN_model.py“,第83行,位于feed_data
self.real_H = data ['GT']。to(self.device)#GT KeyError
:'GT'

嗨,我成功地使用双三次降采样的LR图像测试了超分辨率任务。请提供我的测试代码以供参考。
在测试选项配置中:
name: val_DIV2K mode: LQ dataroot_LQ: ./DIV2K_valid_bicubic_LR

在test.py中:
在第55行之后,插入
`img_path = data ['LQ_path'] [0]
img_name = osp.splitext(osp.basename(img_path))[0]

    output_img = model.upscale(data['LQ'].cuda(),4).detach()[0].float().cpu()
    sr_img = util.tensor2img(output_img)

    # save images
    suffix = opt['suffix']
    if suffix:
        save_img_path = osp.join(dataset_dir, img_name + suffix + '.png')
    else:
        save_img_path = osp.join(dataset_dir, img_name + '.png')
    util.save_img(sr_img, save_img_path)`

并注释以下代码。然后,您可以保存伪造的HR图像以进行定量测量。

最后,感谢作者的出色工作@pkuxmq
Thank you very much for the code of Dashen, but where is the output image saved? Again, I would like to ask if you have continued to write the code to calculate PSNR. According to your change, you can test whether the trained network can improve the quality of the image. It looks clearer. Thank you very much for your reply,

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

5 participants