Colorizing and upscaling a 1960 film using neural networks
We develop a fully automatic image colorization system. Our approach leverages recent advances in deep networks, exploiting both low-level and semantic representations. As many scene elements naturally appear according to multimodal color distributions, we train our model to predict per-pixel color histograms. This intermediate output can be used to automatically generate a color image, or further manipulated prior to image formation. On both fully and partially automatic colorization tasks, we outperform existing methods. We also explore colorization as a vehicle for self-supervised visual representation learning.READ FULL TEXT VIEW PDF
In self-supervised visual representation learning, a feature extractor i...
In this paper, we explore methods of complicating self-supervised tasks ...
Image colorization adds color to grayscale images. It not only increases...
Colorization is the method of converting an image in grayscale to a full...
Self-supervised learning has made unsupervised pretraining relevant agai...
Automatic generation of a high-quality video from a single image remains...
We introduce a deep multitask architecture to integrate multityped
Colorizing and upscaling a 1960 film using neural networks
Colorization of grayscale images is a simple task for the human imagination. A human need only recall that sky is blue and grass is green; for many objects, the mind is free to hallucinate several plausible colors. The high-level comprehension required for this process is precisely why the development of fully automatic colorization algorithms remains a challenge. Colorization is thus intriguing beyond its immediate practical utility in graphics applications. Automatic colorization serves as a proxy measure for visual understanding. Our work makes this connection explicit; we unify a colorization pipeline with the type of deep neural architectures driving advances in image classification and object detection.
Both our technical approach and focus on fully automatic results depart from past work. Given colorization’s importance across multiple applications (e.g. historical photographs and videos , artist assistance [38, 32]), much research strives to make it cheaper and less time-consuming [42, 22, 20, 3, 27, 6, 14, 7, 5]. However, most methods still require some level of user input [22, 34, 20, 3, 6, 14]. Our work joins the relatively few recent efforts on fully automatic colorization [27, 7, 5]. Some [7, 5] show promising results on typical scenes (e.g. landscapes), but their success is limited on complex images with foreground objects.
At a technical level, existing automatic colorization methods often employ a strategy of finding suitable reference images and transferring their color onto a target grayscale image [27, 7]. This works well if sufficiently similar reference images can be found, but is difficult for unique grayscale input images. Such a strategy also requires processing a large repository of reference images at test time. In contrast, our approach is free of database search and fast at test time. Section 2 provides a complete view of prior methods, highlighting differences.
Our approach to automatic colorization converts two intuitive observations into design principles. First, semantic information matters. In order to colorize arbitrary images, a system must interpret the semantic composition of the scene (what is in the image: faces, cars, plants, …) as well as localize objects (where things are). Deep convolutional neural networks (CNNs) can serve as tools to incorporate semantic parsing and localization into a colorization system.
Our second observation is that while some scene elements can be assigned a single color with high confidence, others (e.g. clothes or cars) may draw from many suitable colors. Thus, we design our system to predict a color histogram, instead of a single color, at every image location. Figure 2 sketches the CNN architecture we use to connect semantics with color distributions by exploiting features across multiple abstraction levels. Section 3 provides details.
Section 4 experimentally validates our algorithm against competing methods [42, 7] in two settings: fully (grayscale input only) and partially (grayscale input with reference global color histogram) automatic colorization. Across every metric and dataset [43, 31, 33]
, our method achieves the best performance. Our system’s fully automatic output is superior to that of prior methods relying on additional information such as reference images or ground-truth color histograms. To ease the comparison burden for future research, we propose a new colorization benchmark on ImageNet. We also experiment with colorization itself as an objective for learning visual representations from scratch, thereby replacing use of ImageNet pretraining in a traditional semantic labeling task.
Section 5 summarizes our contributions: (1) a novel technical approach to colorization, bringing semantic knowledge to bear using CNNs, and modeling color distributions; (2) state-of-the-art performance across fully and partially automatic colorization tasks; (3) a new ImageNet colorization benchmark; (4) proof of concept on colorization for self-supervised representation learning.
Scribble-based methods, introduced by Levin et al. , require manually specifying desired colors of certain regions. These scribble colors are propagated under the assumption that adjacent pixels with similar luminance should have similar color, with the optimization relying on Normalized Cuts . Users can interactively refine results via additional scribbles. Further advances extend similarity to texture [32, 25], and exploit edges to reduce color bleeding .
Transfer-based methods rely on availability of related reference image(s), from which color is transferred to the target grayscale image. Mapping between source and target is established automatically, using correspondences between local descriptors [42, 3, 27], or in combination with manual intervention [20, 6]. Excepting , reference image selection is at least partially manual.
In contrast to these method families, our goal is fully automatic colorization. We are aware of two recent efforts in this direction. Deshpande et al.  colorize an entire image by solving a linear system. This can be seen as an extension of patch-matching techniques , adding interaction terms for spatial consistency. Regression trees address the high-dimensionality of the system. Inference requires an iterative algorithm. Most of the experiments are focused on a dataset (SUN-6) limited to images of a few scene classes, and best results are obtained when the scene class is known at test time. They also examine another partially automatic task, in which a desired global color histogram is provided.
The work of Cheng et al.  is perhaps most related to ours. It combines three levels of features with increasing receptive field: the raw image patch, DAISY features , and semantic features . These features are concatenated and fed into a three-layer fully connected neural network trained with an loss. Only this last component is optimized; the feature representations are fixed.
, our system does not rely on hand-crafted features, is trained end-to-end, and treats color prediction as a histogram estimation task rather than as regression. Experiments in Section4 justify these principles by demonstrating performance superior to the best reported by [7, 5] across all regimes.
Two concurrent efforts also present feed-forward networks trained end-to-end for colorization. Iizuka & Simo-Serra et al.  propose a network that concatenates two separate paths, specializing in global and local features, respectively. This concatenation can be seen as a two-tiered hypercolumn; in comparison, our 16-layer hypercolumn creates a continuum between low- and high-level features. Their network is trained jointly for classification (cross-entropy) and colorization ( loss in Lab). We initialize, but do not anchor, our system to a classification-based network, allowing for fine-tuning of colorization on unlabeled datasets.
Zhang et al.  similarly propose predicting color histograms to handle multi-modality. Some key differences include their usage of up-convolutional layers, deep supervision, and dense training. In comparison, we use a fully convolutional approach, with deep supervision implicit in the hypercolumn design, and, as Section 3 describes, memory-efficient training via spatially sparse samples.
We frame the colorization problem as learning a function . Given a grayscale image patch , predicts the color of its center pixel. The patch size is the receptive field of the colorizer. The output space depends on the choice of color parameterization. We implement according to the neural network architecture diagrammed in Figure 2.
Motivating this strategy is the success of similar architectures for semantic segmentation [11, 24, 4, 15, 28] and edge detection [26, 12, 1, 35, 44]. Together with colorization, these tasks can all be viewed as image-to-image prediction problems, in which a value is predicted for each input pixel. Leading methods commonly adapt deep convolutional neural networks pretrained for image classification [33, 37]. Such classification networks can be converted to fully convolutional networks that produce output of the same spatial size as the input, e.g. using the shift-and-stitch method  or the more efficient à trous algorithm . Subsequent training with a task-specific loss fine-tunes the converted network.
Skip-layer connections, which directly link low- and mid-level features to prediction layers, are an architectural addition beneficial for many image-to-image problems. Some methods implement skip connections directly through concatenation layers [24, 4], while others equivalently extract per-pixel descriptors by reading localized slices of multiple layers [26, 28, 15]. We use this latter strategy and adopt the recently coined hypercolumn terminology  for such slices.
Though we build upon these ideas, our technical approach innovates on two fronts. First, we integrate domain knowledge for colorization, experimenting with output spaces and loss functions. We design the network output to serve as an intermediate representation, appropriate for direct or biased sampling. We introduce an energy minimization procedure for optionally biasing sampling towards a reference image. Second, we develop a novel and efficient computational strategy for network training that is widely applicable to hypercolumn architectures.
We generate training data by converting color images to grayscale according to . This is only one of many desaturation options and chosen primarily to facilitate comparison with Deshpande et al. . For the representation of color predictions, using RGB is overdetermined, as lightness is already known. We instead consider output color spaces with (or a closely related quantity) conveniently appearing as a separate pass-through channel:
Hue/chroma. Hue-based spaces, such as HSL, can be thought of as a color cylinder, with angular coordinate (hue), radial distance (saturation), and height (lightness). The values of and are unstable at the bottom (black) and top (white) of the cylinder. HSV describes a similar color cylinder which is only unstable at the bottom. However, is no longer one of the channels. We wish to avoid both instabilities and still retain as a channel. The solution is a color bicone, where chroma () takes the place of saturation. Conversion to HSV is given by .
For any output color representation, we require a loss function for measuring prediction errors. A first consideration, also used in , is regression in Lab:
where describes the vector space. However, regression targets do not handle multimodal color distributions well. To address this, we instead predict distributions over a set of color bins, a technique also used in :
where describes a histogram over bins, and is the KL-divergence. The ground-truth histogram is set as the empirical distribution in a rectangular region of size around the center pixel. Somewhat surprisingly, our experiments see no benefit to predicting smoothed histograms, so we simply set . This makes a one-hot vector and Equation (2) the log loss. For histogram predictions, the last layer of neural network is always a softmax.
There are several choices of how to bin color space. We bin the Lab axes by evenly spaced Gaussian quantiles (). They can be encoded separately for and (as marginal distributions), in which case our loss becomes the sum of two separate terms defined by Equation (2
). They can also be encoded as a joint distribution overand , in which case we let the quantiles form a 2D grid of bins. In our experiments, we set for marginal distributions and for joint. We determined these numbers, along with , to offer a good compromise of output fidelity and output complexity.
For hue/chroma, we only consider marginal distributions and bin axes uniformly in . Since hue becomes unstable as chroma approaches zero, we add a sample weight to the hue based on the chroma:
where and is the sample pixel’s chroma. We set , roughly the inverse expectation of , thus equally weighting hue and chroma.
Given network trained according to a loss function in the previous section, we evaluate it at every pixel in a test image: . For the loss, all that remains is to combine each with the respective lightness and convert to RGB. With histogram predictions, we consider options for inferring a final color:
Sample Draw a sample from the histogram. If done per pixel, this may create high-frequency color changes in areas of high-entropy histograms.
Mode Take the as the color. This can create jarring transitions between colors, and is prone to vote splitting for proximal centroids.
Median Compute cumulative sum of
and use linear interpolation to find the value at the middle bin. Undefined for circular histograms, such as hue.
Expectation Sum over the color bin centroids weighted by the histogram.
For Lab output, we achieve the best qualitative and quantitative results using expectations. For hue/chroma, the best results are achieved by taking the median of the chroma. Many objects can appear both with and without chroma, which means is a particularly common bin. This mode draws the expectation closer to zero, producing less saturated images. As for hue, since it is circular, we first compute the complex expectation:
We then set hue to the argument of remapped to lie in .
In cases where the estimate of the chroma is high and is close to zero, the instability of the hue can create artifacts. A simple, yet effective, fix is chromatic fading: downweight the chroma if the absolute value of is too small. We thus re-define the predicted chroma by multiplying it by a factor of . In our experiments, we set (obtained via cross-validation).
So far, we have only considered the fully automatic color inference task. Deshpande et al. , test a separate task where the ground-truth histogram in the two non-lightness color channels of the original color image is made available.111 Note that if the histogram of the channel were available, it would be possible to match lightness to lightness exactly and thus greatly narrow down color placement. In order to compare, we propose two histogram transfer methods. We refer to the predicted image as the source and the ground-truth image as the target.
Lightness-normalized quantile matching. Divide the RGB representation of both source and target by their respective lightness. Compute marginal histograms over the resulting three color channels. Alter each source histogram to fit the corresponding target histogram by quantile matching, and multiply by lightness. Though it does not exploit our richer color distribution predictions, quantile matching beats the cluster correspondence method of  (see Table 4).
Energy minimization. We phrase histogram matching as minimizing energy:
where is the number of pixels, are the predicted and posterior distributions, respectively. The target histogram is denoted by . The first term contains unary potentials that anchor the posteriors to the predictions. The second term is a symmetric distance to promote proximity between source and target histograms. Weight defines relative importance of histogram matching. We estimate the source histogram as . We parameterize the posterior for all pixels as: , where the vector can be seen as a global bias for each bin. It is also possible to solve for the posteriors directly; this does not perform better quantitatively and is more prone to introducing artifacts. We solve for using gradient descent on and use the resulting posteriors in place of the predictions. In the case of marginal histograms, the optimization is run twice, once for each color channel.
Our base network is a fully convolutional version of VGG-16  with two changes: (1) the classification layer (fc8) is discarded, and (2) the first filter layer (conv1_1) operates on a single intensity channel instead of mean-subtracted RGB. We extract a hypercolumn descriptor for a pixel by concatenating the features at its spatial location in all layers, from data to conv7 (fc7), resulting in a channel descriptor. We feed this hypercolumn into a fully connected layer with channels (h_fc1 in Figure 2), to which we connect output predictors.
Processing each pixel separately in such manner is quite costly. We instead run an entire image through a single forward pass of VGG-16 and approximate hypercolumns using bilinear interpolation. Even with such sharing, densely extracting hypercolumns requires significant memory ( GB for input).
To fit image batches in memory during training, we instead extract hypercolumns at only a sparse set of locations, implementing a custom Caffe layer to directly compute them.222 https://github.com/gustavla/autocolorize Extracting batches of only
hypercolumn descriptors per input image, sampled at random locations, provides sufficient training signal. In the backward pass of stochastic gradient descent, an interpolated hypercolumn propagates its gradients to the four closest spatial cells in each layer. Locks ensure atomicity of gradient updates, without incurring any performance penalty. This drops training memory for hypercolumns to onlyMB per image.
We initialize with a version of VGG-16 pretrained on ImageNet, adapting it to grayscale by averaging over color channels in the first layer and rescaling appropriately. Prior to training for colorization, we further fine-tune the network for one epoch on the ImageNet classification task with grayscale input. As the original VGG-16 was trained without batch normalization, scale of responses in internal layers can vary dramatically, presenting a problem for learning atop their hypercolumn concatenation. Liu et al.  compensate for such variability by applying layer-wise
normalization. We use the alternative of balancing hypercolumns so that each layer has roughly unit second moment (); Appendix (Section 0.A.1) provides additional details.
Starting from pretrained VGG-16-Gray, described in the previous section, we attach h_fc1 and output prediction layers with Xavier initialization , and fine-tune the entire system for colorization. We consider multiple prediction layer variants: Lab output with loss, and both Lab and hue/chroma marginal or joint histogram output with losses according to Equations (2) and (3). We train each system variant end-to-end for one epoch on the million images of the ImageNet training set, each resized to at most pixels in smaller dimension. A single epoch takes approximately 17 hours on a GTX Titan X GPU. At test time, colorizing a single pixel image takes seconds.
We setup two disjoint subsets of the ImageNet validation data for our own use: validation images (cval1k) and test images (ctest10k). Each set has a balanced representation for ImageNet categories, and excludes any images encoded as grayscale, but may include images that are naturally grayscale (e.g. closeup of nuts and bolts), where an algorithm should know not to add color. Category labels are discarded; only images are available at test time. We propose ctest10k as a standard benchmark with the following metrics:
RMSE: root mean square error in averaged over all pixels .
By virtue of comparing to ground-truth color images, quantitative colorization metrics can penalize reasonable, but incorrect, color guesses for many objects (e.g. red car instead of blue car) more than jarring artifacts. This makes qualitative results for colorization as important as quantitative; we report both.
Figures 1, 3, and 4 show example test results of our best system variant, selected according to performance on the validation set and trained for a total of epochs. This variant predicts hue and chroma and uses chromatic fading during image generation. Table 2 provides validation benchmarks for all system variants, including the trivial baseline of no colorization. On ImageNet test (ctest10k), our selected model obtains (RMSE, , avg/px) and dB (PSNR, RGB, avg/im), compared to and dB for the baseline.
Table 2 examines the importance of different neural network layers to colorization; it reports validation performance of ablated systems that include only the specified subsets of layers in the hypercolumn used to predict hue and chroma. Some lower layers may be discarded without much performance loss, yet higher layers alone (fc6..fc7) are insufficient for good colorization.
Our ImageNet colorization benchmark is new to a field lacking an established evaluation protocol. We therefore focus on comparisons with two recent papers [7, 5], using their self-defined evaluation criteria. To do so, we run our ImageNet-trained hue and chroma model on two additional datasets:
SUN-A  is a subset of the SUN dataset  containing object categories. Cheng et al.  train a colorization system on images and report results on test images. We were unable to obtain the list of test images, and therefore report results averaged over five random subsets of SUN-A images. We do not use any SUN-A images for training.
SUN-6, another SUN subset, used by Deshpande et al. , includes images from scene categories (beach, castle, outdoor, kitchen, living room, bedroom). We compare our results on test images to those reported in  for their method as well as for Welsh et al.  with automatically matched reference images as in . Following , we consider another evaluation regime in which ground-truth target color histograms are available.
Figure 5 shows a comparison of results on SUN-6. Forgoing usage of ground-truth global histograms, our fully automatic system produces output qualitatively superior to methods relying on such side information. Tables 4 and 4 report quantitative performance corroborating this view. The partially automatic systems in Table 4 adapt output to fit global histograms using either: (C) cluster correspondences , (Q) quantile matching, or (E) our energy minimization described in Section 3.4. Our quantile matching results are superior to those of  and our new energy minimization procedure offers further improvement.
Figures 7 and 7 compare error distributions on SUN-6 and SUN-A. As in Table 4, our fully automatic method dominates all competing approaches, even those which use auxiliary information. It is only outperformed by the version of itself augmented with ground-truth global histograms. On SUN-A, Figure 7 shows clear separation between our method and  on per-image PSNR.
The Appendix (Figures 14 and 15) provides anecdotal comparisons to one additional method, that of Charpiat et al. , which can be considered an automatic system if reference images are available. Unfortunately, source code of  is not available and reported time cost is prohibitive for large-scale evaluation ( minutes per image). We were thus unable to benchmark  on large datasets.
With regard to concurrent work, Zhang et al.  include a comparison of our results to their own. The two systems are competitive in terms of quantitative measures of colorization accuracy. Their system, set to produce more vibrant colors, has an advantage in terms of human-measured preferences. In contrast, an off-the-shelf VGG-16 network for image classification, consuming our system’s color output, more often produces correct labels, suggesting a realism advantage. We refer interested readers to  for the full details of this comparison.
Though we achieve significant improvements over prior state-of-the-art, our results are not perfect. Figure 8 shows examples of significant failures. Minor imperfections are also present in some of the results in Figures 3 and 4. We believe a common failure mode correlates with gaps in semantic interpretation: incorrectly identified or unfamiliar objects and incorrect segmentation. In addition, there are “mistakes” due to natural uncertainty of color – e.g. the graduation robe at the bottom right of Figure 3 is red, but could as well be purple.
Since our method produces histograms, we can provide interactive means of biasing colorizations according to user preferences. Rather than output a single color per pixel, we can sample color for image regions and evaluate color uncertainty. Specifically, solving our energy minimization formulation (Equation (5)) with global biases that are not optimized based on a reference image, but simply “rotated” through color space, induces changed color preferences throughout the image. The uncertainty in the predicted histogram modulates this effect.
Figure 9 shows multiple sampled colorizations, together with a visualization of uncertainty. Here, uncertainty is the entropy of the predicted hue multiplied by the chroma. Our distributional output and energy minimization framework open the path for future investigation of human-in-the-loop colorization tools.
High-level visual understanding is essential for the colorization of grayscale images, motivating our use of an ImageNet pretrained network as a starting point. But with enough training data, perhaps we can turn this around and use colorization as means of learning networks for capturing high-level visual representations. Table 6 shows that a colorization network, trained from scratch using only unlabeled color images, is surprisingly competitive. It converges slower, but requires not more than twice the number of epochs.
Our preliminary work shows that the networks learned via training colorization from scratch generalize well to other visual tasks. This is significant because such training requires no human annotation effort. It follows a recent trend of learning representations through self-supervision (e.g. context prediction , solving jigsaw puzzles , inpainting , adversarial feature learning [9, 10]).
We examine self-supervised colorization as a replacement for supervised ImageNet pretraining on the Pascal VOC 2012 semantic segmentation task, with results on grayscale validation set images. We train colorization from scratch on ImageNet (Table 6) and fine-tune for Pascal semantic segmentation. We make the one adjustment of employing cross-validated early stopping to avoid overfitting. Table 6 shows this strategy to be promising as a drop-in replacement for supervised ImageNet pretraining. Self-supervised colorization more than halfway bridges the gap between random initialization and supervised pretraining.
As VGG-16 is a more performant architecture, comparison with prior work is not straightforward. Yet, Table 6 still indicates that colorization is a front-runner among the self-supervision methods, leading to an 18-point improvement in mIU over the baseline. To our knowledge, 50.2% is the highest reported result that does not supplement training with additional annotated data .
We present a system that demonstrates state-of-the-art ability to automatically colorize grayscale images. Two novel contributions enable this progress: a deep neural architecture that is trained end-to-end to incorporate semantically meaningful features of varying complexity into colorization, and a color histogram prediction framework that handles uncertainty and ambiguities inherent in colorization while preventing jarring artifacts. Our fully automatic colorizer produces strong results, improving upon previously leading methods by large margins on all datasets tested; we also propose a new large-scale benchmark for automatic image colorization, and establish a strong baseline with our method to facilitate future comparisons. Our colorization results are visually appealing even on complex scenes, and allow for effective post-processing with creative control via color histogram transfer and intelligent, uncertainty-driven color sampling. We further reveal colorization as a promising avenue for self-supervised visual learning.
Acknowledgements. We thank Ayan Chakrabarti for suggesting lightness-normalized quantile matching and for useful discussions, and Aditya Deshpande and Jason Rock for discussions on their work. We gratefully acknowledge the support of NVIDIA Corporation with the donation of GPUs for this research.
Charpiat, G., Bezrukov, I., Altun, Y., Hofmann, M., Schölkopf, B.: Machine learning methods for automatic image colorization. In: Computational Photography: Methods and Applications. CRC Press (2010)
Doersch, C., Gupta, A., Efros, A.A.: Unsupervised visual representation learning by context prediction. In: Proceedings of the IEEE International Conference on Computer Vision. pp. 1422–1430 (2015)
Noroozi, M., Favaro, P.: Unsupervised learning of visual representations by solving jigsaw puzzles. In: ECCV (2016)
Patterson, G., Xu, C., Su, H., Hays, J.: The sun attribute database: Beyond categories for deeper scene understanding. International Journal of Computer Vision 108(1-2) (2014)
Tai, Y.W., Jia, J., Tang, C.K.: Local color transfer via probabilistic segmentation by expectation-maximization. In: CVPR (2005)
To adjust the scale of the activations of layer by factor , without changing any other layer’s activation, the weights and the bias are updated according to:
The activation of becomes:
inside the ReLU will not affect whether or not a value is rectified, so the two cases remain the same: (1) negative: the activation will be the corresponding feature inregardless of , and (2) positive: the ReLU becomes the identity function and and cancel to get back the original activation.
We set , estimated for each layer separately.
For images, each image with pixels, we calculate the error metrics as:
Where and for all .
Ideally the lightness is an unaltered pass-through channel. However, due to subtle differences in how is defined, it is possible that the lightness of the predicted image, , does not agree with the input, . To compensate for this, we add to all color channels in the predicted RGB image as a final corrective step.
A more detailed list of validation results for hue/chroma inference methods is seen in Table 7.
We provide additional samples for global biasing (Figure 12) and SUN-6 (Figure 13). Comparisons with Charpiat et al.  appear in Figures 14 and 15. Examples of how our algorithm can bring old photographs to life in Figure 16. More examples on ImageNet (ctest10k) in Figures 17 to 20 and Figure 21 (failure cases). Examples of histogram predictions in Figures 10 and 11.
Overview of document revisions:
ECCV 2016 camera-ready version. Includes discussion about concurrent work and new experiments using colorization to learn visual representations (Section 4.1).
Added overlooked reference.