Designing a Practical Degradation Model for Deep Blind Image Super-Resolution (ICCV, 2021) (PyTorch) - We released the training code!

Overview

Designing a Practical Degradation Model for Deep Blind Image Super-Resolution

visitors

Kai Zhang, Jingyun Liang, Luc Van Gool, Radu Timofte
Computer Vision Lab, ETH Zurich, Switzerland

[Paper] [Code] [Training Code]

Our work is the beginning rather than the end of real image super-resolution.


  • News (2021-08-31): We upload the training code.
  • News (2021-08-24): We upload the BSRGAN degradation model.
from utils import utils_blindsr as blindsr
img_lq, img_hq = blindsr.degradation_bsrgan(img, sf=4, lq_patchsize=72)
  • News (2021-07-23): After rejection by CVPR 2021, our paper is accepted by ICCV 2021. For the sake of fairness, we will not update the trained models in our camera-ready version. However, we may updata the trained models in github.
  • News (2021-05-18): Add trained BSRGAN model for scale factor 2.
  • News (2021-04): Our degradation model for face image enhancement: https://github.com/vvictoryuki/BSRGAN_implementation

Training

  1. Download KAIR: git clone https://github.com/cszn/KAIR.git
  2. Put your training high-quality images into trainsets/trainH or set "dataroot_H": "trainsets/trainH"
  3. Train BSRNet
    1. Modify train_bsrgan_x4_psnr.json e.g., "gpu_ids": [0], "dataloader_batch_size": 4
    2. Training with DataParallel
    python main_train_psnr.py --opt options/train_bsrgan_x4_psnr.json
    1. Training with DistributedDataParallel - 4 GPUs
    python -m torch.distributed.launch --nproc_per_node=4 --master_port=1234 main_train_psnr.py --opt options/train_bsrgan_x4_psnr.json  --dist True
  4. Train BSRGAN
    1. Put BSRNet model (e.g., '400000_G.pth') into superresolution/bsrgan_x4_gan/models
    2. Modify train_bsrgan_x4_gan.json e.g., "gpu_ids": [0], "dataloader_batch_size": 4
    3. Training with DataParallel
    python main_train_gan.py --opt options/train_bsrgan_x4_gan.json
    1. Training with DistributedDataParallel - 4 GPUs
    python -m torch.distributed.launch --nproc_per_node=4 --master_port=1234 main_train_gan.py --opt options/train_bsrgan_x4_gan.json  --dist True
  5. Test BSRGAN model 'xxxxxx_E.pth' by modified main_test_bsrgan.py
    1. 'xxxxxx_E.pth' is more stable than 'xxxxxx_G.pth'

Some visual examples: oldphoto2; butterfly; comic; oldphoto3; oldphoto6; comic_01; comic_03; comic_04


Testing code

Main idea

Design a new degradation model to synthesize LR images for training:

  • 1) Make the blur, downsampling and noise more practical
    • Blur: two convolutions with isotropic and anisotropic Gaussian kernels from both the HR space and LR space
    • Downsampling: nearest, bilinear, bicubic, down-up-sampling
    • Noise: Gaussian noise, JPEG compression noise, processed camera sensor noise
  • 2) Degradation shuffle: instead of using the commonly-used blur/downsampling/noise-addition pipeline, we perform randomly shuffled degradations to synthesize LR images

Some notes on the proposed degradation model:

  • The degradation model is mainly designed to synthesize degraded LR images. Its most direct application is to train a deep blind super-resolver with paired LR/HR images. In particular, the degradation model can be performed on a large dataset of HR images to produce unlimited perfectly aligned training images, which typically do not suffer from the limited data issue of laboriously collected paired data and the misalignment issue of unpaired training data.

  • The degradation model tends to be unsuited to model a degraded LR image as it involves too many degradation parameters and also adopts a random shuffle strategy.

  • The degradation model can produce some degradation cases that rarely happen in real-world scenarios, while this can still be expected to improve the generalization ability of the trained deep blind super-resolver.

  • A DNN with large capacity has the ability to handle different degradations via a single model. This has been validated multiple times. For example, DnCNN is able to handle SISR with different scale factors, JPEG compression deblocking with different quality factors and denoising for a wide range of noise levels, while still having a performance comparable to VDSR for SISR. It is worth noting that even when the super-resolver reduces the performance for unrealistic bicubic downsampling, it is still a preferred choice for real SISR.

  • One can conveniently modify the degradation model by changing the degradation parameter settings and adding more reasonable degradation types to improve the practicability for a certain application.

