Multimodal Semantic-Aware Automatic Colorization with Diffusion Prior
Han Wang Xinning Chai Yiwen Wang Yuhong Zhang Rong Xie Li Song




𝐱
ŁL



 





Han Wang, Xinning Chai, Yiwen Wang, Yuhong Zhang, Rong Xie, Li Song
Shanghai Jiao Tong University



Project page: https://servuskk.github.io/ColorDiff-Image/https://servuskk.github.io/ColorDiff-Image/

Multimodal Semantic-Aware Automatic Colorization with Diffusion Prior
    Lijing Shao
    April 29, 2024
=====================================================================






Colorizing grayscale images offers an engaging visual experience. Existing automatic colorization methods often fail to generate satisfactory results due to incorrect semantic colors and unsaturated colors. In this work, we propose an automatic colorization pipeline to overcome these challenges. We leverage the extraordinary generative ability of the diffusion prior to synthesize color with plausible semantics. To overcome the artifacts introduced by the diffusion prior, we apply the luminance conditional guidance. Moreover, we adopt multimodal high-level semantic priors to help the model understand the image content and deliver saturated colors. Besides, a luminance-aware decoder is designed to restore details and enhance overall visual quality. The proposed pipeline synthesizes saturated colors while maintaining plausible semantics. Experiments indicate that our proposed method considers both diversity and fidelity, surpassing previous methods in terms of perceptual realism and gain most human preference.




Automatic Colorization, Diffusion Models, Luminance Guidance, High-level Semantics






§ INTRODUCTION




Automatic colorization synthesizes a colorful and semantically plausible image given a grayscale image. It is a classical computer vision task that has been studied for decades. However, existing automatic colorization methods cannot provide satisfactory solution due to the two main challenges: incorrect semantic colors and unsaturated colors. 

Aiming to synthesize semantically coherent and perceptually plausible colors, generative models have been extensively incorporated into relevant research. Generative adversarial networks (GAN) based <cit.> and autoregressive-based <cit.> methods have made notable progress. Although the issue of incorrect semantic colors has been partially addressed, significant challenges still remain. See the yellow boxes in Figure <ref>, the semantic errors significantly undermine the visual quality. Recently, Denoising Diffusion Probabilistic Models(DDPM) <cit.> has demonstrated remarkable performance in the realm of image generation. With its exceptional generation capabilities, superior level of detail, and extensive range of variations, DDPM has emerged as a compelling alternative to the GAN. Moreover, the controllable generation algorithms based on the diffusion model have achieved impressive performance in various downstream tasks such as T2I <cit.>, image editing <cit.>, super resolution <cit.>, etc. In this work, we leverage the powerful diffusion prior to synthesize plausible images that align with real-world common sense. Unfortunately, applying pre-trained diffusion models directly to this pixel-wise conditional task lead to inconsistencies <cit.> that do not accurately align with the original grayscale input. Therefore, it becomes imperative to provide more effective condition guidance in order to ensure coherence and fidelity. We align the luminance channel both in the latent and pixel spaces. Specifically, our proposed image-to-image pipeline is fine-tuned based on pre-trained stable diffusion. The pixel-level conditions are injected into the latent space to assist the denoising U-Net in producing latent codes that are more faithful to grayscale images. A luminance-aware decoder is applied to mitigate pixel space distortion. 

In addition to incorrect semantics, another challenge in this task is unsaturated colors. For example, the oranges in the first two columns of Figure <ref> suffer from the unsaturated colors. To moderate the unsaturated colors, priors such as categories <cit.>, bounding boxes <cit.> and saliency maps <cit.> have been introduced in relevant research. Based on this insight, we
adopt multimodal high-level semantic priors to help the model understand the image content and generate vivid colors. To simultaneously generate plausible semantics and  vivid colors, multimodal priors, including category, caption, and segmentation, are injected into the generation process in a comprehensive manner.

