Giter Site home page Giter Site logo

gcdn's Introduction

Deep Graph-Convolutional Image Denoising

Code for paper "Deep Graph-Convolutional Image Denoising" by Diego Valsesia, Giulia Fracastoro, Enrico Magli.

BibTex references for journal and conference versions:

@article{valsesia2020deep,
  title={Deep graph-convolutional image denoising},
  author={Valsesia, Diego and Fracastoro, Giulia and Magli, Enrico},
  journal={IEEE Transactions on Image Processing},
  volume={29},
  pages={8226--8237},
  year={2020},
  publisher={IEEE}
}


@inproceedings{ValsesiaICIP19,
  title     = {Image Denoising with Graph-Convolutional Neural Networks},
  author    = {Valsesia, Diego and Fracastoro, Giulia and Magli, Enrico},
  year      = {2019},
  booktitle={2019 26th IEEE International Conference on Image Processing (ICIP)}
}

Tested hardware configuration

CPU: AMD Ryzen 1 1700
RAM: 32 GB
GPUs: 2x Nvidia Quadro P6000 (24 GB)

The code requires a good amount of GPU memory. 2 GPUs with 24 GB are recommended for training. A single GPU is used for testing.

Software requirements

  • Python 2.7
  • Tensorflow 1.12
  • The packages listed in requirements.txt

Code organization

Code is organized in the following directories

Code: one subfolder for each network model with all the source files;

Dataset: training ad testing images;

log_dir: logs for training process; if a start_iter file is found, training will resume from the iteration number written in the file after loading a model.

Results: saved_models directories contain checkpoints with trained models; denoised_images is the defualt path for output images.

Parameters

File config.py contains all the parameters used by the training and testing process.

patch_size : size of patches used in training
pre_n_layers : number of conv2d layers is the preprocessing block
pregconv_n_layers : number of gconv layers is the preprocessing block
hpf_n_layers : number of gconv layers in the HPF block
lpf_n_layers : number of gconv layers in each LPF block
prox_n_layers : number of LPF blocks
Nfeat : number of feature maps, must be a multiple of 3
rank_theta : maximum rank in low-rank approximation of ECC   
stride : Nfeat/num where num is how many circulant versions of a row are used in the circulant ECC aproximation
min_nn : total receptive field of gconv layer = number of non-local neighbors + 8 local neighbors
batch_size : total batch size (each GPU sees batch_size/Ngpus)
grad_accum : if >1 gradients from multiple minibatches are accumulated before being applied
N_iter : total number of training iterations
starter_learning_rate : learning rate (for fixed learning rate) or starting learning rate (for decay)
end_learning_rate : final learning rate (for decay)
Ngpus : number of GPUs used for training (only tested for 1 or 2)
minisize : maximum size of testing image portion to be considered at a time (to limit memory consumption), must be a multiple of search_window
search_window : size of window around each pixel where nearest neighbors are computed at testing time
sigma : standard deviation of noise. Remember to set it correctly when testing!

Training

  • Copy your training images (*.png) to the Dataset/Gray/trainset directory
  • Training can be run with the launcher bash script:
./launcher_train.sh

Training is parallelized over 2 GPUs. Notice that during training the gconv layer will compute all pairwise distances between the feature vectors of pixels within the patch. A small testing routine is included in the training code for debugging, but uses patchwise testing which creates border artifacts, contrary to the actual fully-convolutional testing code. Suggestion: improved convergence is achieved by pretraining a shorter model with only 2 LPF blocks (lpf_n_layers=2) and then increase its length to 4 LPF blocks.

Testing

Pretrained models are available for noise standard deviations 15,25,50. Notice that the results can be slightly different from paper due to noise seed, initialization and finetuning of number of non-local neighbors. Pretrained models are finetuned on 16 non-local neighbors, changing that requires finetuning. Testing can be run with the launcher bash script:

./launcher_test.sh

Testing only works on a single GPU. Testing is fully-convolutional, so any input size is accepted. Contrary to training, only the distances from the pixel to be estimated to those in a search window around it are computed in the gconv layer.

Testing parameters are optimized for a GPU with 24GB of memory. A few things can be changed to reduce (or increase) memory usage:

  • Tweak the number of parallel threads in net_conv2.py (increases computation time):
Line 213: 
ret_list = tf.map_fn(lambda feat: self.gconv_conv_inner(feat[0], name, in_feat, out_feat, stride_th1, stride_th2, compute_graph, return_graph, feat[1]), [p, D], parallel_iterations=2, swap_memory=False) # needs 24GB
ret_list = tf.map_fn(lambda feat: self.gconv_conv_inner(feat[0], name, in_feat, out_feat, stride_th1, stride_th2, compute_graph, return_graph, feat[1]), [p, D], parallel_iterations=1, swap_memory=False) # lower memory usage
  • Reduce the search window size (reduces output quality)
  • Reduce the minisize value to let the network process a smaller crop of the image at a time (UNSTABLE, treat with care)

gcdn's People

Contributors

diegovalsesia 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gcdn's Issues

Lighter/faster version ?

Hi,

I am testing your model, and I am trying to reduce the computational time. I already used your first recommendation (use only 1 thread). I am now struggling to reduce window size.
How can I easily reduce the patch_size and/or increase the stride of your method ? Can it be done without retraining the whole model ? (If so, how much time did it take with your hardware configuration (2x Nvidia Quadro P6000 (24 GB) ) ?

Many thanks,
Mickaël

License ?

Hi,

Your method seems promising, and I would like to know if you plan to add an open-source license (such as MIT or Apache-2.0) to your repo so it can be used elsewhere ?
If so, I plan to refer to it in my own project: https://github.com/titsitits/open-image-restoration
and I'll try to integrate your method (maybe replace NLRN by yours after some tests) to my restoration pipeline.

(it's very easy to add a license to your repo, you just need to upload a license.md file like this one: https://github.com/titsitits/open-image-restoration/blob/master/LICENSE.md
file raw version: https://raw.githubusercontent.com/titsitits/open-image-restoration/master/LICENSE.md )

Best regards,
Mickaël

Why precompute mask for local neighborhood?

I interest your work but have two questions in 'main.py'.
First, why precompute masks for local neighborhood?
Second, why leverage this manner to precompute the mask?
I'm a fresher for GCN. Thank you.

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.