SketchDeco: Decorating B&W Sketches with Colour

Chaitat UtintuInterned with SketchX Pinaki Nath ChowdhuryAneeshan SainSubhadeep KoleyAyan Kumar BhuniaYi-Zhe Song

Utintu et al.

SketchX, CVSSP, University of Surrey, United Kingdom

{p.chowdhury, a.sain, s.koley, a.bhunia<EMAIL_ADDRESS>
This paper introduces a novel approach to sketch colourisation, inspired by the universal childhood activity of colouring and its professional applications in design and story-boarding. Striking a balance between precision and convenience, our method utilises region masks and colour palettes to allow intuitive user control, steering clear of the meticulousness of manual colour assignments or the limitations of textual prompts. By strategically combining ControlNet and staged generation, incorporating Stable Diffusion v$1.5$, and leveraging BLIP-2 text prompts, our methodology facilitates faithful image generation and user-directed colourisation. Addressing challenges of local and global consistency, we employ inventive solutions such as an inversion scheme, guided sampling, and a self-attention mechanism with a scaling factor. The resulting tool is not only fast and training-free but also compatible with consumer-grade Nvidia RTX 4090 Super GPUs, making it a valuable asset for both creative professionals and enthusiasts in various fields.

§ INTRODUCTION

Seated in a cafe, the motivation for this paper arose from watching my child engrossed in colouring – an experience we've all shared during our childhood. The task is to add colour to black and white sketches, yielding results that are aesthetically pleasing (often not!). Beyond being a child's pastime, this activity holds professional value in product design and animation story-boarding, where artists breathe life into initial concept sketches (<ref>a). This paper seeks to accomplish this dual purpose – solving the beloved childhood game while simultaneously offering a much-needed sketch colouring tool for professionals in various creative fields.

Tackling this task is anything but child's play. The central challenge lies in control – how do we determine what colours to be applied, and where? Prior work began with laborious region-by-region colour assignments [78, 55, 11], and later evolved towards the utilisation of reference images [75, 32, 39, 8, 74]. Despite yielding aesthetically pleasing results, these methods often prove excessively meticulous. The latest approaches draw inspiration from the Text-to-Image (T2I) paradigm [9, 2, 76, 7, 71]. They employ text descriptions specifying both the region and its colour, , “colour the back of a car blue and its front red”. Albeit convenient, results often lack precision, e.g., the blue might extend to other regions of the car! Furthermore, the colours might not look holistically pleasant, e.g., you might end up with an unattractive car! (See <ref>b).

(A) An artist colouring initial concept sketches. (B) Prior works on sketch colouring [76] that use text descriptions often lack precision. Hence, we focus on precision and convenience by requiring designers to specify the region mask (, use Photoshop) and its desired colours palettes. Our training-free method figures out the optimal way to colour specified regions with chosen colours.

In this paper, we aim to strike a delicate balance between precision and convenience. We steer away from requiring designers (or kids) to meticulously specify colours for each region through points or scribbles. Simultaneously, we avoid an overly flexible approach that sacrifices precision in control, such as relying solely on textual prompts. Our solution lies in a combination of region masks and colour palettes (see <ref>b) – utilising region masks to specify the “where” and colour palettes to indicate the desired colour scheme. The AI's task then becomes figuring out the optimal way to colour the specified region with the chosen palette, while making sure the global result is harmonious in colour. This might initially seem laborious, with the right user interface, the process becomes effortless. Masks can be easily obtained using common tools (e.g., `Magic Wand' in Photoshop) under a few seconds, and each mask after selected will have a drop-down menu pop up where users can choose from predefined colour palettes (or manually create new ones).

Our solution revolves around the strategic use of ControlNet and staged coarse-to-fine generation. Initially, we employ ControlNet [79] with Stable Diffusion [50] to generate a high-quality image from the input sketch, transforming the challenging task of sketch colourisation [78] into a well-explored image colourisation problem [75]. To enhance fidelity, we further integrate a text prompt from BLIP-2 [34]. With a globally coloured sketch in hand, user control is then introduced. Colour names from the chosen palette serve as text prompts to ControlNet [79] along with corresponding masks, generating locally coloured masks (see <ref>b).

It follows that the globally coloured sketch and locally coloured masks are blended to create a final harmonious image with smooth colour transitions. This task poses challenges as (i) we should sidestep training or fine-tuning that could compromise the rich priors inherent in large-scale diffusion models [50], (ii) we must enforce a “local colour consistency” property, , the localised colouring should be constrained to be within that region and only that region, and (iii) there is a demand for global consistency, , specifically coloured regions and assigned colours for those left back should appear harmonic.

To tackle the first challenge, we approach it as an image composition problem [25, 82, 47, 77], employing a diffusion inversion scheme [59, 45, 41, 67]. This inversion entails reverse-order sampling to transform coloured patches into a noise vector, essentially finding an initial noise vector that generates coloured image patches upon denoising.

For the latter challenge, we employ a combination of two strategies: (i) utilising DPM-Solver++[40] for inversion due to its superior alignment, crucial for localised colouring, and (ii) implementing guided sampling [45, 41] in the diffusion process to seamlessly blend local colour palettes. Specifically, we leverage classifier-free guidance (CFG) [24], where each diffusion step involves dual predictions — one conditionally using a text prompt (, , hyper-realistic, $\dots$) and the other unconditionally using a special placeholder token, known as an exceptional prompt [41]. While the exceptional prompt aims to mitigate the instability[Classifier-free guidance (CFG) magnifies its accumulated error.] of CFG [16, 24] and accurately reconstruct the input coloured patches, the text prompt enables meaningful (and artistic) blending of local colour palettes.

Addressing the final challenge, we observe that while the text prompt is crucial for blending colours across user-specified local regions, it results in a lack of global consistency. Two main issues arise: (i) the shape of the input sketch is not preserved in the denoised generated image, and (ii) the local colour palettes are blended across the entire image, neglecting the intended locality of colours. This is attributed to the amplification of the effect induced by text conditioning [24]. To overcome this, we introduce two key modifications: (i) a self-attention mechanism with an exceptional prompt to maintain global consistency in shape (, faithfulness to the input sketch) and the locality of colours, and (ii) the incorporation of a scaling factor (hyper-parameter) $\tau$ to balance the trade-off between textual and spatial guidance with self-attention.

In summary, our contributions are: (i) we present an innovative sketch colourisation approach that harmonises precision and convenience, using region masks and colour palettes for intuitive user control. (ii) our methodology integrates ControlNet and staged generation, incorporating Stable Diffusion v$1.5$ and BLIP-2 text prompts for faithful image generation and user-directed colourisation. (iii) we tackle challenges of local and global consistency through inventive solutions, including an inversion scheme, guided sampling, and a self-attention mechanism with a scaling factor. Last but not least, it has the added benefit of being (iv) fast (takes $15$ to $20$ steps), training-free, and works on a consumer-grade Nvidia RTX 4090 Super GPU.

§ RELATED WORKS

Sketch-to-Image Generation: Sketch-to-image generation [29] diverges from traditional image-to-image translation[26, 83, 31, 84, 12, 48] by aiming to generate realistic images from input sketches, bridging the gap between hand-drawn sketches and real images. SketchyGAN[10] pioneers this task by employing GANs[19] alongside edge-preserving image augmentations, while ContextualGAN[42] utilises conditional GANs to learn joint image-sketch representations. Given the difficulty in acquiring paired sketch-image datasets, some researchers have explored unsupervised[38] and self-supervised[36, 53] learning paradigms to tackle this challenge. Subsequent studies have enhanced results by fine-tuning pre-trained StyleGAN models[70] or leveraging VQGAN to minimise discrepancies between ground truth image-sketch embeddings[20]. Despite these advancements, existing GANs-based methods for sketch-to-image generation often suffer from issues of unstable training and inferior quality, leading to a shift towards diffusion models[23, 66, 69, 79, 35, 46]. In this paper, we utilise pre-trained text-to-image (T2I) diffusion models and address sketch-to-image generation problem
as a downstream task.

Diffusion Models for Vision Tasks: Diffusion models[23, 59, 58], a recent category of generative models, surpass the result quality, fidelity, and stability of training of GANs[19] and VAEs[28]. The core principle of diffusion models revolves around training a denoising autoencoder to learn the inverse of a Markov process. Among them, Rombach [50] propose the Latent Diffusion Models (LDMs), which later known as Stable Diffusion (SD), aiming to reduce computational complexity by conducting diffusion process in a latent space instead of pixel space and introducing conditional control via cross-attention mechanism[64]. In particular, text-to-image (T2I) diffusion models utilise textual information to guide iterative denoising steps and yield success across various visual downstream tasks, including image generation[11], style transfer[25], manipulation[73], inpainting [43], and composition[41], etc. Instead of only textual guidance, additional semantic modalities, , sketch, can be utilised for improving controllability and fidelity. The naive method to achieve this is to retrain the entire diffusion models[69, 11, 25], hence requiring a massive amount of computational cost. To mitigate this constraint, certain studies suggest finetuning hypernetworks for domain adaptation, such as ControlNet[79], GLIGEN[35], and T2I-Adapter [46]. However, recent methods have found more practical ways to add extra conditions to the diffusion process without the need for retraining or fine-tuning[57, 41, 44]. They achieve this by directing UNet's[51] denoising process with cross-attention maps[64]. Therefore, we explore a training-free approach to tackle the realistic sketch colourisation problem.

