This repository contains an op-for-op PyTorch reimplementation of Designing a Practical Degradation Model for Deep Blind Image Super-Resolution .
- BSRGAN-PyTorch
Contains DIV2K, DIV8K, Flickr2K, OST, T91, Set5, Set14, BSDS100 and BSDS200, etc.
Please refer to README.md
in the data
directory for the method of making a dataset.
Both training and testing only need to modify the bsrnet_config.py
or bsrgan_config.py
file.
Modify the bsrgan_config.py
file.
- line 48:
g_model_arch_name
change tobsrgan_x4
. - line 60:
upscale_factor
change to4
. - line 62:
mode
change totest
. - line 64:
exp_name
change toBSRGAN_x4-Set5
. - line 118:
lr_dir
change tof"./data/Set5/LRbicx{upscale_factor}"
. - line 119:
gt_dir
change tof"./data/Set5/GTmod12"
. - line 121:
g_model_weights_path
change to./results/pretrained_models/BSRGAN_x4-DIV2K-6d507222.pth.tar
.
python3 test.py
Modify the bsrnet_config.py
file.
- line 48:
g_model_arch_name
change tobsrgan_x4
. - line 60:
upscale_factor
change to4
. - line 62:
mode
change totrain
. - line 64:
exp_name
change toBSRNet_x4-DIV2K
.
python3 train_bsrnet.py
Modify the bsrnet_config.py
file.
- line 48:
g_model_arch_name
change tobsrgan_x4
. - line 60:
upscale_factor
change to4
. - line 62:
mode
change totest
. - line 64:
exp_name
change toBSRNet_x4-DIV2K
. - line 74:
resume_g_model_weights_path
change to./samples/BSRNet_x4-DIV2K/g_epoch_xxx.pth.tar
. - line 118:
lr_dir
change tof"./data/Set5/LRbicx{upscale_factor}"
. - line 119:
gt_dir
change tof"./data/Set5/GTmod12"
.
python3 train_bsrnet.py
Modify the bsrgan_config.py
file.
- line 47:
d_model_arch_name
change todiscriminator_unet
. - line 48:
g_model_arch_name
change tobsrgan_x4
. - line 60:
upscale_factor
change to4
. - line 62:
mode
change totrain
. - line 64:
exp_name
change toBSRGAN_x4-DIV2K
.
python3 train_bsrgan.py
Modify the bsrgan_config.py
file.
- line 47:
d_model_arch_name
change todiscriminator_unet
. - line 48:
g_model_arch_name
change tobsrgan_x4
. - line 60:
upscale_factor
change to4
. - line 62:
mode
change totrain
. - line 64:
exp_name
change toBSRGAN_x4-DIV2K
. - line 83:
resume_d_model_weights_path
change to./samples/BSRGAN_x4-DIV2K/d_epoch_xxx.pth.tar
. - line 84:
resume_g_model_weights_path
change to./samples/BSRGAN_x4-DIV2K/g_epoch_xxx.pth.tar
. - line 118:
lr_dir
change tof"./data/Set5/LRbicx{upscale_factor}"
. - line 119:
gt_dir
change tof"./data/Set5/GTmod12"
.
python3 train_bsrgan.py
Source of original paper results: https://arxiv.org/pdf/2103.14006v2.pdf
In the following table, the psnr value in ()
indicates the result of the project, and -
indicates no test.
- RealSRSet
Model | Scale | NIQE |
---|---|---|
BSRNet | 2 | -(7.25) |
BSRGAN | 2 | -(6.39) |
BSRNet | 4 | -(8.06) |
BSRGAN | 4 | 5.60(5.50) |
# Download `BSRGAN_x4-DIV2K-6d507222.pth.tar` weights to `./results/pretrained_models`
# More detail see `README.md<Download weights>`
python3 ./inference.py
Input:
Output:
Build `bsrgan_x4` model successfully.
Load `bsrgan_x4` model weights `./results/pretrained_models/BSRGAN_x4-DIV2K-6d507222.pth.tar` successfully.
SR image save to `./figure/oldphoto2_sr.png`
If you find a bug, create a GitHub issue, or even better, submit a pull request. Similarly, if you have questions, simply post them as GitHub issues.
I look forward to seeing what the community does with these models!
Zhang, Kai and Liang, Jingyun and Van Gool, Luc and Timofte, Radu
Abstract
It is widely acknowledged that single image super-resolution (SISR) methods would not perform well if the assumed
degradation model deviates from those in real images. Although several degradation models take additional factors into
consideration, such as blur, they are still not effective enough to cover the diverse degradations of real images. To
address this issue, this paper proposes to design a more complex but practical degradation model that consists of
randomly shuffled blur, downsampling and noise degradations. Specifically, the blur is approximated by two convolutions
with isotropic and anisotropic Gaussian kernels; the downsampling is randomly chosen from nearest, bilinear and bicubic
interpolations; the noise is synthesized by adding Gaussian noise with different noise levels, adopting JPEG compression
with different quality factors, and generating processed camera sensor noise via reverse-forward camera image signal
processing (ISP) pipeline model and RAW image noise model. To verify the effectiveness of the new degradation model, we
have trained a deep blind ESRGAN super-resolver and then applied it to super-resolve both synthetic and real images with
diverse degradations. The experimental results demonstrate that the new degradation model can help to significantly
improve the practicability of deep super-resolvers, thus providing a powerful alternative solution for real SISR
applications.
@inproceedings{zhang2021designing,
title={Designing a Practical Degradation Model for Deep Blind Image Super-Resolution},
author={Zhang, Kai and Liang, Jingyun and Van Gool, Luc and Timofte, Radu},
booktitle={IEEE International Conference on Computer Vision},
pages={4791--4800},
year={2021}
}