Code Monkey home page Code Monkey logo

fkp's Introduction

Flow-based Kernel Prior with Application to Blind Super-Resolution (FKP), CVPR2021

This repository is the official PyTorch implementation of Flow-based Kernel Prior with Application to Blind Super-Resolution (arxiv, supp).

๐Ÿš€ ๐Ÿš€ ๐Ÿš€ News:


Kernel estimation is generally one of the key problems for blind image super-resolution (SR). Recently, Double-DIP proposes to model the kernel via a network architecture prior, while KernelGAN employs the deep linear network and several regularization losses to constrain the kernel space. However, they fail to fully exploit the general SR kernel assumption that anisotropic Gaussian kernels are sufficient for image SR. To address this issue, this paper proposes a normalizing flow-based kernel prior (FKP) for kernel modeling. By learning an invertible mapping between the anisotropic Gaussian kernel distribution and a tractable latent distribution, FKP can be easily used to replace the kernel modeling modules of Double-DIP and KernelGAN. Specifically, FKP optimizes the kernel in the latent space rather than the network parameter space, which allows it to generate reasonable kernel initialization, traverse the learned kernel manifold and improve the optimization stability. Extensive experiments on synthetic and real-world images demonstrate that the proposed FKP can significantly improve the kernel estimation accuracy with less parameters, runtime and memory usage, leading to state-of-the-art blind SR results.

Requirements

  • Python 3.6, PyTorch >= 1.6
  • Requirements: opencv-python, tqdm
  • Platforms: Ubuntu 16.04, cuda-10.0 & cuDNN v-7.5

Quick Run

To run the code without preparing data, run this command:

cd DIPFKP
python main.py --SR --sf 4 --dataset Test

Data Preparation

To prepare testing data, please organize images as data/datasets/DIV2K/HR/0801.png, and run this command:

cd data
python prepare_dataset.py --model DIPFKP --sf 2 --dataset Set5
python prepare_dataset.py --model KernelGANFKP --sf 2 --dataset DIV2K

Commonly used datasets can be downloaded here. Note that KernelGAN/KernelGAN-FKP use analytic X4 kernel based on X2, and do not support X3.

FKP

To train FKP, run this command:

cd FKP
python main.py --train --sf 2

Pretrained FKP and USRNet models are already provided in data/pretrained_models.

DIP-FKP

To test DIP-FKP (no training phase), run this command:

cd DIPFKP
python main.py --SR --sf 2 --dataset Set5

KernelGAN-FKP

To test KernelGAN-FKP (no training phase), run this command:

cd KernelGANFKP
python main.py --SR --sf 2 --dataset DIV2K

Results

Please refer to the paper and supplementary for results. Since both DIP-FKP and KernelGAn-FKP are randomly intialized, different runs may get slightly different results. The reported results are averages of 5 runs.

Citation

@article{liang21fkp,
  title={Flow-based Kernel Prior with Application to Blind Super-Resolution},
  author={Liang, Jingyun and Zhang, Kai and Gu, Shuhang and Van Gool, Luc and Timofte, Radu},
  journal={arXiv preprint arXiv:2103.15977},
  year={2021}
}

License & Acknowledgement

This project is released under the Apache 2.0 license. The codes are based on normalizing_flows, DIP, KernelGAN and USRNet. Please also follow their licenses. Thanks for their great works.

fkp's People

Contributors

jingyunliang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fkp's Issues

image alignment issue

It seems that the alignment between HR and LR generated by your program is off and it could be related to the following code (different from original version). But somehow after USRNet, the alignment is back to normal. This is quite confusing.

wanted_center_of_mass = (np.array(kernel.shape) - sf) / 2.

how to test on my own images?

hi Jingyun,
Thanks for your work. There are too many test code in the project which make me confuesd.
I just want to test on my own image, what should do ?
Thanks again.

New Super-Resolution Benchmarks

Hello,

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

If you are interested in participating, you can add your algorithm following the submission steps:

We would be grateful for your feedback on our work!

How to train FKP?(no input datasets)

Thanks for your work. I have a question about how to train FKP. Because in your code, there are no input datasets. I am very confused about it. Could you help me?

What is Zk, please

The Zk in this paper is also the kernel_code in the code. What is Zk,please

Benchmark Evaluation on KernelGANFKPx4

Hello,

Thanks for uploading the code.

I am trying to evaluate KernelGANFKP on Set5 & Set14 & B100 for scaling factor x4:
FKP/KernelGANFKP$ python main.py --SR --sf 4 --dataset {dataset}

However, I am hitting an error during the forward pass of the discriminator if the input patch has a height or width < 27. Is KernelGANFKPx4 not supported for Set5, Set14, and B100 datasets?

about random kernel generator

In the following code, lamda_1&2 (referred as kernel width) are used to calculate the COV matrix. But shouldn't the square of lambda be used here for covariance?

def gen_kernel_fixed(k_size, scale_factor, lambda_1, lambda_2, theta, noise):

Training on pre-defined kernels

Hello! I have a kernel-pool which has 1k kernels of size 33x33 for x4 upscaling. How should the code be modified in order to make sure that we obtain proper estimations? Cause right now in order to obtain the x4 kernel you use FKP_x2 to obtain an estimation and then you do a kernel shift to obtain the x4 one. But this should not work if we would have to bring our own kernels of a different size.

Pixel Offset Problem

Hi, thank you for sharing the code.

I have an LR image and corresponding HR image.

We use the LR image as the input to the KernelGAN-FKP, and obtain a super-resolved image without ground-truth kernels, .

It seems that there is pixel offset between the super-resolved image and the original HR image, leading to a very low PSNR of the super-resolved image.

Do you know how to solve this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.