Comparison

These no-reference IQA metrics, i.e., NIQE, NRQM and PI, do not always match perceptual visual quality [1] and the IQA metric should be updated with new SISR methods [2]. We further argue that the IQA metric for SISR should also be updated with new image degradation types, which we leave for future work.

[1] "NTIRE 2020 challenge on real-world image super-resolution: Methods and results." CVPRW, 2020.
[2] "PIPAL: a large-scale image quality assessment dataset for perceptual image restoration." ECCV, 2020.

More visual results on RealSRSet dataset

Left: real images | Right: super-resolved images with scale factor 4

Visual results on DPED dataset

Without using any prior information of DPED dataset for training, our BSRGAN still performs well.

Citation

@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={arxiv},
  year={2021}
}

Acknowledgments

This work was partly supported by the ETH Zurich Fund (OK), a Huawei Technologies Oy (Finland) project, and an Amazon AWS grant.

Comments
  • Question about Gaussain Noise

    Question about Gaussain Noise

    Hi, thank you for your work. I have a question about the degradation. For the Gaussian noise, in the general case, why you only set L=noise_level2/255.0 (https://github.com/cszn/BSRGAN/blob/main/utils/utils_blindsr.py#L371) instead of generating a random value between noise_level1 and noise_level2, like for the grayscale and color Gaussian noises?

    Thanks!

    opened by ShijianXu 5
  • What does 'axis length' mean?

    What does 'axis length' mean?

    As section 3.1 of your paper said, the length of each axis for scale factors 2 and 4 uniformly from [0.5, 6] and [0.5, 8], respectively. However, I am not sure what does that mean. In my understanding, gaussian kernel needs only 1. kernel size, 2. eigen-vals, and 3. rotation angle.

    I will appreciate it if you can reply at any time you are available. Thank you!

    opened by AlanZhang1995 4
  • Possible bug in degradation_bsrgan

    Possible bug in degradation_bsrgan

    It is possible that dimensions are permutated in the cropping operation in degradation_bsrgan_plus, degradation_bsrgan functions in 541, 450 lines.

    It should be img = img.copy()[:h1 - h1 % sf, :w1 - w1 % sf, ...] # mod crop instead of img = img.copy()[:w1 - w1 % sf, :h1 - h1 % sf, ...] # mod crop

    opened by DanilKonon 3
  • 如何制作自己的训练集

    如何制作自己的训练集

    from utils import utils_blindsr as blindsr
    img_lq, img_hq = blindsr.degradation_bsrgan(img, sf=4, lq_patchsize=72)
    

    但是报错,这这这咋办 h1, w1 = img.shape[:2] AttributeError: 'str' object has no attribute 'shape'

    opened by tongchangD 3
  • Question about the utils_blindsr

    Question about the utils_blindsr

    why did you write the "util.imresize_np" function? Is there a difference between cv2.resize and util.imresize_np?

    ..... if sf == 4 and random.random() < scale2_prob: # downsample1 if np.random.rand() < 0.5: img = cv2.resize(img, (int(1/2img.shape[1]), int(1/2img.shape[0])), interpolation=random.choice([1,2,3])) else: img = util.imresize_np(img, 1/2, True) img = np.clip(img, 0.0, 1.0) sf = 2 ......

    opened by FengMu1995 2
  • 3x3 and 5x5 Gaussian kernel sizes?

    3x3 and 5x5 Gaussian kernel sizes?

    Hi @cszn,

    Great work on the paper, the results are really fascinating.

    Is there any reason why you haven't included 3x3 and 5x5 Gaussian blur kernels? They seem to be pretty standard so I was wondering why they aren't included.

    My line of reasoning is that including them could expand the augmentation space and thus help with generalization.

    opened by bfreskura 1
  • Can you share 2x model in another form?

    Can you share 2x model in another form?

    Is it possible for you to post the 2x pretrained model in the architecture of your 4x model? Other than that thanks for this great work. Are you thinking about improving the face restoration quality in later projects?

    Also I was wondering if you have any experimental models you would like to share for bsrgan without any denoising but with the ability of face restoration,motion blur removal etc? I mean bsrgan model but just without denoise

    opened by FlowDownTheRiver 1
  • Trained BSRGAN and got blank images

    Trained BSRGAN and got blank images

    I followed the instructions in https://github.com/cszn/BSRGAN#training and trained DIV2K dataset. However after a day of training all test images were just uniform patches

    Output: image Anyone successfully trained BSRGAN using the code in this repo? Thanks

    opened by thanhhuyha 0
  • when you training, if the patch_size 72*72 in the paper  means randomcrop 72*72 from lr_image

    when you training, if the patch_size 72*72 in the paper means randomcrop 72*72 from lr_image

    the patch_size 7272 in the paper means randomcrop 7272 from lr_image ,and make it as input of generator ,and hr_img should be 288 *288 corrspond to randomcrop's lr_img , am I right? WechatIMG224

    opened by erjihaoshi 0
  • Replication of BSRGAN results

    Replication of BSRGAN results

    Dear authors,

    I am more than interested in your work and would very much appreciate if you answer the following questions:

    • Have you used the blindsr.degradation_bsrgan script to generate test dataset? I inferenced BSRNet and RRDB from type-I to type-3 (of proposed DIV2K4D) and achieved almost the same results as reported in the paper. However, results on type-4 (generated by abovementioned script) led to significantly worse results: BSRNet 24.40 +- 0.14 dB (over 10 realizations) and RRDB: 22.50 +- 0.14 dB. Metrics are calculated in Y channel.
    • Do you use the same script to generate a training dataset? Also, are the training parameters (learning rate, patch shape (72x72), num. of iterations, etc.) of BSRNet the same as BSRGAN?

    Sincerely, Magauiya

    opened by Magauiya 0
  • Your Results in New Super-Resolution Benchmarks

    Your Results in New Super-Resolution Benchmarks

    Hello,

    MSU Graphics & Media Lab Video Group has recently launched two new Super-Resolution Benchmarks.

    Your method achieved 3rd place in Video Upscalers Benchmark: Quality Enhancement in 'Camera 4x' category. We congratulate you on your result and look forward to your future work!

    We would be grateful for your feedback on our work.

    opened by EvgeneyBogatyrev 0
  • pretrained_netE 和pretrained_netD的关系

    pretrained_netE 和pretrained_netD的关系

    请问pretrained_netE 和pretrained_netD是同一个东西吗? 我填写如下 是否有问题 "root": "superresolution" // "denoising" | "superresolution" , "pretrained_netG": "bsrgan_x4_gan/models/BSRNet.pth" // path of pretrained model , "pretrained_netD": "bsrgan_x4_gan/models/vgg19-dcbb9e9d.pth" // path of pretrained model , "pretrained_netE": "bsrgan_x4_gan/models/vgg19-dcbb9e9d.pth" // path of pretrained model

    opened by yumulinfeng1 2
  • import ISP model in the degradation model

    import ISP model in the degradation model

    Hi Kai, thank you for your great work. And I want to know how to import the ISP model in the function "degradation_bsrgan_plus(img, sf=4, shuffle_prob=0.5, use_sharp=True, lq_patchsize=64, isp_model=None)" to process the RGB images. Thank you again for your time and attention.

    opened by peiyaoooo 0
Owner
Kai Zhang
Image Restoration; Inverse Problems
Kai Zhang
Official implementation of the paper 'Efficient and Degradation-Adaptive Network for Real-World Image Super-Resolution'

DASR Paper Efficient and Degradation-Adaptive Network for Real-World Image Super-Resolution Jie Liang, Hui Zeng, and Lei Zhang. In arxiv preprint. Abs

null 81 Dec 28, 2022
Official PyTorch implementation of the paper "Deep Constrained Least Squares for Blind Image Super-Resolution", CVPR 2022.

Deep Constrained Least Squares for Blind Image Super-Resolution [Paper] This is the official implementation of 'Deep Constrained Least Squares for Bli

MEGVII Research 141 Dec 30, 2022
Official PyTorch code for Mutual Affine Network for Spatially Variant Kernel Estimation in Blind Image Super-Resolution (MANet, ICCV2021)

Mutual Affine Network for Spatially Variant Kernel Estimation in Blind Image Super-Resolution (MANet, ICCV2021) This repository is the official PyTorc

Jingyun Liang 139 Dec 29, 2022
Code for Blind Image Decomposition (BID) and Blind Image Decomposition network (BIDeN).

arXiv, porject page, paper Blind Image Decomposition (BID) Blind Image Decomposition is a novel task. The task requires separating a superimposed imag

null 64 Dec 20, 2022
Official implementation of Unfolded Deep Kernel Estimation for Blind Image Super-resolution.

Unfolded Deep Kernel Estimation for Blind Image Super-resolution Hongyi Zheng, Hongwei Yong, Lei Zhang, "Unfolded Deep Kernel Estimation for Blind Ima

Z80 15 Dec 26, 2022
Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data

Real-ESRGAN Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data Ported from https://github.com/xinntao/Real-ESRGAN Depend

Holy Wu 44 Dec 27, 2022
Practical Single-Image Super-Resolution Using Look-Up Table

Practical Single-Image Super-Resolution Using Look-Up Table [Paper] Dependency Python 3.6 PyTorch glob numpy pillow tqdm tensorboardx 1. Training deep

Younghyun Jo 116 Dec 23, 2022
DAN: Unfolding the Alternating Optimization for Blind Super Resolution

DAN-Basd-on-Openmmlab DAN: Unfolding the Alternating Optimization for Blind Super Resolution We reproduce DAN via mmediting based on open-sourced code

AlexZou 72 Dec 13, 2022
Super-Fast-Adversarial-Training - A PyTorch Implementation code for developing super fast adversarial training

Super-Fast-Adversarial-Training This is a PyTorch Implementation code for develo

LBK 26 Dec 2, 2022
A python software that can help blind people find things like laptops, phones, etc the same way a guide dog guides a blind person in finding his way.

GuidEye A python software that can help blind people find things like laptops, phones, etc the same way a guide dog guides a blind person in finding h

Munal Jain 0 Aug 9, 2022
[ICCV 2021] Released code for Causal Attention for Unbiased Visual Recognition

CaaM This repo contains the codes of training our CaaM on NICO/ImageNet9 dataset. Due to my recent limited bandwidth, this codebase is still messy, wh

Wang Tan 66 Dec 31, 2022
Practical Blind Denoising via Swin-Conv-UNet and Data Synthesis

Practical Blind Denoising via Swin-Conv-UNet and Data Synthesis [Paper] [Online Demo] The following results are obtained by our SCUNet with purely syn

Kai Zhang 312 Jan 7, 2023
PyTorch code for our ECCV 2018 paper "Image Super-Resolution Using Very Deep Residual Channel Attention Networks"

PyTorch code for our ECCV 2018 paper "Image Super-Resolution Using Very Deep Residual Channel Attention Networks"

Yulun Zhang 1.2k Dec 26, 2022
Official PyTorch code for Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021)

Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021) This repository is the official P

