Git Product home page Git Product logo

selfdeblur's Introduction

[pdf] [supp]

Introduction

Blind deconvolution is a classical yet challenging low-level vision problem with many real-world applications. Traditional maximum a posterior (MAP) based methods rely heavily on fixed and handcrafted priors that certainly are insufficient in characterizing clean images and blur kernels, and usually adopt specially designed alternating minimization to avoid trivial solution. In contrast, existing deep motion deblurring networks learn from massive training images the mapping to clean image or blur kernel, but are limited in handling various complex and large size blur kernels. Motivated by deep image prior (DIP) [1], we in this paper present two generative networks for respectively modeling the deep priors of clean image and blur kernel, and propose an unconstrained neural optimization solution to blind deconvolution (SelfDeblur). Experimental results show that our SelfDeblur can achieve notable quantitative gains as well as more visually plausible deblurring results in comparison to state-of-the-art blind deconvolution methods on benchmark datasets and real-world blurry images.

Prerequisites

  • Python 3.6, PyTorch >= 0.4
  • Requirements: opencv-python, tqdm
  • Platforms: Ubuntu 16.04, TITAN V, cuda-10.0 & cuDNN v-7.5
  • MATLAB for computing evaluation metrics

Datasets

SelfDeblur is evaluated on datasets of Levin et al. [2] and Lai et al. [3]. Please download the testing datasets from BaiduYun or OneDrive, and place the unzipped folders into ./datasets/.

Getting Started

1. Run SelfDeblur

-(1) SelfDeblur on Levin dataset. The code has been improved, and usually can achieve better retults than those reported in the paper.

python selfdeblur_levin.py 

-(2) SelfDeblur on Lai dataset, where blurry images have firstly been converted to their Y channel. Several images may converge to "black" deblurring images, but their estimated blur kernels are good. I will check why this happened. In these cases, you need to run selfdeblur_nonblind.py to generate final deblurring images.

python selfdeblur_lai.py 
python selfdeblur_nonblind.py --data_path path_to_blurry --save_path path_to_estimated_kernel # Optional nonblind SelfDeblur. Given kernel estimated by Gk, only update Gx.

-(3) Handle color images in YCbCr space. 2500 iterations are adopted. If you need better texture details, more iterations will help.

python selfdeblur_ycbcr.py # Deblur several color images in `./datasets/real/`.

*In current SelfDeblur code, TV regularization has been removed. The improved code is more robust to blur kernel estimation. But for some images with high level noises and non-uniform blurry images, the deblurring results may suffer from ringing effects due to our uniform convolution-based loss function. In this case, adding TV regularization to SelfDeblur loss function or running another nonblind deblur method may be a choice.

-(4) Reproduce results reported in the paper. The codes for reproducing results require Pytorch 1.0.0 to load the models. Higher versions may work well, but I do not test. Pytorch 0.4 fails to load these trained models.

As for Levin dataset, one should download the SelfDeblur models from BaiduYun (levin/SelfDeblur.zip), and then run the following script to load trained models for reproducing the results reported in the paper. We note that the deblurring images may be slightly different due to the random perturbations of input to Gx, while generated blur kernels keep same.

python selfdeblur_levin_reproduce.py # Reproduce results in the paper. 

As for Lai dataset, one should download the SelfDeblur models from BaiduYun (lai/SelfDeblur_models.zip), and then run the following script to load trained models for reproducing the results reported in the paper. We note that the deblurring images may be slightly different due to the random perturbations of input to Gx, while generated blur kernels keep same.

python selfdeblur_lai_reproduce.py # Reproduce results in the paper. 

*Actually, the trained SelfDeblur models can be regarded as an optimization solution to a given blurry image, and cannot be generalized to other blurry images. So these trained models can only be used to reproduce the results.I suggest to re-run scripts in (1) and (2) to see the performance of SelfDeblur on Levin and Lai datasets. Since I have updated the code, the results on Levin dataset are usually better than the paper, and the results on Lai dataset are also comparable.

All the deblurring results are also available. Please read results/levin/readme.docx and results/lai/readme.docx for the details. You can place the downloaded results into ./results/, and directly compute all the evaluation metrics in this paper.

2. Evaluation metrics

We provide the MATLAB scripts to compute the average PSNR and SSIM values reported in the paper.

 cd ./statistic
 run statistic_levin.m 
 run statistic_lai.m 

SelfDeblur succeeds in simultaneously estimating blur kernel and generating clean image with finer texture details.

References

[1] D. Ulyanov, A. Vedaldi, and V. Lempitsky. Deep image prior. In IEEE CVPR 2018.

[2] A. Levin, Y. Weiss, F. Durand, and W. T. Freeman. Understanding and evaluating blind deconvolution algorithms. In IEEE CVPR 2009.

[3] W.-S. Lai, J.-B. Huang, Z. Hu, N. Ahuja, and M.-H. Yang. A comparative study for single image blind deblurring. In IEEE CVPR 2016.

selfdeblur's People

Contributors

csdwren 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  avatar  avatar  avatar  avatar

selfdeblur's Issues

Why is PSNR lower than in the paper ?

Thank you for your wonderful work, but I have a little doubt. I used the deblur result you provided and directly compute all the evaluation metrics(PSNR SSIM) and found that the result was lower than your value in the paper. Thank you again for your work.