In summary, we propose an automatic colorization pipeline to address the challenges in this task. The contributions of this paper are as follows:



    
  * We extend the stable diffusion model to automatic image colorization by introducing pixel-level grayscale conditions in the denoising diffusion. The pre-trained diffusion priors are employed to generate vivid and plausible colors.
    

    
  * We design a high-level semantic injection module to enhance the model's capability to produce semantically reasonable colors.    

    
  * A luminance-aware decoder is designed to mitigate pixel domain distortion and make the reconstruction more faithful to the grayscale input.     

    
  * Quantitative and qualitative experiments demonstrate that our proposed colorization pipeline provides high-fidelity, color-diversified colorization for grayscale images with complex content. User study further indicates that our pipeline gain more human preference than other state-of-the-art methods.




§ RELATED WORKS





Learning-based algorithms have been the mainstream of research on automatic colorization in recent years. Previous methods suffer from unsaturated colors and semantic confusion due to the lack of prior knowledge of color. In order to generate plausible colors, generative models have been applied to automatic colorization tasks, including adversarial generative networks <cit.> and transformers <cit.>. Besides,  <cit.> shows that diffusion models are more creative than GAN. DDPM has achieved amazing results in diverse natural image generation. Research based on DDPM has confirmed its ability to handle a variety of downstream tasks, including colorization <cit.>. To alleviate semantic confusion and synthesize more satisfactory results, priors are introduced into related research, including categories <cit.>, saliency maps <cit.>, bounding boxes <cit.>, etc.  





§ METHOD







 §.§ Overview



A color image y^lab, represented in CIELAB color space, contains three channels: lightness channel l and chromatic channels a and b. The automatic colorization aims to recover the chromatic channels from the grayscale image: x^gray→ŷ^lab.

In this work, we propose an automatic colorization pipeline for natural images based on stable diffusion. The pipeline consists of two parts: a variational autoencoder <cit.> and a denoising U-Net. Explicitly, the VAE is for the transformation between pixel space x∈ℛ^H× W× 3 and latent space z∈ℛ^h× w× c. While the denoising U-Net applies DDPM in the latent space to generate an image from Gaussian noise. 

The framework of our pipeline is shown in Figure <ref>. First, the VAE encodes grayscale image x^gray into latent code z_c. Next, the T-step diffusion process generates a clean latent code z_0 from Gaussian noise  z_T  under the guidance of image latent z_c and high-level semantics. Finally, z_0 is reconstructed by a luminance-aware decoder to obtain the color image ŷ. 

The pixel-level grayscale condition and high-level semantic condition for denoising process are introduced in the latent space, shown in the yellow box in Figure <ref>. We elaborate on the detailed injections of these conditions in Section <ref> and Section <ref>, respectively. As for the reconstruction processes, the detailed designs of the luminance-aware decoder are described in Section <ref>.






 §.§ Colorization Diffusion Model

Large-scale diffusion model has the capability to generate high-resolution images with complex structures. While naive usage of diffusion priors generates serious artifacts, we introduce pixel-level luminance information to provide detailed guidance.

Specifically, we use encoded grayscale image z_c as control condition to enhance U-Net's understanding of luminance information in the latent space. To involve the grayscale condition in the entire diffusion process, we simultaneously input the latent code z_t generated in the previous time step and the noise-free grayscale latent code z_c into the input layer of U-Net at each time step t:



    z^'_t = 𝚌𝚘𝚗𝚟_1×1(𝚌𝚘𝚗𝚌𝚊𝚝(z_t ,z_c))

In this way, we take advantage of the powerful generative capabilities of stable diffusion while preserve the grayscale condition. The loss function for our denoising U-Net is defined in a similar way to stable diffusion <cit.>:

    ℒ=𝔼_z,z_c,c,ϵ∼𝒩(0,1),t[||ϵ-ϵ_θ(z_t,t,z_c,c)||_2^2]

where z is the encoded color image, z_c is the encoded grayscale image, c is the category embedding, ϵ is a noise term, t is the time step, ϵ_θ is the denoising U-Net, z_t is the noisy version of z at time step t.



 §.§ High-level Semantic Guidance