Image Colourisation: In contrast to traditional methods[17, 18], Deep Learning (DL)-based image colourisation[13, 56, 30, 61, 72] has gained significant traction and advancement in recent years. DL-based methods for image colourisation can be categorised into three primary types based on their control mechanisms: reference-based[32, 72, 39, 8, 74], text-based[9, 2, 76, 7, 71], and user-guided approaches[2, 33, 6, 25, 81]. Reference-based techniques aim to incorporate colour information from a reference image into a target greyscale image by establishing correspondences using pixel-level[39], or semantic segment-level similarity measures[8]. Some approaches enhance realism by integrating colour priors from GANs[72] or pre-trained neural networks[74]; however, they often struggle due to insufficient semantic guidance. Text-based methods offer an alternative by using textual descriptions or prompts to guide colourisation, either through attention mechanisms blending natural language with image features[9], employing text semantics to create colour palettes[2], separating language conditions into a colour and object space[7, 71], or utilising pre-trained text-to-image models[76, 52]. Nevertheless, these methods face challenges including limited vocabulary range and imprecise results, constraining expressiveness and creativity. User-guided colourisation seeks to overcome these limitations by spreading user-annotated colours to nearby pixels based on similarity[2, 5], framing the task as an optimisation problem[33], or incorporating global hints like colour palettes[6, 25] or local hints like colour scribbles[81, 4]. In our study, we adopt a user-guided approach, introducing a text-free colourisation framework that empowers users to express their creativity by providing input sketch along with instance-aware colour palettes for overall guidance or part-aware colour palettes for local guidance to direct the colourisation process.

§ PROPOSED METHOD