TV loss

Hi! First, thanks for your kind work.

However, where can I get the TV loss function when reproducing the results of the paper??

Can you provide a solution for this?
Thank you.

Possible mismatch for examples from Lai's dataset

Thank you for your inspiring work! I just report a possible mismatch when running the released code.

I tried to run selfdeblur_lai.py to deblur images from Lai's dataset. However, I can not produce meaningful results for certain images like manmade_01_kernel_03.png and manmade_01_kernel_04.png by default settings. I guess there are some mismatches between the uploaded code for Lai's dataset and the deblurred results you provided.

Here are my workflows for your reference.
I downloaded your data blurry/lai and transfer all images of this folder to YCbCr color space. Then I run that code by input only Y channel. It can generate good results for manmade_01_kernel_01.png and manmade_01_kernel_02.png, but it failed for larger kernels, which do not correspond to the results provided.

Please refer to the kernel I got for manmade_01_kernel_03
manmade_01_kernel_03_k

Could you please help to check out if there is something wrong? Thank you!

Colour image deblurring

Uploading fishes_k.png…
hello I ran your test code selfdeblur_ycbcr but the result is very poor,the estimated blur kernel is a snowflake and I'm not quite sure why?

I'm using a 2080 Ti graphics card.

test

how to do deblur on an image?

Online/offline image deblur solution

Hi @csdwren, thanks for the cool research and the open source.
Do you plan to provide something like a (ideally - free) online image deblur solution?
I imagine that it should be easy to setup.
It would be also nice to pack complete solution, with model, for local image deblurring.

RuntimeError: set_storage_offset is not allowed on a Tensor created from .data or .detach().

Hi,when I run selfdeblur_levin.py,I have the error:
im1_kernel1_img
Traceback (most recent call last):
File "selfdeblur_levin.py", line 101, in
net_input_kernel.squeeze_()
RuntimeError: set_storage_offset is not allowed on a Tensor created from .data or .detach().
If your intent is to change the metadata of a Tensor (such as sizes / strides / storage / storage_offset)
without autograd tracking the change, remove the .data / .detach() call and wrap the change in a with torch.no_grad(): block.
For example, change:
x.data.set_(y)
to:
with torch.no_grad():
x.set_(y)

cublas runtime error : the GPU program failed to execute at /opt/conda/conda-bld/pytorch_1533672544752/work/aten/src/THC/THCBlas.cu:411

Hello, when i run selfdeblur_ycbcr.py,there is a mistake,
File "selfdeblur_ycbcr.py", line 121, in
out_x = net(net_input)
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/tmp/selfdDeblur/networks/common.py", line 22, in forward
inputs.append(module(input))
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/tmp/selfdDeblur/networks/common.py", line 22, in forward
inputs.append(module(input))
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/tmp/selfdDeblur/networks/common.py", line 22, in forward
inputs.append(module(input))
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/container.py", line 91, in forward
input = module(input)
File "/home/user1/anaconda3/envs/pytorch1.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/tmp/selfdDeblur/networks/non_local_dot_product.py", line 77, in forward
f = torch.matmul(theta_x, phi_x)
RuntimeError: cublas runtime error : the GPU program failed to execute at /opt/conda/conda-bld/pytorch_1533672544752/work/aten/src/THC/THCBlas.cu:411
How can solve this problem?

How to get color results?

Hi~
Thanks for your work.
I ran SelfDeblur on my own blur images and get gray results. It seems that the SelfDeblur is performed on Y channel. So can you provide the code coverting the results to RGB?
Looking forward to it, thank you!

where is the pretrained model

it seems that there is no pretrained model file in baiduyun download link. and the onedrive link is broken. so how can i get the pretrained model

The noise level

Hello,

Firstly, thanks for the great contribution and the open access to the code!

My question is that I want to apply this algorithm on my own datasets, say that I have a blurry noisy image, with known noise level and blur kernel size. I notice that in your code like selfdeblur_levin.py line 48 there is one setting called 'reg_noise_std = 0.001', does this refer to the regularization parameter \lambda in Eq.6 in your paper? If so, why you did not set it as 10^-6 as you said in Section 4.1 (10\times std of noise level), if not, what is this setting?

Another question is that if I understand correctly, your algorithm is an unsupervised one so that we do not need to train a generalized model using training sets, instead we directly apply the algorithm on the blurry noisy images one by one, right? Does your algorithm have some limitations to the noise level? If the noise std is relatively big, say 0.1, would it still work well?

Any reply is appreciated!

other fuzzy kernels

Excuse me, can this algorithm solve the blind deblurring of other fuzzy kernels?

RuntimeError: CUDA out of memory

Hi, when I run selfdeblur for GOPRO data, I have the runtime error.
RuntimeError: CUDA out of memory. Tried to allocate 530.75 MiB (GPU 0; 8.00 GiB total capacity; 4.17 GiB already allocated; 323.22 MiB free; 5.45 MiB cached)
Some suggestions are "reduce batch size" and do you have any suggestions?

Can't find the training set

Hello, Professor, thank you for your contribution! I can't find where the training set is when I run levin data.

About the estimating of blur kernel

I wanna know the reason why you use fcn to estimate the blur kernel instead of directly estimate the kernel by CNN from a blur image? Thank you professor.

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.