To alleviate semantic confusion and generate vivid colors, we design a high-level semantic guidance module for inference. As shown in Figure <ref>, the multimodal semantics are generated by the pre-trained semantic generator in the blue box. Afterwards, text and segmentation priors are injected into the inference process through cross attention and segmentation guidance respectively, as shown in the yellow box in Figure <ref>. Specifically, given the grayscale image x^gray, the semantic generator produce the corresponding categories <cit.>,  captions <cit.> and segmentations <cit.>. The category, caption, and segmentation labels are in textual form, while the segmentation masks are binary masks.

For textual priors, the CLIP <cit.> encoder is employed to generate the text embedding c_t. The text embedding guidance is applied in denoising U-Net via cross-attention mechanism. Given the timestep t, the concatenated noisy input z_t and the text condition c_t, the latent code z_t-1 is produced by the Colorization Diffusion Model(CDM):

    z_t-1 = CDM(z_t,t,z_c,c_t)


For segmentation priors, we use the pre-trained transfiner <cit.> to generate paired segmentation masks ℳ and labels ℒ. For each instance, we first resize the binary mask ℳ^i ∈ℛ^H× W× 1 to align the latent space. The resized mask is represented as M^i ∈ℛ^h× w× 1. Then we use the CDM to yield the corresponding latent code z^i_t-1 of the masked region:

    z^i_t-1 = CDM(z_t,t,z_c× M^i,L^i)

Finally, we combine the original latent code z_t-1 and the instances to yield the segment-aware latent code ẑ_t-1:

    ẑ_t-1 = ∑_i=1^i=k [z_t-1× (1-M^i) + z^i_t-1× M^i]


We set a coefficient i∈ [0,1] to control the strength of segmentation guidance. The threshold is defined as T_th=T×(1-i). The segmentation mask is used to guide the synthesis process at inference time step t>T_th. We set i=0.3 for the experiment. Users have the flexibility to select a different value based on their preferences.



 §.§ Luminance-aware Decoder

As the downsampling to latent space inevitably lose detailed structures and textures, we apply the luminance condition to the reconstruction process and propose a luminance-aware decoder. To align the latent space with stable diffusion, we freeze the encoder. The intermediate grayscale features obtained in the encoder are added to the decoder through skip connections. 

Specifically, the intermediate features f_down^i generated by the first three downsample layers of the encoder are extracted. These features are convolved, weighted, and finally added to the corresponding upsample layers of the decoder:

    f̂_up^j=f_up^j + α_i ·𝚌𝚘𝚗𝚟(f_down^i),  i=0,1,2; j=3,2,1


We adopt L2 loss ℒ_2 and perceptual loss <cit.> ℒ_p to train the  luminance-aware decoder:

    ℒ=ℒ_2 + λ_pℒ_p





§ EXPERIMENT





 §.§ Implementation

We train the denoising U-Net and luminance-aware decoder separately. Firstly, we train the denoising U-Net on the imagenet <cit.> training set at the resolution of 512× 512. We initialize the U-Net using the pre-trained weights of  <cit.>. The learning rate is fixed at 5e-5. We use the classifier-free guidance <cit.> strategy and set the conditioning dropout probability to 0.05. The model is updated for 20K iterations with a batch size of 16. Then we train the luminance-aware decoder on the same dataset and at the same resolution. The VAE is initialized using the pre-trained weights of  <cit.>. We fix the learning rate at 1e-4 for 22,500 steps with a batch size of 1. We set the parameter λ_p in Eq.(<ref>) to 0.1. Our tests are conducted on the COCO-Stuff <cit.> val set containing 5,000 images of complex scenes. At inference, we adopt DDIM sampler <cit.> and set the inference time step T=50. We conduct all experiments on a single Nvidia GeForce RTX 3090 GPU.




 §.§ Comparisons