Fig. 2: Our training-free method takes sketch $\mathcal{S}$, region masks $\mathcal{M}$, and colour hexcodes $\mathcal{P}_{H}$ as inputs. The sketch is fed to BLIP-2 to detect class semantics (, `cow'). Next, we use Stable Diffusion with class semantics with positive & negative prompts to generate a global colourised image $\mathcal{I}_{\mathcal{P}_{\phi}}$ (generic colours given no colour names in text prompt) and $\mathcal{I}_{\mathcal{P}_{{H}_{i}}}$ (specific coloured patches with colour names in text prompt). We combine global images with masks $\mathcal{M}$ to get composited image $\mathcal{I}^{\ast}$. To blend colours across multiple patches, we invert $\mathcal{I}^{\ast}$ using inverse sampling followed by denoising using DPM-Solver++, CFG with normal and exceptional prompts to get the final image.

Overview: We propose a new paradigm to sketch colourisation in Fig. 2 – one that does not require any training, works on a consumer-grade GPU, and leverages the rich prior of large-scale diffusion models [50] and vision-language models [34]. This is in sharp contrast to prior works on both (i) sketch colourisation [78, 55] that typically trains custom networks on limited sketch categories and colour palette, thereby lacking generalisation required for practical deployment; and (ii) image colourisation [75] that either use expensive training of custom networks from scratch [6, 2] or fine-tuning [76, 75, 65]  that undermines the rich prior of large-scale diffusion models. Our cheap inference and emphasis on the reuse of existing well-studied modules from various sub-domains in computer vision help practical deployment and democratisation of sketch colourisation.

§.§ Background

Pixel Space Diffusion Models: Diffusion Probabilistic Models (DPMs)[23, 16, 59] approximate a data distribution \(p(x)\) by gradually denoising a normally distributed variable. The denoising function is trained to invert a fixed Markov Chain process of length \(T\). Diffusion modelling is composed of two stochastic processes: \(forward\) and \(backward\) diffusion[59]. During training, the \(forward\) diffusion process is responsible to gradually add Gaussian noise to the image \(x_{0}\in \mathbb{R}^{H\times W\times3}\) and produce a noisy image \(x_{t}\in \mathbb{R}^{H\times W\times3}\), which can be formulated as \( x_{t}=\sqrt{ \bar{\alpha}_{t}}x_{0} + (\sqrt{1-\bar{\alpha}_{t}})\epsilon \), where, \(\epsilon \sim \mathcal{N}(0,\textbf{I})\) represents the added Gaussian noise, \(\alpha_{t}\) controls the levels of noise varied from \(\alpha_{0}=1\) to \(\alpha_{T}\simeq 0\), and time-step \(t\) denotes the number of times noise is added, which is uniformly sampled from \(\left \{1,...,T\right \}\)[59]. For the \(backward\) diffusion process, The denoising autoencoders \(\epsilon_{\theta }(\cdot)\) are learned to predict a denoised output by optimising the following objective:

\begin{equation}
\mathcal{L}_\textrm{DM}=\mathbb{E}_{x,\epsilon \sim \mathcal{N}(0,1),t}\left [ \left \| \epsilon -\epsilon _{\theta }(x_{t},t) \right \| _{2}^{2}\right ]
\vspace{-2mm}
\end{equation}

During inference, the trained denoising autoencoder network \(\epsilon_{\theta }(\cdot)\) is applied iteratively for \(T\) time-steps on a randomly sampled Gaussian noise \(x_{T}\) until it becomes fully denoised image \(x_{0}\), recovering target data distribution[59].

Latent Diffusion Models: Instead of learning the target data distribution in high-dimensional pixel space, Latent Diffusion Models (, Stable Diffusion [50]) exploit an autoencoder – comprising of an encoder \(\mathcal{E}(\cdot)\) and decoder \(\mathcal{D}(\cdot)\) (, UNet backbone[51]) – to perform \(forward\) and \(backward\) diffusion on an efficient low-dimensional latent space [50]. Given the input image \(x_{0}\in \mathbb{R}^{H\times W\times3}\) in pixel space, the encoder downsamples \(x_{0}\) by the factor \(f=H/h=W/w\) to its a latent representation \(z_{0}\in \mathbb{R}^{h\times w\times d}\) as: \(z_{0}=\mathcal{E}(x_{0})\)[50], then the decoder \(\mathcal{D}\) tries to restore to the original version \(\tilde{x_{0}}=\mathcal{D}(z_{0})=\mathcal{D}(\mathcal{E}(x_{0}))\). The conditional image generation is feasible via augmenting their underlying UNet backbone with the cross-attention mechanism[64], thus the conditional denoising network \(\epsilon _{\theta }(z_{t},t,c)\) can learn \(p(z|c)\), where \(c\) represents conditional embedding computed from the additional condition. The objective function is modified as:

\begin{equation}
\label{eq2}
\mathcal{L}_\textrm{LDM}=\mathbb{E}_{\mathcal{E}(x),c,\epsilon \sim \mathcal{N}(0,1),t}\left [ \left \| \epsilon -\epsilon _{\theta }(z_{t},t,c) \right \| _{2}^{2}\right ]
\end{equation}

Text-Conditioned Diffusion Model: Latent Diffusion Models[50] can incorporate different conditions (, text[50], sketch [79], etc.) to guide the diffusion process via optimising a modified objective function (see <ref>). To pre-process textual prompt \(p\), the first step includes applying a text-embedding function \(\textbf{T}(\cdot)\) to generate text-embedding \(\textbf{T}(p)\). Subsequently, the pre-trained CLIP[49] text encoder \(\mathrm{\mathcal{E}}_{t}(\cdot)\) is utilised to project text-embedding to intermediate representation as text encoding \(t_{p}=\mathrm{\mathcal{E}}_{t}(\textbf{T}(p))\), which is then mapped to the intermediate layers of the UNet backbone via a cross-attention layer[64] using \( \text{Attention}(Q,K,V) = \text{softmax}\left( \frac{QK^{T}}{\sqrt{d}} \right)\cdot V \) with:

\begin{equation}
Q=W_{Q}\cdot z_{t},\,
K=W_{K}\cdot t_{p},\,
V=W_{V}\cdot t_{p}
\vspace{-1mm}
\end{equation}

where, \(W_{Q}, W_{K}, W_{V}\) are learnable projection matrices. \(W_{K}\) and \(W_{V}\) linearly projects the text encoding \(t_{p}\in \mathbb{R}^{77\times 768}\) to form the Key and Value vectors. Whereas, \(W_{Q}\) projects intermediate noisy latents to form Query maps[50].

§.§ Sketch-to-Image Generation

To generate a realistic image \(\mathcal{I}\) based on input sketch \(\mathcal{S}\), we employ the generative prior derived from a robust pre-trained text-to-image diffusion model. Distinct from textual conditioning \(t_{p}\), sketch inputs embody spatial information [54]. In this paper, we harness the capabilities of the pre-trained Scribble ControlNet[79] to attain superior fidelity and realism in the conversion of sketches to images. Given the sketch latents \(z_{s} = \mathcal{E}_{s}(\mathcal{S}); \ z_{s} \in \mathbb{R}^{h \times w \times d}\), the noise estimator \(\epsilon _{\theta }(z_{t},t,t_{p},z_{s})\) need to incorporate sketch condition \(p(z|t_{p},z_{s})\). Moreover, the integration of positive (, “hyper-realistic”) and negative (, “unrealistic”) textual prompts augments the quality of the generated results.

Sketch as Controllable Condition: We leverage ControlNet[79], a trainable adaptor engineered to operate alongside Stable Diffusion, which is initialised by partially copying the backbone UNet of Stable Diffusion. This adaptor assumes a pivotal role in mitigating catastrophic forgetting during the fine-tuning process when incorporating image-text pairs and

additional spatial control information[79] (, segmentation masks, scribbles, sketches, key poses, depth maps, colour palettes, or their weighted combinations), alongside the intermediate, noisy generated image. Subsequently, the conditioning signals are then directed into the various decoder blocks of the generation model. The connectivity from the control adaptor to the generation model is established via zero-convolutions \( \mathcal{Z}_{s} \), which strategically preserves the generative priors at the start of training. Given the input sketch \(\mathcal{S}\in \mathbb{R}^{512\times 512\times 3}\), ControlNet exploits tiny sketch encoder \(\mathcal{E}_{s}(.)\), composes of four convolution layers with \(4\times4\) kernels and \(2\times2\) strides, to encode input sketch \(\mathcal{S}\) to sketch latents \(z_{s}=\mathcal{E}_{s}(\mathcal{S})\), \(z_{s}\in \mathbb{R}^{64\times 64\times d}\). During training, the conditional UNet network \(\epsilon _{\theta }(z_{t},t,t_{p},z_{s})\) within Stable Diffusion now learns to optimise the following objective:

\begin{equation}
\mathcal{L}_\textrm{LDM}=\mathbb{E}_{\mathcal{E}(x),t_{p},\mathcal{Z}_{s},\epsilon \sim \mathcal{N}(0,1),t}\left [ \left \| \epsilon -\epsilon _{\theta }(z_{t},t,t_{p},z_{s}) \right \| _{2}^{2}\right ]
\end{equation}

§.§ Global Sketch Colourisation

To facilitate user creativity, we introduce a novel approach in the form of a prompt-free and training-free global sketch colourisation framework. This framework operates solely on input of sketch \(\mathcal{S}\in \mathbb{R}^{512\times 512\times3}\) and colour palette \(\mathcal{P_{H}}=\left\{ h\;|\;h\;\text{is a hexadecimal colour code}\right\}\), and aims to harness generative priors from Stable Diffusion for efficient colourisation. The proposed method has dual objectives: (a) generate faithful images \(\mathcal{I}^{G}\) from input sketch (, \(id(\mathcal{I}^{G}) \approx id(\mathcal{S})\)) that preserve identity and shape, and (b) achieve a vivid outcome by blending colours given the input colour hexcodes (, \(\textit{colour}(\mathcal{I}^{G})\approx\textit{colour}(\mathcal{P_{H}})\)). Toward these objectives, we identify the following challenges: (i) our pipeline is prompt-free (no input text from the user), however, sketch-to-image generation fails without adding class information [79] of the sketch () in textual conditioning ($t_{p}$). (ii) convert input hexcodes to colour names that describe colour palettes for global colour conditioning using textual conditioning ($t_{p}$).
To overcome these challenges, we (i) employ a vision-language pre-training model (VLP)[34] and reframe it as a visual question answering (VQA) problem to bridge the gap between sketch and class information. (ii) to retrieve the most appropriate colour name from the input colour hexcode, we integrate a straightforward yet efficient K-Dimensional Tree (KD-Tree)[3] algorithm.

Predicting Class Semantics: We adopt the robust language-vision pre-training (VLP) technique, BLIP-2[34], which addresses the domain gap between image and text modalities. BLIP-2 leverages two pre-trained uni-modal models, namely CLIP's image encoder and LLM, to bootstrap its architecture. The core element of BLIP-2 is the Q-former[34], comprising two transformers: the image transformer and the text transformer, which share the same self-attention layers. Throughout the training process, BLIP-2 incorporates a set of learnable query embeddings as input to the image transformer. These queries dynamically interact with each other and textual features via self-attention layers, as well as with image features via cross-attention layers. This mechanism enables the queries to extract visual information that is most relevant to the text. Moreover, by employing distinct self-attention masks, the interaction between queries and text can be manipulated to address diverse tasks (, image captioning, image-text retrieval, and visual question answering, etc.)[34]. We adopt the Visual Question Answering (VQA) task of BLIP-2 to infer class information from the input sketch by prompting questions (, “What is this object in this sketch?”). The resulting system works for open-set zero-shot class prediction across a wide spectrum of sketches, thanks to the generalisability of BLIP-2.

Colour-to-Name Mapping with KD-Tree: To convert colour hexcodes into colour names, we use the industry standard CSS3 colour database [1]. Note, not all hexcodes have a matching colour name, hence we employ a binary search tree known as the K-Dimensional Tree (KD-Tree)[3] to search the nearest neighbour query (, colour name). KD-Trees organise multidimensional data to facilitate rapid retrieval of nearest neighbours based on some specified criteria. We begin by constructing a KD-Tree (with \(K=3\)) using the RGB colour values extracted from the database of $147$ CSS3 colours [1]. This process guarantees that every colour within the search space \(\mathbb{R}^{3}\) possesses a corresponding colour name. Thereafter, the hexadecimal colour code \(\mathcal{P_{H}}=\left\{ h\;|\;h\;\text{is a hexadecimal colour code}\right\}\) is converted to RBG values \(\mathcal{P}_{rgb}=\left\{(r, g, b)\;|\;r, g, b \in [0, 255]\right\}\), followed by using KD-Tree to locate the nearest colour name in \(\mathbb{R}^{3}\). Once all queried colour hexcodes are retrieved \(\mathcal{P}_{name}=\left\{ c_s\;|\;c_s\;\text{is colour name string}\right\}\),

the resulting textual prompt is integrated with additional information (, class semantics, positive prompts, and negative prompts) to construct the comprehensive textual guidance $t_{p}$ as: “, hyper-realistic, quality, photography style, using only colours in colour palette of , -  - $\dots$ ” and negative prompts “drawing look, sketch look, line art style, cartoon look, unnatural colour, unnatural texture, unrealistic look, low-quality”.

§.§ Local Sketch Colourisation

Prior methods [15] for local sketch colourisation typically involve treating colourisation as a manipulation task by iteratively colouring individual regions using masks and instructions to capture the complex spatial colour relationships. However, such approaches often rely solely on textual prompts for describing both colour information and locations to be colourised, limiting user expressiveness.

To mitigate this limitation, recent efforts [65] have enabled users to select multiple masks and colours for inpainting in parallel, but are restricted to a single colour per region. On the other hand, [25] provides users with editable masks conditioned by a colour palette that expands the range of available colour choices for each region. However, despite their advantages, prior works necessitate retraining or fine-tuning the pre-trained text-to-image diffusion model.

To capitalise on the rich priors of large-scale diffusion models, we present a training-free framework for controlling the colourisation of multiple regions within a sketch in parallel. Given a user-defined sketch \(\mathcal{S}\in \mathbb{R}^{512\times 512\times3}\), local colour palettes \( \left\{ {\mathcal{P}_{H}}_{1}, {\mathcal{P}_{H}}_{2}, ..., {\mathcal{P}_{H}}_{n}\right\} \), where,  \({\mathcal{P}_{H}}\) is a list of colour hexcodes \(\left\{h_1, h_2, \dots \right\}\),

and their binary mask for regions-of-interest \(\left\{\mathcal{M}^{(1)}, \mathcal{M}^{(2)}, ..., \mathcal{M}^{(n)}\right\}\); \(\mathcal{M} \in \mathbb{R}^{512\times 512\times1}\), we employ a generative prior derived from the pre-trained Text-to-Image (T2I) stable diffusion v2.1 model to enrich the semantic information and seamlessly blend colours. The colourised result \(\mathcal{I}^{L}\) is expected to fulfil three objectives: (a) maintain the identity of the input sketch (, \(id(\mathcal{I}^{L}) \approx id(\mathcal{S})\)), (b) preserve local colour consistency – the colour palette within mask region \(\mathcal{M}\) should align with the corresponding colour hexcodes \(\mathcal{P_{H}}\) (, \(\text{colour}(\mathcal{I}^{L}\odot\mathcal{M})\approx\text{colour}(\mathcal{P_{H}})\)), (c) homogeneous transitions between local coloured regions.

Parallel Local Colour Composition: We reframe the local sketch colourisation problem as an image composition task, drawing upon the rationale that the colourised outcomes derived from the global colourisation pipeline \(\mathcal{I}^{G}\) already addresses our first objective: maintaining sketch identity (, \(id(\mathcal{I}^{G}) \approx id(\mathcal{S})\)) and aligning with the specified colour palettes (, \(\text{colour}(\mathcal{I}^{G})\approx\text{colour}(\mathcal{P_{H}})\)). To achieve this, we first concurrently produce the globally-colourised results \( \left\{ {\mathcal{I}}^{G}_{{\mathcal{P}_{H}}_{1}}, {\mathcal{I}}^{G}_{{\mathcal{P}_{H}}_{2}}, ..., {\mathcal{I}}^{G}_{{\mathcal{P}_{H}}_{n}} \right\}\) based on given colour palettes \( \left\{ {\mathcal{P}_{H}}_{1}, {\mathcal{P}_{H}}_{2}, ..., {\mathcal{P}_{H}}_{n} \right\}\). Moreover, we generate an additional image \({\mathcal{I}}^{G}_{\mathcal{P}\phi}\) without colour description, which serves as the main image for the composition process. Thereafter, we apply the corresponding mask to each globally-colourised result for background removal to isolate the region-of-interest for each colour hexcodes as \({\mathcal{I}}^{G}_{\mathcal{M}^{(i)}}={\mathcal{I}}^{G}_{{\mathcal{P}_{H}}_{i}}\odot\mathcal{M}^{(i)}\), for \(i=1,2,...,n\) and $\odot$ denotes hadamard product. Next, we integrate all segmented local colour images with the main image to get composited result \({\mathcal{I}}^{\ast}={\mathcal{I}}^{G}_{\mathcal{P}\phi} \odot(1-{\mathcal{M}}_{tot})+\sum_{i=1}^{n}{\mathcal{I}}^{G}_{\mathcal{M}^{(i)}}\), where, \({\mathcal{M}}_{tot}=\max(\sum_{i=1}^{n}{\mathcal{M}}^{(i)}, 1)\). This injects the colour-blending ability of our global colourisation pipeline into local colourisation process and ensures local colour consistency in the final output.

ODE Inversion on Composited Image: The composited image $\mathcal{I}^{\ast}$ satisfies our second objective – local colour consistency – but lacks smooth transition between local coloured regions (third objective). In order to achieve smooth transitions between local colourised regions, a crucial step involves transforming the composited image \({\mathcal{I}}^{\ast}\) into a latent representation \(z^{\ast}\).

The sampling process within the diffusion probabilistic models (DPM) can be executed by solving diffusion ordinary differential equations (ODE) from \(T\) to \(0\)[60]:

\begin{equation}
\label{eq:ode}
\frac{dx_{t}}{dt}=f(t)x_{t}+\frac{g^{2}(t)}{2\sigma_{t}}\epsilon_{\theta}(x_{t},t),\;\;\text{ where, }\;\;x_{T}\sim \mathcal{N}(0,\tilde{\sigma}^{2}I),
\end{equation}

Hence, the inversion process can be achieved by solving the diffusion ODE from \(0\) to \(T\). We utilise DPM-Solver++[40] for inversion due to its fast-guided sampling ability and generate higher-quality samples in 15 to 20 steps, compared to commonly-used DDIM [59] that achieves similar results in 100 to 250 steps. Additionally, DPM-Solver++ demonstrates superior alignment between forward and backward trajectories, which makes it suitable for real image inversion and maintains local colour consistency. However, in the context of T2I diffusion models, numerous studies[21, 45, 63, 67] have faced notable challenges associated with significant reconstruction errors, particularly when attempting to perform inversion in the text-conditioned setting \(\epsilon_{\theta}(x_{t},t,t_{p})\). This issue primarily arises from the inherent instability of classifier-free guidance (CFG) mechanisms:

\begin{equation}
\label{eq: cfg}
\hat{\epsilon}_{\theta}(x_{t},t,t_{p},\varnothing )=s\cdot \epsilon_{\theta}(x_{t},t,t_{p})+(1-s)\cdot \epsilon_{\theta}(x_{t},t,\varnothing)
\end{equation}

where, \(t_{p}=\mathrm{\mathcal{E}}_{t}(\textbf{T}(p))\) and \(\varnothing=\mathrm{\mathcal{E}}_{t}(`` \ ")\) denotes text encodings of normal and null prompt (empty string) embeddings, and \(s\) is the guidance scale. In this study, we replace null prompt with exceptional prompt embedding \(\textbf{T}_{except}\)[41], which sets all token numbers to a common value [41] and removes positional embeddings and special tokens like , , and . This leads to more accurate inversion \(\epsilon_{\theta}(x_{t},t,\mathrm{\mathcal{E}}_{t}(\textbf{T}_{except}))\), as any information included in the prompt causes backward ODE trajectories to deviate from forward trajectories.

Initial Gaussian Noise Incorporation: After inversion process \(\mathcal{I}^{\ast}\rightarrow z^{\ast}\), we incorporate the additional Gaussian noise \(z^{+}\) to enhance transition smoothness by leveraging the rich generative priors [50] to effectively in-paint the transition area between regions inside (, \(\mathcal{M}_{tot}\)) and outside (, \(1-\mathcal{M}_{tot}\)) the user masks. Initially, we determine the spatial extent of each regional mask \(\mathcal{M}\) by computing its coverage rectangular area \(\mathcal{M}_{rect}\). Subsequently, we identify the transitional area \(\mathcal{M}_{tran}\) by employing the summation of XOR operation \(\oplus\) results between each rectangular area and its corresponding user-defined mask as \({\mathcal{M}}_{tran}=\max(\sum_{i=1}^{n}({{\mathcal{M}}_{rect}^{i}}\oplus{\mathcal{M}}^{i}), 1)\). Therefore, the initial noise incorporation for final diffusion ODE solving becomes: \( z^{\ast}_{f} = z^{\ast}\odot(1-\mathcal{M}_{tran})+z^{+}\odot\mathcal{M}_{tran}\).

Self-attention Injection for Global Consistency:  In the final backward diffusion process, the incorporated noise  \({z}^{\ast}_{f}\) derived from the composite image  \({\mathcal{I}}^{\ast}\) serves as the initial point for solving the diffusion ODE from \(T\) to \(0\). Throughout this process, the additional prompt \(p\) (, “hyper-realistic  in photography style.”) plays a pivotal role in blending colours in transitional regions seamlessly. Nevertheless, relying solely on initial noise may not adequately retain the colour context (, \(\textit{colour}(\mathcal{I}^{L}\odot\mathcal{M}) \not\approx\textit{colour}(\mathcal{P_{H}})\)) or the fidelity of sketch (, \(id(\mathcal{I}^{L}) \not\approx id(\mathcal{S})\)). To address this, we inject the self-attention map  \({\mathcal{A}}^{\ast}_{l,t}\) of the composited image  \({\mathcal{I}}^{\ast}\) to guide the denoising process. This self-attention map is derived using self-attention modules from the pre-trained Stable Diffusion model, incorporating exceptional prompt embedding \(\textbf{T}_{except}\) for enhanced contextual understanding. Particularly, the self-attention module at layer \(l\) composes of three projection matrices as \(W_{Q_{l}}, W_{K_{l}}, W_{V_{l}}\) and the encoded features of composited image at timestep \(t\) and layer \(l\) is \({z}^{\ast}_{l,t}\in \mathbb{R}^{h\times w\times d}\), we compute the self-attention map \({\mathcal{A}}^{\ast}_{l,t}\)  by  \( {\mathcal{A}}^{\ast}_{l,t} = \text{softmax}\left( \frac{Q_{l,t}K^{T}_{l,t}}{\sqrt{d}} \right)\cdot V_{l,t} \) with:

\begin{equation}
Q_{l,t}=W_{Q_{l}}\cdot {z}^{\ast}_{l,t},\,
K_{l,t}=W_{K_{l}}\cdot {z}^{\ast}_{l,t},\,
V_{l,t}=W_{V_{l}}\cdot {z}^{\ast}_{l,t}.
\end{equation}

In the sampling process to produce the colourised output \(\mathcal{I}^{L}\) guided by prompt \(p\), we inject the globally-controlled self-attention map \({\mathcal{A}}^{\ast}_{l,t}\) by simultaneously solving the diffusion ODE using an exceptional prompt embedding \(\textbf{T}_{except}\). However, achieving a balanced trade-off between textual and spatial guidance is essential. Therefore, we introduce a scaling factor \(\tau\) to regulate this trade-off. During the initial phase \(t\in[T,T\cdot(1-\tau)]\) we inject the self-attention map \({\mathcal{A}}^{\ast}_{l,t}\) to maintain global fidelity; whereas, in the subsequent phase \(t\in[T\cdot(1-\tau),0]\) the text encoding \(t_{p}\) from the text prompt \(p\) assumes the role of facilitating smooth transitions and colour-blending throughout the local colourised regions.

§ EXPERIMENTS

Dataset: In our study, we evaluate the effectiveness of our proposed method using three different datasets: AFHQ-cat[14] and AFHQ-dog[14]. To ensure the reliability and validity of our findings, we have examined on a substantial number of samples. Specifically, our analysis is based on 5153 images from the training set of AFHQ-cat, as well as 4739 images from the training set of AFHQ-dog. To extract the sketch representation, we apply an effective edge detection algorithm, PiDiNet[62], on all datasets to obtain sketch representations. Following this, we employ the K-Means clustering algorithm (with K=4) to identify the four most dominant colours in each input image, thereby constructing the colour palette. For further qualitative evaluation, we also apply our proposed method to a set of 15 randomly sourced sketches (see Supplemental) obtained from <www.freepik.com> with search keywords: “black-and-white  sketch”.

Implementation Details: Our global sketch colourisation approach involves combining the pre-trained Stable Diffusion v$1.5$[50] with the scribble ControlNet[79]. To extract class semantics, we utilise BLIP2's Q-former[34], bridging the domain gap with a Visual Question Answering (VQA) task. This allows us to obtain class semantics, representing categories or types of objects depicted in the sketches. We retrieve colour names by employing a binary search tree, known as a K-dimensional (KD-Tree) [3] on the RGB search space. To ensure clarity and avoid ambiguity, we restrict our colour selection to those available in the standard CSS3 colour database[1]. For the local sketch colourisation pipeline, we employ an inversion technique based on the guided sampler DPM-Solver++[40] applied to the pre-trained Stable Diffusion v2.1 model. In particular, all experiments are conducted on a single Nvidia RTX 4090 Super GPU, with each colourisation taking approximately 30 seconds – 5 seconds for global colourisation pipeline, and 25 seconds to complete local colourisation.

§.§ Competitors

We perform qualitative comparison against two state-of-the-art (SOTA) diffusion-based approaches: DiffBlender [27] and DiSS[11]. DiffBlender aims to enhance the functionality of Text-to-Image diffusion models by integrating inputs from multiple modalities. These inputs are processed based on their conditional types, which include image/sketches, spatial tokens (, bounding boxes), and non-spatial tokens (, colour palettes). For fair comparison, we use a combination of sketch and colour palette modalities, equivalent to our global sketch colourisation. As for DiSS, the primary objective is to generate realistic images based on sketch and stroke conditions. DiSS also proposes a region-sensitive stroke-to-image method using partially coloured strokes as input, to synthesise diverse content in the non-coloured regions. For a fair comparison with our approach, we use a single colour instead of a colour palette. To the best of our knowledge, there is no prior work addressing the use of masks and colour palettes for region-aware colourisation. Importantly, unlike our method, existing SOTA methods [27, 11] are not training-free and require expensive fine-tuning.

Comparison with SOTA diffusion-based approaches. Our training-free colourisation approach outperforms state-of-the-art (SOTA) models, DiffBlender [27] and DiSS[11], in various aspects including colour vividness, colour harmonisation, fidelity to the original sketch, and overall realistic look.

§.§ Qualitative Evaluation

Fig. <ref> illustrates the effectiveness of our proposed technique in the task of colourisation while adhering closely to the prescribed specifications for both sketch and colour. In contrast to competing methods, our sketch colourisation pipelines (, global and local) deliver superior outcomes without the need for retraining or fine-tuning the text-to-image diffusion model. Additionally, our pipelines are capable of executing multi-region colourisation concurrently. This capability allows us to fully preserve and exploit the generative prior encoded in the pre-trained model. Employing a training-free approach, our proposed system is not confined to specific domains, thus demonstrating robustness in generalisation and adaptability. To validate this assertion, we apply our proposed method to a selection of 15 randomly sourced sketches obtained from <www.freepik.com> using search keywords: “black-and-white  sketch”. The results of this experimentation are depicted in Fig. <ref>.

§.§ Performance Analysis

We employ FID [22] to measure the realism of generated images and LPIPS [80]

Quantitative Evaluation.

2*Methods     2cAFHG-cat[14]     2cAFHQ-dog[14]

(lr)2-3 (l)4-5
FID\(\downarrow\)      LPIPS\(\downarrow\)      FID\(\downarrow\)     LPIPS\(\downarrow\)

(r)1-1 (lr)2-3 (l)4-5
DiffBlender           78.44     0.828     141.02     0.860

T2I-Adapter           51.11     0.707     139.92     0.753

Proposed     56.51     0.665     60.90     0.677

to evaluate their alignment with ground-truth images. Lower FID and LPIPS scores indicate higher perceptual quality and improved alignment between the generated image and ground truth. It's crucial to highlight that the quantitative analysis outlined in <ref> solely focuses on our global colourisation performance as it also plays an integral role in contributing the local colourisation stage. Furthermore, in local colourisation, our method (, incorporating multiple masks with corresponding colour palettes) represents a novel and unique approach, without any direct comparison available yet. To ensure fairness in comparison, identical textual prompts and colour palettes are used across all frameworks.

Input Sketch     Mask with colour     Composited Image     Final Result

Qualitative evaluation on randomly sourced sketches. We randomly sourced sketches from <www.freepik.com> with search keywords “black-and-white  sketch” and used Photoshop to create masks and preferred colour palettes. Our local colourisation method allows users to precisely define the colour composition in each region (, wings or body of the bird) while the AI figures out the optimal way to colour the specified region with the chosen palette. See supplemental for more examples.

§.§ Ablative Studies

Contributions of Attention Maps: Fig. <ref> illustrates different variations of the generated results obtained by incorporating various combinations of attention map injections, starting from the baseline. In the baseline scenario, the composition is generated by solving diffusion ODE from time step T to 0 using DPM-Solver++[40] without any injection as described in Eq. <ref>. (i) we notice that increasing number of attention maps does not necessarily lead to any improvement in the results, particularly in our local colourisation task, where it is crucial to preserve both colour and sketch faithfulness. (ii) since our framework allows for the manipulation of multiple region-aware colourisation concurrently, injecting redundant attention maps would introduce the computational complexity, as it requires solving additional diffusion ODEs, which scales with the increasing input masks. Consequently, in our framework, only the self-attention map of the composited image is injected, ensuring that the number of diffusion processes remains constant at two for any given number of colourised regions. Furthermore, our design on using one attention map still outperforms other injection combinations, as the key contribution is on preserving details only, while the transitional harmonisation task is primarily nominated to textual guidance.

Ablative Studies.  (i) No injection: without using attention map injection $\mathcal{A}^{\ast}_{l, t}$, (ii-vi) Injection A-E: different combinations of attention map injection:
\({\mathcal{I}}^{G}_{\mathcal{M}}\)),
\({\mathcal{I}}^{G}_{\mathcal{M}}\))+SA(\({\mathcal{I}}^{G}_{\mathcal{M}}\)),
\({\mathcal{I}}^{G}_{\mathcal{P}\phi}\)+SA(\({\mathcal{I}}^{G}_{\mathcal{P}\phi}\)),
\({\mathcal{I}}^{G}_{\mathcal{P}\phi}\)), where, SA: self-attention and
CA: cross-attention. (vii) Null prompt inversion: change from exceptional prompt to null prompt [45]. (viii) Our method: default settings as in <ref>.

Effect of Exceptional Prompt \(\textbf{T}_{except}\): To assess the impact of the exceptional prompt \(\textbf{T}_{except}\), we can evaluate its contribution by substituting it with a null prompt (, unconditional term of classifier-free guidance (CFG) described in Eq. <ref>) during the inversion process. As illustrated in Fig. <ref>, we observe a notable decrease in colour vibrancy and fidelity of content in the output compared to the default baseline outcome. This decline in quality may stem from the inaccurate inversion caused by the inclusion of special symbols in the null prompt (,  $\dots$). These additional symbols, along with varying row vectors, induce shifts in embeddings along different directions, thereby disrupting the image pattern and introducing information shifting. Hence, in our study, we decide to choose the exceptional prompt approach to facilitate more accurate inversion by eliminating these tokens, which seems to be the key factors to deviate backward ODE trajectories from the forward one.

Impact of Scaling Factor \(\tau\): The ablation studies illustrated in Fig. <ref> showcase the resulting images obtained from varying scaling factors \(\tau\). (i) it is observed that as the value of \(\tau\) decreases, the transitional colour regions blend together smoothly and mix naturally, relying more on the normal prompt guidance (, , hyper-realistic, $\dots$). However, when \(\tau\) reaches 0, the output notably loses fidelity to the original sketch and colour, as only the initially composited noise contributes to these semantics. (ii) with an increase in the value of \(\tau\), the original context of the sketch and colour is preserved due to the self-attention mechanism mentioned in Sec. <ref>. However, if this value becomes excessively high, the smoothing ability diminishes entirely, resulting in the final output closely resembling the composited image \({\mathcal{I}}^{\ast}\). Thus, there exists a `sweet spot' typically between 0.3 and 0.6, where users can freely adjust this balance according to their subjective preferences to achieve coherent colourised results. Throughout our experiments, we empirically set \(\tau\) to 0.4.

Trade-off between harmonisation and faithfulness. A low $\tau=0.0$ gives better harmonisation of colours but lacks faithfulness (, missing regions in the wings of `butterfly') whereas a high $\tau=1.0$ gives highly faithful image generation but lacks sufficient harmonisation of colours (, the red patch on `cow').

§ CONCLUSION

In conclusion, our work introduced a novel approach to sketch colourisation, one that achieves a striking balance between precision and convenience by utilising region masks (easily generated from Photoshop) and colour palettes to allow intuitive user control. Our solution combines ControNet and staged generation, BLIP-2 for class semantics in text prompts, DPM-Solver++, guided sampling, and a self-attention mechanism with a scaling factor. The resulting model enforces a “local colour consistency” property, , the localised colouring is constrained to only within that region. Finally, our model is fast (takes less than $20$ steps), training-free, and works on consumer-grade Nvidia RTX 4090 GPU.

[1]
CSS Color Module Level 3. <https://www.w3.org/TR/css-color-3/>, Accessed: 2024-03-03

[2]
Bahng, H., Yoo, S., Cho, W., Park, D.K., Wu, Z., Ma, X., Choo, J.: Coloring with Words: Guiding Image Colorization Through Text-based Palette Generation. In: ECCV (2018)

[3]
Bentley, J.L.: Multidimensional binary search trees used for associative searching. Communications of the ACM  (1975)

[4]
Bhunia, A.K., Gajjala, V.R., Koley, S., Kundu, R., Sain, A., Xiang, T., Song, Y.Z.: Doodle It Yourself: Class Incremental Learning by Drawing a Few Sketches. In: CVPR (2022)

[5]
Bhunia, A.K., Koley, S., Kumar, A., Sain, A., Chowdhury, P.N., Xiang, T., Song, Y.Z.: Sketch2Saliency: Learning to Detect Salient Objects from Human Drawings. In: CVPR (2023)

[6]
Chang, H., Fried, O., Liu, Y., DiVerdi, S., Finkelstein, A.: Palette-based Photo Recoloring. In: SIGGRAPH (2015)

[7]
Chang, Z., Weng, S., Li, Y., Li, S., Shi, B.: L-CoDer: Language-Based Colorization with Color-Object Decoupling Transformer. In: ECCV (2022)

[8]
Charpiat, G., Hofmann, M., Schölkopf, B.: Automatic Image Colorization Via Multimodal Predictions. In: ECCV (2008)

[9]
Chen, J., Shen, Y., Gao, J., Liu, J., Liu, X.: Language-Based Image Editing with Recurrent Attentive Models. In: CVPR (2018)

[10]
Chen, W., Hays, J.: SketchyGAN: Towards Diverse and Realistic Sketch to Image Synthesis. In: CVPR (2018)

[11]
Cheng, S.I., Chen, Y.J., Chiu, W.C., Tseng, H.Y., Lee, H.Y.: Adaptively-Realistic Image Generation from Stroke and Sketch with Diffusion Model. In: WACV (2023)

[12]
Cheng, Y.C., Lee, H.Y., Sun, M., Yang, M.H.: Controllable Image Synthesis via SegVAE. In: ECCV (2020)

[13]
Cheng, Z., Yang, Q., Sheng, B.: Deep Colorization. In: ICCV (2015)

[14]
Choi, Y., Uh, Y., Yoo, J., Ha, J.W.: StarGAN v2: Diverse Image Synthesis for Multiple Domains. In: CVPR (2020)

[15]
Couairon, G., Verbeek, J., Schwenk, H., Cord, M.: DiffEdit: Diffusion-based semantic image editing with mask guidance. In: ICLR (2023)

[16]
Dhariwal, P., Nichol, A.: Diffusion Models Beat GANs on Image Synthesis. In: NeurIPS (2021)

[17]
Fabian, B., Carsten, D., Filip, S.: A Fast and Efficient Semi-guided Algorithm for Flat Coloring Line-arts. In: VMV (2018)

[18]
Furusawa, C., Hiroshiba, K., Ogaki, K., Odagiri, Y.: Comicolorization: Semi-Automatic Manga Colorization. In: SIGGRAPH (2017)

[19]
Goodfellow, I.J., Pouget-Abadie, J., Mirza, M., Xu, B., Warde-Farley, D., Ozair, S., Courville, A., Bengio, Y.: Generative Adversarial Networks. In: NeurIPS (2014)

[20]
Ham, C., Tarres, G.C., Bui, T., Hays, J., Lin, Z., Collomosse, J.: CoGS: Controllable Generation and Search from Sketch and Style. In: ECCV (2022)

[21]
Hertz, A., Mokady, R., Tenenbaum, J., Aberman, K., Pritch, Y., Cohen-Or, D.: Prompt-to-Prompt Image Editing with Cross Attention Control. In: ICLR (2023)

[22]
Heusel, M., Ramsauer, H., Unterthiner, T., Nessler, B., Hochreiter, S.: GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium. In: NeurIPS (2017)

[23]
Ho, J., Jain, A., Abbeel, P.: Denoising Diffusion Probabilistic Models. In: NeurIPS (2020)

[24]
Ho, J., Salimans, T.: Classifier-Free Diffusion Guidance. In: NeurIPS Workshop on Deep Generative Models and Downstream Applications (2021)

[25]
Huang, L., Chen, D., Liu, Y., Shen, Y., Zhao, D., Zhou, J.: Composer: Creative and Controllable Image Synthesis with Composable Conditions. In: ICML (2023)

[26]
Kim, J., Kim, M., Kang, H., Lee, K.H.: U-GAT-IT: Unsupervised Generative Attentional Networks with Adaptive Layer-Instance Normalization for Image-to-Image Translation. In: ICLR (2020)

[27]
Kim, S., Lee, J., Hong, K., Kim, D., Ahn, N.: DiffBlender: Scalable and Composable Multimodal Text-to-Image Diffusion Models. arXiv preprint arXiv:2305.15194  (2023)

[28]
Kingma, D.P., Welling, M.: Auto-Encoding Variational Bayes. arXiv preprint arXiv:1312.6114  (2013)

[29]
Koley, S., Bhunia, A.K., Sain, A., Chowdhury, P.N., Xiang, T., Song, Y.Z.: Picture that Sketch: Photorealistic Image Generation from Abstract Sketches. In: CVPR (2023)

[30]
Larsson, G., Maire, M., Shakhnarovich, G.: Colorization as a Proxy Task for Visual Understanding. In: CVPR (2017)

[31]
Lee, H.Y., Tseng, H.Y., Huang, J.B., Singh, M.K., Yang, M.H.: Diverse Image-to-Image Translation via Disentangled Representations. In: ECCV (2018)

[32]
Lee, J., Kim, E., Lee, Y., Kim, D., Chang, J., Choo, J.: Reference-Based Sketch Image Colorization using Augmented-Self Reference and Dense Semantic Correspondence. In: CVPR (2020)

[33]
Levin, A., Lischinski, D., Weiss, Y.: Colorization Using Optimization. In: SIGGRAPH (2004)

[34]
Li, J., Li, D., Savarese, S., Hoi, S.: BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models. arXiv preprint arXiv:2301.12597  (2023)

[35]
Li, Y., Liu, H., Wu, Q., Mu, F., Yang, J., Gao, J., Li, C., Lee, Y.J.: GLIGEN: Open-Set Grounded Text-to-Image Generation. In: CVPR (2023)

[36]
Liu, B., Zhu, Y., Song, K., Elgammal, A.: Self-Supervised Sketch-to-Image Synthesis. In: AAAI (2021)

[37]
Liu, H., Li, C., Wu, Q., Lee, Y.J.: Visual Instruction Tuning. arXiv preprint arXiv:2304.08485  (2023)

[38]
Liu, R., Yu, Q., Yu, S.: Unsupervised Sketch-to-Photo Synthesis. In: ECCV (2020)

[39]
Liu, X., Wan, L., Qu, Y., Wong, T.T., Lin, S., Leung, C.S., Heng, P.A.: Intrinsic colorization. In: SIGGRAPH (2008)

[40]
Lu, C., Zhou, Y., Bao, F., Chen, J., Li, C., Zhu, J.: DPM-Solver++: Fast Solver for Guided Sampling of Diffusion Probabilistic Models. arXiv preprint arXiv:2211.01095  (2023)

[41]
Lu, S., Liu, Y., Kong, A.W.K.: TF-ICON: Diffusion-Based Training-Free Cross-Domain Image Composition. In: ICCV (2023)

[42]
Lu, Y., Wu, S., Tai, Y.W., Tang, C.K.: Image Generation from Sketch Constraint Using Contextual GAN. In: ECCV (2018)

[43]
Lugmayr, A., Danelljan, M., Romero, A., Yu, F., Timofte, R., Gool, L.V.: RePaint: Inpainting using Denoising Diffusion Probabilistic Models. In: CVPR (2022)

[44]
Mo, S., Mu, F., Lin, K.H., Liu, Y., Guan, B., Li, Y., Zhou, B.: FreeControl: Training-Free Spatial Control of Any Text-to-Image Diffusion Model with Any Condition. arXiv preprint arXiv:2312.07536  (2023)

[45]
Mokady, R., Hertz, A., Aberman, K., Pritch, Y., Cohen-Or, D.: Null-text Inversion for Editing Real Images using Guided Diffusion Models. arXiv preprint arXiv:2211.09794  (2022)

[46]
Mou, C., Wang, X., Xie, L., Wu, Y., Zhang, J., Qi, Z., Shan, Y., Qie, X.: T2I-Adapter: Learning Adapters to Dig out More Controllable Ability for Text-to-Image Diffusion Models. arXiv preprint arXiv:2302.08453  (2023)

[47]
Niu, L., Cong, W., Liu, L., Hong, Y., Zhang, B., Liang, J., Zhang, L.: Making Images Real Again: A Comprehensive Survey on Deep Image Composition. arXiv preprint arXiv:2106.14490  (2023)

[48]
Park, T., Liu, M.Y., Wang, T.C., Zhu, J.Y.: Semantic Image Synthesis with Spatially-Adaptive Normalization. In: CVPR (2019)

[49]
Radford, A., Kim, J.W., Hallacy, C., Ramesh, A., Goh, G., Agarwal, S., Sastry, G., Askell, A., Mishkin, P., Clark, J., Krueger, G., Sutskever, I.: Learning Transferable Visual Models From Natural Language Supervision. In: ICML (2021)

[50]
Rombach, R., Blattmann, A., Lorenz, D., Esser, P., Ommer, B.: High-Resolution Image Synthesis with Latent Diffusion Models. In: CVPR (2022)

[51]
Ronneberger, O., Fischer, P., Brox, T.: U-Net: Convolutional Networks for Biomedical Image Segmentation. In: MICCAI (2015)

[52]
Sain, A., Bhunia, A.K., Chowdhury, P.N., Koley, S., Xiang, T., Song, Y.Z.: CLIP for All Things Zero-Shot Sketch-Based Image Retrieval, Fine-Grained or Not. In: CVPR (2023)

[53]
Sain, A., Bhunia, A.K., Potlapalli, V., Chowdhury, P.N., Xiang, T., Song, Y.Z.: Sketch3T: Test-time Training for Zero-Shot SBIR. In: CVPR (2022)

[54]
Sangkloy, P., Jitkrittum, W., Yang, D., Hays, J.: A Sketch Is Worth a Thousand Words: Image Retrieval with Text and Sketch. In: ECCV (2022)

[55]
Sangkloy, P., Lu, J., Fang, C., Yu, F., Hays, J.: Scribbler: Controlling Deep Image Synthesis with Sketch and Color. In: CVPR (2017)

[56]
Satoshi, L., Edgar, S.S., Hiroshi, I.: Let there be Color!: Joint End-to-end Learning of Global and Local Image Priors for Automatic Image Colorization with Simultaneous Classification. In: SIGGRAPH (2016)

[57]
Si, C., Huang, Z., Jiang, Y., Liu, Z.: FreeU: Free Lunch in Diffusion U-Net. arXiv preprint arXiv:2309.11497  (2023)

[58]
Sohl-Dickstein, J., Weiss, E.A., Maheswaranathan, N., Ganguli, S.: Deep Unsupervised Learning using Nonequilibrium Thermodynamics. In: ICML (2015)

[59]
Song, J., Meng, C., Ermon, S.: Denoising Diffusion Implicit Models. In: ICLR (2021)

[60]
Song, Y., Sohl-Dickstein, J., Kingma, D.P., Kumar, A., Ermon, S., Poole, B.: Score-Based Generative Modeling through Stochastic Differential Equations. In: ICLR (2021)

[61]
Su, J.W., Chu, H.K., Huang, J.B.: Instance-aware Image Colorization. In: CVPR (2020)

[62]
Su, Z., Liu, W., Yu, Z., Hu, D., Liao, Q., Tian, Q., Pietikäinen, M., Liu, L.: Pixel Difference Networks for Efficient Edge Detection. In: ICCV (2021)

[63]
Tumanyan, N., Geyer, M., Bagon, S., Dekel, T.: Plug-and-Play Diffusion Features for Text-Driven Image-to-Image Translation. arXiv preprint arXiv:2211.12572  (2022)

[64]
Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A.N., Kaiser, L., Polosukhin, I.: Attention Is All You Need. In: NeurIPS (2017)

[65]
Vavilala, V., Forsyth, D.: Applying a Color Palette with Local Control using Diffusion Models. arXiv preprint arXiv:2307.02698  (2023)

[66]
Voynov, A., Aberman, K., Cohen-Or, D.: Sketch-Guided Text-to-Image Diffusion Models. In: SIGGRAPH (2023)

[67]
Wallace, B., Gokul, A., Naik, N.: EDICT: Exact Diffusion Inversion via Coupled Transformations. In: CVPR (2023)

[68]
Wang, J., Yang, Z., Hu, X., Li, L., Lin, K., Gan, Z., Liu, Z., Liu, C., Wang, L.: GIT: A Generative Image-to-text Transformer for Vision and Language. arXiv preprint arXiv:2205.14100  (2022)

[69]
Wang, Q., Kong, D., Lin, F., Qi, Y.: DiffSketching: Sketch Control Image Synthesis with Diffusion Models. In: BMVC (2022)

[70]
Wang, S.Y., Bau, D., Zhu, J.Y.: Sketch Your Own GAN. In: ICCV (2021)

[71]
Weng, S., Wu, H., Chang, Z., Tang, J., Li, S., Shi, B.: L-CoDe:Language-Based Colorization Using Color-Object Decoupled Conditions. In: AAAI (2022)

[72]
Wu, Y., Wang, X., Li, Y., Zhang, H., Zhao, X., Shan, Y.: Towards Vivid and Diverse Image Colorization with Generative Color Prior. In: ICCV (2021)

[73]
Xu, S., Ma, Z., Huang, Y., Lee, H., Chai, J.: CycleNet: Rethinking Cycle Consistency in Text-Guided Diffusion for Image Manipulation. In: NeurIPS (2023)

[74]
Xu, Z., Wang, T., Fang, F., Sheng, Y., Zhang, G.: Stylization-Based Architecture for Fast Deep Exemplar Colorization. In: CVPR (2020)

[75]
Yan, D., Yuan, L., Nishioka, Y., Fujishiro, I., Saito, S.: ColorizeDiffusion: Adjustable Sketch Colorization with Reference Image and Text. arXiv preprint arXiv:2401.01456  (2024)

[76]
Zabari, N., Azulay, A., Gorkor, A., Halperin, T., Fried, O.: Diffusing Colors: Image Colorization with Text Guided Diffusion. In: SIGGRAPH (2023)

[77]
Zhang, B., Duan, Y., Lan, J., Hong, Y., Zhu, H., Wang, W., Niu, L.: ControlCom: Controllable Image Composition using Diffusion Model. arXiv preprint arXiv:2308.10040  (2023)

[78]
Zhang, L., Li, C., Wong, T.T., Ji, Y., Liu, C.: Two-stage Sketch Colourization. SIGGRAPH  (2018)

[79]
Zhang, L., Rao, A., Agrawala, M.: Adding Conditional Control to Text-to-Image Diffusion Models. In: ICCV (2023)

[80]
Zhang, R., Isola, P., Efros, A.A., Shechtman, E., Wang, O.: The Unreasonable Effectiveness of Deep Features as a Perceptual Metric. In: CVPR (2018)

[81]
Zhang, R., Zhu, J.Y., Isola, P., Geng, X., Lin, A.S., Yu, T., Efros, A.A.: Real-Time User-Guided Image Colorization with Learned Deep Priors. In: SIGGRAPH (2017)

[82]
Zhong, M., Shen, Y., Wang, S., Lu, Y., Jiao, Y., Ouyang, S., Yu, D., Han, J., Chen, W.: Multi-LoRA Composition for Image Generation. arXiv preprint arXiv:2402.16843  (2024)

[83]
Zhu, J.Y., Park, T., Isola, P., Efros, A.A.: Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks. In: ICCV (2017)

[84]
Zhu, J.Y., Zhang, R., Pathak, D., Darrell, T., Efros, A.A., Wang, O., Shechtman, E.: Toward Multimodal Image-to-Image Translation. In: NeurIPS (2017)

Supplementary Material

Chaitat UtintuInterned with SketchX Pinaki Nath ChowdhuryAneeshan SainSubhadeep KoleyAyan Kumar BhuniaYi-Zhe Song

Utintu et al.

SketchX, CVSSP, University of Surrey, United Kingdom

{p.chowdhury, a.sain, s.koley, a.bhunia<EMAIL_ADDRESS>
This supplementary material complements the main paper, "SketchDeco: Decorating B&W Sketches with Colour," by providing additional details: ablation study of textual prompts (Sec. <ref>), limitation and future study (Sec. <ref>), computational performance analysis (Sec. <ref>), additional discussion on design choices (Sec. <ref>), additional quantitative results (Sec. <ref>), and additional qualitative results on T2I-Adapter[46] and 15 random sketches (Sec. <ref>).

§ ABLATION STUDY OF TEXTUAL PROMPTS

We conduct an additional ablation study to investigate the contribution of each textual information on our global sketch colourisation process in the following cases: (i) Baseline, where the colourised results are generated without any textual guidance (i.e., only input sketches are utilised as conditions); (ii) only class semantics (i.e., “”), derived from BLIP2[34] prediction, are applied for textual guidance; (iii) class semantics and positive prompts (i.e., “, hyper-realistic, quality, photography style”) are used; (iv) negative prompts (i.e., “drawing look, sketch look, line art style, cartoon look, unnatural colour, unnatural texture, unrealistic look, low-quality”) are combined; (v) finally, four main textual information, including class semantics, colour names, positive prompts (i.e., “, hyper-realistic, quality, photography style, using only colours in colour palette of , -  - $\dots$ ”) and negative prompts (i.e., “drawing look, sketch look, line art style, cartoon look, unnatural colour, unnatural texture, unrealistic look, low-quality”) are utilised. The results are illustrated in Fig. <ref>.

Ablation study of different textual prompt settings. In our global sketch colourisation pipeline, the textual prompts $t_{p}$ are composed of four main textual information, including class semantics, colour names, positive prompts (i.e., “, hyper-realistic, quality, photography style, using only colours in colour palette of , -  - $\dots$ ”) and negative prompts (i.e., “drawing look, sketch look, line art style, cartoon look, unnatural colour, unnatural texture, unrealistic look, low-quality”)

§ LIMITATION AND FUTURE STUDY

In our work, we acknowledge several limitations and suggest avenues for future research. Firstly, when processing small selected regions for local colourisation, the initial blending ability derived from global colourisation pipeline may lead to some losses in colour fidelity, necessitating exploration of novel techniques to address this challenge. This could involve the development of adaptive blending strategies or localised colour correction mechanisms to better preserve colour accuracy in intricate or fine-textured areas. Additionally, while our approach relies on matching colour hexcodes with name entries in a standard CSS3 colour database[1], there is potential to enhance the database to accommodate a wider variety of colours. However, caution must be exercised to ensure compatibility with the pretrained Stable Diffusion[50] model, as ambiguous or non-standard colour names may introduce uncertainty and inconsistency in the colourisation process. Furthermore, with BLIP2's[34] ability to predict class categories, future research could extend the Visual Question Answering (VQA) task to include fine-grained classification, providing more detailed and informative class semantics for colourisation pipelines.

§ COMPUTATIONAL PERFORMANCE ANALYSIS

Given efficiency as a key contribution, we further evaluate our method using qualitative metrics related to computational performance. Specifically, we measure the computation time for each component in our proposed method, including VisualQA prediction, inversion of composited images, and the sampling process. Additionally, we compare the overall time required for global sketch colorization across DiffBlender[27], T2I-Adapter[46], and our proposed method. These comparisons allow us to highlight the efficiency improvements achieved by our approach in terms of reduced computational time and enhanced performance.
The result is described in Tab.<ref>.

Computational Time Evaluation.

Process     Proposed Module     Time (s)     Ours (s)     T2I-Adapter (s)     DiffBlender (s)

2*Global Stage     VQA class prediction     0.65     2*5.44     2*2.96     2*20.79

sampling process/image     4.79

2*Local Stage     inversion of composited img $\mathcal{I}^{\ast}$     3.52     2*22.43      2*-     2*-

final sampling process     18.94

§ ADDITIONAL DISCUSSION ON DESIGN CHOICES

We evaluate the contribution of various design choices on AFHQ-cat[14] and AFHQ-dog[14]: (i) For VQA: replacing BLIP2 with GIT [68] gives FID/LPIPS $(65.71/0.693)$ and $(129.19/0.742)$, llama-3-vision-alpha [37] $(57.23/0.673)$ and $(61.22/0.683)$, and llava-1.5-7b [37] $(55.97/0.669)$ and $(62.96/0.686)$. (ii) For inversion schemes in local sketch colourisation: replacing DPM-Solver++ with DDIM gives FID/LPIPS $(35.09/0.716)$, and DPM-Solver $(33.74/0.714)$. (iii) For staged generation replacing SD2.1 with SD1.5 gives $(34.05/0.706)$.

§ ADDITIONAL QUANTITATIVE RESULTS

We conduct an additional quantitative comparison between DiffBlender[27], T2I-Adapter[46], and our method, evaluating the performance on the AFHQ-cat[14], AFHQ-dog[14], and AFHQ-wildlife[14] datasets. We use the following metrics: Mean Squared Error (MSE), Peak Signal-to-Noise Ratio (PSNR), and Structural Similarity Index (SSIM). MSE measures the average squared difference between the original and reconstructed images, with lower values indicating better reconstruction quality. PSNR quantifies the ratio between the maximum possible pixel value and the power of distorting noise, where higher values generally indicate higher image quality. SSIM assesses the similarity between two images based on luminance, contrast, and structure, with values ranging from -1 to 1, where 1 signifies perfect structural similarity. The results of this comparison are shown in Tab. <ref>.

Additional Quantitative Evaluation.

2*Methods     3cAFHQ-cat     3cAFHQ-dog     3cAFHQ-wildlife

PSNR $\uparrow$     SSIM $\uparrow$     MSE $\downarrow$     PSNR $\uparrow$     SSIM $\uparrow$     MSE $\downarrow$     PSNR $\uparrow$     SSIM $\uparrow$     MSE $\downarrow$

DiffBlender     6.78     0.028     14454.01     6.82     0.034     14340.06     6.91     0.017     13850.16

T2I-Adapter     6.06     0.014     17544.70     5.94     0.017     17843.84     6.82     0.011     15852.42

YellowGreen!40 Proposed     8.76     0.191     8968.34     8.91     0.210     8747.87     9.01     0.147     8534.97

§ ADDITIONAL QUALITATIVE RESULTS

Qualitative comparison with T2I-Adapter[46] is illustrated in Fig.<ref>.
Additionally, <ref> represents qualitative results on 15 random sketches obtained from <www.freepik.com> using search keywords: “black-and-white  sketch”.

Additional qualitative comparison with T2I-Adapter. Qualitative comparison of global sketch colourisation between T2I-Adapter[46] and our proposed method on AFHG-cat[14] and AFHG-dog[14] dataset.

Input Sketch     Mask with colour     Composited Image     Final Result

Qualitative evaluation with random sketches. The local sketch colourisation pipeline showcased notable adaptability, allowing users to incorporate three conditional inputs: a variety of sketches, hand-drawn masks, and preferred colour palettes. Consequently, our approach yields precise outcomes tailored to user-defined specifications. It is non-trivial to mention that these sketch images are randomly sourced from <www.freepik.com> with search keywords: “”.

Input Sketch     Mask with colour     Composited Image     Final Result

Qualitative evaluation with random sketches. The local sketch colourisation pipeline showcased notable adaptability, allowing users to incorporate three conditional inputs: a variety of sketches, hand-drawn masks, and preferred colour palettes. Consequently, our approach yields precise outcomes tailored to user-defined specifications. It is non-trivial to mention that these sketch images are randomly sourced from <www.freepik.com> with search keywords: “”.

Input Sketch     Mask with colour     Composited Image     Final Result

Qualitative evaluation with random sketches. The local sketch colourisation pipeline showcased notable adaptability, allowing users to incorporate three conditional inputs: a variety of sketches, hand-drawn masks, and preferred colour palettes. Consequently, our approach yields precise outcomes tailored to user-defined specifications. It is non-trivial to mention that these sketch images are randomly sourced from <www.freepik.com> with search keywords: “”.

Input Sketch     Mask with colour     Composited Image     Final Result

Qualitative evaluation with random sketches. The local sketch colourisation pipeline showcased notable adaptability, allowing users to incorporate three conditional inputs: a variety of sketches, hand-drawn masks, and preferred colour palettes. Consequently, our approach yields precise outcomes tailored to user-defined specifications. It is non-trivial to mention that these sketch images are randomly sourced from <www.freepik.com> with search keywords: “”.

Input Sketch     Mask with colour     Composited Image     Final Result

Qualitative evaluation with random sketches. The local sketch colourisation pipeline showcased notable adaptability, allowing users to incorporate three conditional inputs: a variety of sketches, hand-drawn masks, and preferred colour palettes. Consequently, our approach yields precise outcomes tailored to user-defined specifications. It is non-trivial to mention that these sketch images are randomly sourced from <www.freepik.com> with search keywords: “”.

Input Sketch     Mask with colour     Composited Image     Final Result

Qualitative evaluation with random sketches. The local sketch colourisation pipeline showcased notable adaptability, allowing users to incorporate three conditional inputs: a variety of sketches, hand-drawn masks, and preferred colour palettes. Consequently, our approach yields precise outcomes tailored to user-defined specifications. It is non-trivial to mention that these sketch images are randomly sourced from <www.freepik.com> with search keywords: “”.