This version is outdated by a newer approved version.DiffThis version (2019/07/11 11:06) was approved by twagner.The Previously approved version (2019/07/10 10:37) is available.Diff

This is an old revision of the document!

Just Another Noise 2 Noise Implementation (JANNI)

JANNI implements a neural network denoising tool described in NVIDIA's noise2noise paper: Noise2Noise: Learning Image Restoration without Clean Data - arXiv

JANNI can be used a command line tool but also provides an simple interface to be integrated into other programs.

You can find the download and installation instructions here: Download and Installation

In case you want to use the general model (Download here) you can skip this part and directly denoise your images.

In case you would like to train a model for your data, the first thing you have to do is to create a configuration file for JANNI. In the following I assume you named it config.json. It should look like this:

    "model" : {
        "architecture":         "unet",
        "patch_size":           1024
    "train": {
        "movie_dir":            "/path/to/movie/directory/",
        "even_dir":             "even_averages/",
        "odd_dir":              "odd_averages/",
        "batch_size":           4,
        "learning_rate":        1e-3,
        "nb_epoch":             100,
        "saved_weights_name":   "mymodel.h5"

The fields have the following meaning:

  • architecture: CNN Architecture. Right now, only unet is supported.
  • patch_size: The image will be denoised in patches. This field defines the patch size.
  • movie_dir: Path to the directory with the movie files. If an average exists already in even_dir or odd_dir (see below), it will be skipped.
  • even_dir: For each movie in movie_dir, an average based on the even frames is calculated and saved in even_dir.
  • odd_dir: For each movie in movie_dir, an average based on the odd frames is calculated and saved in even_dir.
  • batch_size: How many patches are in one mini-batch. If you have memory problems (e.g with cards < 8GB memory), you can try to reduce this value.
  • learning_rate: Learning rate, should not be changed.
  • nb_epoch: Number of epochs to train. More epochs seems to only slightly improve the results.
  • saved_weights_name: Filename of your model.

In principle you only have to adapt the paths. The other could keep as they are. We typically use at least 30 movies to train the model. Less might also work, more work often much better.

To run the training on gpu 0:

janni_denoise.py train config.json -g 0

With a trained model (either trained by you or the general model) you can directly denoise either your movies or averages. In our experience, denoising the motion corrected averages works better.

To denoise a set if images you have to tell JANNI three mandatory arguments:

  1. input_path: This path points to the directory with your images.
  2. ouput_path: This path points to a directory where the results will be written
  3. model_path: This path points to the model you want to use (the .h5 file).

As model you can either use the model you trained for your data or the general model (Download here).

There are couple of optional parameters that you use:

  • -ol: The image is denoised in patches and these patches have to overlap to avoid artifacts. This is the amount of overlap in pixel and the default value is 24. If you observe a grid like pattern in your images, increase this value.
  • -bs: Number of patches predicted in parallel. Default is 4. If you have memory problems, decrease this value. Increase should speed up the things a bit.
  • -g: GPU ID to run JANNI on. Multiple GPUs are not supported yet.

Here is now how you do the actual denoising: It is assumed that you run the command in a directory with your model file mymodel.h5 (might have a different name in case of the general model). Furthermore, it is assumed that your would like denoise averages in the folder /my/averages/ and want to write results in the folder /my/outputdir/denoised/

The following command will run the denoising on GPU 0:

janni_denoise.py predict /my/averages/ /my/outputdir/denoised/ mymodel.h5 -g 0

Please checkout the jupyter notebook to see how to use JANNI with python.

  • janni_tutorial.1562758302.txt.gz
  • Last modified: 2019/07/10 13:31
  • by twagner