Jingyun Liang 159 Dec 30, 2022
Official PyTorch code for Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021)

Hierarchical Conditional Flow: A Unified Framework for Image Super-Resolution and Image Rescaling (HCFlow, ICCV2021) This repository is the official P

Jingyun Liang 159 Dec 30, 2022
Implementation for our ICCV 2021 paper: Dual-Camera Super-Resolution with Aligned Attention Modules

DCSR: Dual Camera Super-Resolution Implementation for our ICCV 2021 oral paper: Dual-Camera Super-Resolution with Aligned Attention Modules paper | pr

Tengfei Wang 110 Dec 20, 2022
Implementation for our ICCV 2021 paper: Dual-Camera Super-Resolution with Aligned Attention Modules

DCSR: Dual Camera Super-Resolution Implementation for our ICCV 2021 oral paper: Dual-Camera Super-Resolution with Aligned Attention Modules paper | pr

Tengfei Wang 110 Dec 20, 2022
PyTorch version of the paper 'Enhanced Deep Residual Networks for Single Image Super-Resolution' (CVPRW 2017)

About PyTorch 1.2.0 Now the master branch supports PyTorch 1.2.0 by default. Due to the serious version problem (especially torch.utils.data.dataloade

Sanghyun Son 2.1k Jan 1, 2023
Towards Flexible Blind JPEG Artifacts Removal (FBCNN, ICCV 2021)

Towards Flexible Blind JPEG Artifacts Removal (FBCNN, ICCV 2021)

Jiaxi Jiang 282 Jan 2, 2023