pkuxmq / Invertible-Image-Rescaling

[ECCV 2020, IJCV 2022] Invertible Image Rescaling
Apache License 2.0
627 stars 86 forks source link

Dosen't work with LQ mode #4

Open ajuanzju opened 4 years ago

ajuanzju commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

ajuanzju commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

get it. Thanks~~~~

inconst commented 4 years ago

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

pkuxmq commented 4 years ago

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 commented 3 years ago

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 commented 3 years ago

太感谢了。 如果我仅指定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,