Home

Awesome

Nighttime Smartphone Reflective Flare Removal using Optical Center Symmetry Prior (CVPR2023)

Paper | Project Page | Video

Yuekun Dai, Yihang Luo, Shangchen Zhou, Chongyi Li, Chen Change Loy

S-Lab, Nanyang Technological University

News

Installation

  1. Clone the repo

    git clone https://github.com/ykdai/BracketFlare
    
  2. Install dependent packages

    cd BracketFlare
    pip install -r requirements.txt
    
  3. Install BracketFlare<br> Please run the following commands in the BracketFlare root path to install BracketFlare:<br>

    python setup.py develop
    

Data Download

Baidu NetdiskGoogle DriveNumberDescription
BracketFlarelinklink440We offer 440 normal-exposure and short-exposure nighttime image pairs. Short exposure images can be added to the corresponding normal-exposure image to synthesize the flare-corrupted image.

BracketFlare Data structure

├── BracketFlare
    ├── flare
    ├── gt
    ├── test
         ├── flare
         ├── gt
         ├── mask
         ├── lq

Pretrained Model

The inference code based on MPRNet is released Now. You can download the pretrained checkpoints on [GoogleDrive | Baidu Netdisk]. Please place it under the experiments folder and unzip it.

Inference Code

To generate the flare-free images from the test/lq folder, you can run the test.py by using:

python test.py --i test/lq/ --o result/ --model_path experiments/net_g_last.pth

If you have a large image and don't want to change the size of it, you can also try test_large.py by using:

python test_large.py --i test/lq/ --o result/ --model_path experiments/net_g_last.pth --inpaint

Module --inpaint is mainly for tiny reflective flares, it will achieve smoother results for large size image.

Evaluation Code

To calculate different metrics with our pretrained model, you can run the evaluate.py by using:

python evaluate.py --input result/deflare/ --gt test/gt --mask test/mask

Training model

Training with single GPU

To train a model, you need to download and unzip our BracketFlare dataset under data folder. You may edit the options/bracketflare_mprnet_option.yml and run the following code. You can also add --debug command to start the debug mode:

python basicsr/train.py -opt options/bracketflare_mprnet_option.yml

Training with multiple GPU

You can run the following command for the multiple GPU tranining:

CUDA_VISIBLE_DEVICES=0,1 bash scripts/dist_train.sh 2 options/bracketflare_mprnet_option.yml

License

This project is licensed under <a rel="license" href="https://github.com/ykdai/BracketFlare/blob/main/LICENSE">S-Lab License 1.0</a>. Redistribution and use of the dataset and code for non-commercial purposes should follow this license. This project is built on BasicSR, the detailed tutorial on training commands and config settings can be found here.

Citation

If you find this work useful, please cite:

@inproceedings{dai2023nighttime,
  title={Nighttime Smartphone Reflective Flare Removal using Optical Center Symmetry Prior},
  author={Dai, Yuekun and Luo, Yihang and Zhou, Shangchen and Li, Chongyi and Loy, Chen Change},
  booktitle = {Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
  year = {2023}
 }

Contact

If you have any question (such as asking for the 4K version of our BracketFlare Dataset), please feel free to reach me out at ydai005@e.ntu.edu.sg.