Zero DCE Colab Keras(Video)
Zero-DCE for low-light image enhancement
Author: Soumik Rakshit
Description: Implementing Zero-Reference Deep Curve Estimation for low-light image enhancement.
Modified for the video by: Ivan Goncharov
Introduction
Zero-Reference Deep Curve Estimation or Zero-DCE formulates low-light image enhancement as the task of estimating an image-specific tonal curve with a deep neural network. In this example, we train a lightweight deep network, DCE-Net, to estimate pixel-wise and high-order tonal curves for dynamic range adjustment of a given image.
Zero-DCE takes a low-light image as input and produces high-order tonal curves as its output. These curves are then used for pixel-wise adjustment on the dynamic range of the input to obtain an enhanced image. The curve estimation process is done in such a way that it maintains the range of the enhanced image and preserves the contrast of neighboring pixels. This curve estimation is inspired by curves adjustment used in photo editing software such as Adobe Photoshop where users can adjust points throughout an image’s tonal range.
Zero-DCE is appealing because of its relaxed assumptions with regard to reference images: it does not require any input/output image pairs during training. This is achieved through a set of carefully formulated non-reference loss functions, which implicitly measure the enhancement quality and guide the training of the network.
References
Downloading LOLDataset
The LoL Dataset has been created for low-light image enhancement. It provides 485 images for training and 15 for testing. Each image pair in the dataset consists of a low-light input image and its corresponding well-exposed reference image.
Downloading Lol dataset using W&B Artifacts
Creating a TensorFlow Dataset
We use 300 low-light images from the LoL Dataset training set for training, and we use
the remaining 185 low-light images for validation. We resize the images to size 256 x 256 to be used for both training and validation. Note that in order to train the DCE-Net,
we will not require the corresponding enhanced images.
Visualizing 100 train images from the Lol (low light) dataset
The Zero-DCE Framework
The goal of DCE-Net is to estimate a set of best-fitting light-enhancement curves (LE-curves) given an input image. The framework then maps all pixels of the input’s RGB channels by applying the curves iteratively to obtain the final enhanced image.
Understanding light-enhancement curves
A ligh-enhancement curve is a kind of curve that can map a low-light image to its enhanced version automatically, where the self-adaptive curve parameters are solely dependent on the input image. When designing such a curve, three objectives should be taken into account:
- Each pixel value of the enhanced image should be in the normalized range
[0,1], in order to avoid information loss induced by overflow truncation. - It should be monotonous, to preserve the contrast between neighboring pixels.
- The shape of this curve should be as simple as possible, and the curve should be differentiable to allow backpropagation.
The light-enhancement curve is separately applied to three RGB channels instead of solely on the illumination channel. The three-channel adjustment can better preserve the inherent color and reduce the risk of over-saturation.

DCE-Net
The DCE-Net is a lightweight deep neural network that learns the mapping between an input image and its best-fitting curve parameter maps. The input to the DCE-Net is a low-light image while the outputs are a set of pixel-wise curve parameter maps for corresponding higher-order curves. It is a plain CNN of seven convolutional layers with symmetrical concatenation. Each layer consists of 32 convolutional kernels of size 3×3 and stride 1 followed by the ReLU activation function. The last convolutional layer is followed by the Tanh activation function, which produces 24 parameter maps for 8 iterations, where each iteration requires three curve parameter maps for the three channels.

Loss functions
To enable zero-reference learning in DCE-Net, we use a set of differentiable zero-reference losses that allow us to evaluate the quality of enhanced images.
Color constancy loss
The color constancy loss is used to correct the potential color deviations in the enhanced image.
Exposure loss
To restrain under-/over-exposed regions, we use the exposure control loss.
It measures the distance between the average intensity value of a local region
and a preset well-exposedness level (set to 0.6).
Illumination smoothness loss
To preserve the monotonicity relations between neighboring pixels, the illumination smoothness loss is added to each curve parameter map.
Spatial consistency loss
The spatial consistency loss encourages spatial coherence of the enhanced image by preserving the contrast between neighboring regions across the input image and its enhanced version.
Deep curve estimation model
We implement the Zero-DCE framework as a Keras subclassed model.