HDR image reconstruction from a single exposure using deep CNNs
Branch: master
Clone or download
Latest commit 0716dc8 Jan 15, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
data Initial commit Sep 29, 2017
training_code Update README.md Jan 15, 2019
LICENSE Initial commit Sep 29, 2017
README.md Update README.md Jan 15, 2019
hdrcnn_predict.py Added option for controlling intensity of reconstructed pixels Dec 10, 2017
img_io.py Training code added Mar 2, 2018
network.py Resolved TensorLayer compatibility issue Apr 18, 2018


Deep learning HDR image reconstruction



This repository provides code for running inference with the autoencoder convolutional neural network (CNN) described in our Siggraph Asia paper, as well as training of the network. Please read the information below in order to make proper use of the method. If you use the code for your research work, please consider citing the paper according to:

  author       = "Eilertsen, Gabriel and Kronander, Joel, and Denes, Gyorgy and Mantiuk, Rafał and Unger, Jonas",
  title        = "HDR image reconstruction from a single exposure using deep CNNs",
  journal      = "ACM Transactions on Graphics (TOG)",
  number       = "6",
  volume       = "36",
  articleno    = "178",
  year         = "2017"

The CNN is trained to reconstruct image regions where information has been lost due to sensor saturation, such as highlights and bright image features. This means that a standard 8-bit single exposed image can be fed to the network, which then reconstructs the missing information in order to create a high dynamic range (HDR) image. Please see the project webpage for more information on the method.

In what follows are descriptions on how to make HDR reconstructions using the trained network. For training of new weigths information and code is provided in the training_code folder.

Code specification

The model and prediction scripts are written in Python using the following packages:

  • TensorFlow for model specification and prediction.
  • TensorLayer for simplified TensorFlow layer construction.
  • OpenEXR in order to write reconstructed HDR images to disc.
  • NumPy and SciPy for image handling etc.

All dependencies are available through the Python pip package manager (replace tensorflow with tensorflow-gpu for GPU support):

$ pip install numpy scipy tensorflow tensorlayer OpenEXR


  1. Trained CNN weights to be used for the inference, can be found here.
  2. Run python hdrcnn_predict.py -h to display available input options.
  3. Below follows an example to demonstrate how to make an HDR reconstruction.


There are a few test images provided, that can be used for reconstruction as follows:

$ python hdrcnn_predict.py --params hdrcnn_params.npz --im_dir data --width 1024 --height 768

Prediction can also be made on individual frames:

$ python hdrcnn_predict.py --params hdrcnn_params.npz --im_dir data/img_001.png --width 1024 --height 768

Compression artifacts

There is a limit to how much compression artifacts that can be present in the input images. Compression can often cause small (and often invisible) blocking artifacts close to highlights, which impairs the HDR reconstruction. Preferably, the input images should contain no or little compression (PNG or JPEG with highest quality setting).

[UPDATE, 2017-10-19]: There are now parameters available that have been trained with images that include JPEG compression artifacts. These can be downloaded here. If the images for reconstruction contain compression artifacts, these parameters makes for a substantial improvement in reconstruction quality as compared to the previous parameters. However, if the input images contain no compression artifacts we recommend to use the original parameters as these allow for a slight advantage in terms of reconstructed details.

Controlling the reconstruction

The HDR reconstruction with the CNN is completely automatic, with no parameter calibration needed. However, in some situations it may be beneficial to be able to control how bright the reconstructed pixels will be. To this end, there is a simple trick that can be used to allow for such control.

Given the input image x, the CNN prediction y = f(x) can be controlled somewhat by altering the input image with an exponential/gamma function, and inverting this after the reconstruction,

    y = f(x1/g)g.

Essentially, this modifies the camera curve of the image, so that reconstruction is performed given other camera characteristics. For a value g > 1, the intensities of reconstructed bright regions will be boosted, and vice versa for g < 1. There is an input option --gamma that allows to perform this modification:

$ python hdrcnn_predict.py [...] --gamma 1.2

In general, a value around 1.1-1.3 may be a good idea, since this prevents underestimation of the brightest pixels, which otherwise is common (e.g. due to limitations in the training data).


Copyright (c) 2017, Gabriel Eilertsen. All rights reserved.

The code is distributed under a BSD license. See LICENSE for information.