We compare with 6 state-of-the-art automatic colorization methods including 3 types: 1) GAN-based method: InstColor <cit.>, ChromaGAN <cit.>, BigColor <cit.>, 2)Transformer-based method: ColTran <cit.>, CT^2 <cit.>, 3) Diffusion-based method: ControlNet <cit.>.

Qualitative Comparison.
We show visual comparison results in Figure <ref>. The images in the first and second rows indicate the ability of the models to synthesise vivid colors. Both GAN-based and transformer-based algorithms suffer from unsaturated colors. Although ControlNet synthesises saturated colors, the marked areas contain significant artifacts. Images in the third and forth rows demonstrate the ability of the models to synthesise semantically reasonable colors. InstColor, ChromaGAN, BigColor, CT^2 and ControlNet fail to maintain the color continuity of the same object(discontinuity of colors between the head and tail of the train, hands and shoulders of the girl). While ColTran yields colors that defy common sense (blue shadows and blue hands). In summary, our method provides vivid and semantically reasonable colorization results.







User Study. To reflect human preferences, we randomly select 15 images from the COCO-Stuff val set for user study. For each image, the 7 results and ground truth are displayed to the user in a random order. We asked 18 participants to choose their top three favorites. Figure <ref> shows the proportion of the Top 1 selected by users. Our method has a vote rate of 22.59%, which significantly outperforms other methods.


Quantitative Comparison. We use Fréchet Inception Distance (FID) and colorfulness <cit.> to evaluate image quality and vividness. These two metrics have recently been used to evaluate the colorization algorithm <cit.> . Considering that colorization is an ill-posed problem, the ground-truth dependent metric PSNR used in previous works does not accurately reflect the quality of image and color generation <cit.>, and the comparison here is for reference. As shown in Table <ref>, our proposed method demonstrates superior performance in terms of FID when compared to the state-of-the-art algorithms. Even though ControlNet outperforms our algorithm in the colourful metric, the results shown in the qualitative comparison indicate that the artefacts are meaningless and negatively affect the visual effect of the image.




 §.§ Ablation Studies


The significance of the main components of the proposed method is discussed in this section. The quantitative and visual comparisons are presented in Table <ref> and Figure <ref>. 

High-level Semantic Guidance. We discuss the impact of high-level semantic guidance on model performance. The visuals shown in Figure <ref>(a) demonstrate our high-level guidance improves saturation of synthesised colors and mitigates failures caused by semantic confusion. The quantitative scores in Table <ref> confirm the significant improvement in both color vividness and perceptual quality introduced by the high-level semantic guidance.

Luminance-aware Decoder. The pipeline equipped with a luminance-aware decoder facilitates the generation of cognitively plausible colors. As shown in the first row of Figure <ref>(b), the artifacts are suppressed. Furthermore, the incorporation of this decoder yields a positive impact on the retrieval of image details, as demonstrated by the successful reconstruction of textual elements in the second row of Figure <ref>(b). Consequently, the full model outperforms the alternative in terms of FID. It is reported a slight decrease in colorfulness score after incorporating luminance awareness which can be attributed to the suppression of outliers, as discussed in Section <ref> regarding the analysis of the ControlNet.



§ CONCLUSION



In this study, we introduce an novel automatic colorization pipeline that harmoniously combines color diversity with fidelity.  It generate plausible and saturated colors by leveraging powerful diffusion priors with the proposed luminance and high-level semantic guidance. Besides, we design a luminance-aware decoder to restore image details and improve color plausibility. Experiments demonstrate that the proposed pipeline outperforms previous methods in terms of perceptual realism and attains the highest human preference compared to other algorithms.



§ ACKNOWLEDGEMENT



This work was supported by National Key R&D Project of China(2019YFB1802701), MoE-China Mobile Research Fund Project(MCM20180702), the Fundamental Research Funds for the Central Universities; in part by the 111 project under Grant B07022 and Sheitc No.150633; in part by the Shanghai Key Laboratory of Digital Media Processing and Transmissions.





IEEEbib


