Code Monkey home page Code Monkey logo

defocus-deblurring-dual-pixel's Introduction

Abdullah Abuolaim1 and Michael S. Brown1,2

1York University, Toronto, Canada      2Samsung AI Center, Toronto, Canada

teaser figure

Reference github repository for the paper Defocus Deblurring Using Dual-Pixel Data. Abdullah Abuolaim and Michael S. Brown, Proceedings of the European Conference on Computer Vision (ECCV), 2020. If you use our dataset or code, please cite our paper:

@article{abuolaim2020defocus,
  title={Defocus Deblurring Using Dual-Pixel Data},
  author={Abuolaim, Abdullah and Brown, Michael S},
  booktitle={Proceedings of the European Conference on Computer Vision (ECCV)},
  year={2020}
}

Dataset

Dual-Pixel Defocus Deblurring (DPDD) dataset contains 500 carefully captured scenes. This dataset consists of 2000 images i.e., 500 DoF blurred images with their 1000 dual-pixel (DP) sub-aperture views and 500 corresponding all-in-focus images all at full-frame resolution (i.e., 6720x4480 pixels).

Canon_01

  • Images captured by Canon EOS 5D Mark IV DSLR camera

  • Images captured by Google Pixel 4 smartphone camera

    • Pixel 4 images used for testing in our experiments
    • We refer redears to this GitHub repository created by Google research in order to extract DP views for Pixel smartphone
    • Recall, the smartphone camera currently has limitations that make it challenging to train our DPDNet with
      • The Google Pixel smartphone cameras do not have adjustable apertures, so we are unable to capture corresponding sharp images using a small aperture
      • The data currently available from the Pixel smartphones are not full-frame, but are limited to only one of the Green channels in the raw-Bayer frame
  • Extracting DP left and right views from the RAW CR2

Canon_01

  • Training, validation, and testing sets

    • The dataset is divided randomly into:
      • 70% training, 15% validation, and 15% testing
    • Each set has a balanced number of indoor/outdoor scenes
    • The image names for each set can be found in ./DPDNet/file_names/ directory
  • The dataset is organized based on the following directory structure

Canon_01

$dir_name$_c: directory of the final output combined images
$dir_name$_l: directory of the corresponding DP left view images
$dir_name$_r: directory of the corresponding DP right view images
source: images exhibiting defocus blur
target: the corresponding all-in-focus images

Code

Prerequisites

  • The code tested with:
    • Python 3.6.9
    • TensorFlow 1.9.0
    • Keras 2.2.4
    • Numpy 1.17.2
    • Scikit-image 0.16.2
    • OpenCV 3.4.2

Despite not tested, the code may work with library versions other than the specified

Installation

Clone with HTTPS this project to your local machine

git clone https://github.com/Abdullah-Abuolaim/defocus-deblurring-dual-pixel.git
cd defocus-deblurring-dual-pixel

Evaluation Metrics

Results are reported on traditional signal processing metrics i.e., MSE, PSNR, SSIM, and MAE. Implementation can be found in ./DPDNet/metrics.py. We also incorporate the recent learned perceptual image patch similarity (LPIPS) proposed by R. Zhang et al. [1]. Implementation can be found in this GitHub repository

Testing

  • Download pretrained model defocus_deblurring_dp_l5_s512_f0.7_d0.4.hdf5 inside ./DPDNet/ModelCheckpoints/

  • Canon dataset

    • Download dataset dd_dp_dataset_canon.zip and unzip it inside ./DPDNet/

    • Recall that we test with 16-bit images (bit_depth=16 in ./DPDNet/config.py)

    • Run:

       python ./DPDNet/main.py
  • Pixel 4 test images

    • Download dataset dd_dp_dataset_pixel.zip and unzip it inside ./DPDNet/

    • Change the dataset name variable inside ./DPDNet/config.py to be dataset_name='_pixel'

    • Recall that we test with 16-bit images (bit_depth=16 in ./DPDNet/config.py)

    • Run:

       python ./DPDNet/main.py

Training

  • Pre-processe data to extract patches for training

    • As we mentioned in the main paper, we discard 30% of the patches that have the lowest sharpness energy

    • We found it faster to prepare training patches beforehand instead of extract patches during the runtime

    • Download dataset dd_dp_dataset_canon.zip and unzip it inside ./DPDNet/

    • The patch size, overlapping ratio, and sharpness energy filtering ratio are set as described in the main paper

    • Run:

       python ./DPDNet/image_to_patch_filter.py
    • Running above creates a new directory dd_dp_dataset_canon_patch that has the training/validation patches

  • Start training based on the procedure and hyper-parameters described in the main paper

    • ./DPDNet/config.py module contains all the configurations and hyper-parameters

    • Change op_phase='test' to op_phase='train' in ./DPDNet/config.py

    • Recall that we train with 16-bit images (bit_depth=16 in ./DPDNet/config.py)

    • Run:

       python ./DPDNet/main.py

Contact

Should you have any question/suggestion, please feel free to reach out:

Abdullah Abuolaim ([email protected])

Related Links

Reference

[1] R. Zhang et al. R. Zhang, P. Isola, A. A. Efros, E. Shechtman, and O. Wang. The unreasonable effectiveness of deep features as a perceptual metric. In CVPR, 2018.

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.