Weak Segmentation-Guided GAN for realistic color edition
- Authors
- Vincent Auriau
- Emmanuel Malherbe
- Matthieu Perrot
- Affiliations
- Artefact Research Center
- L'Oréal AI Research
- Accepted at
- ICIAP 2023
- Date
- arXiv
- 2610.16620
Abstract
Editing the color of images in a realistic way finds many applications such as changing the perception of an image, data augmentation or film post processing. The design of an automatic tool is a complex and long addressed challenge. In particular, two properties are difficult to meet altogether: generating realistic results without artifacts and the possibility to precisely choose the future color. Conventional methods using segmentation and histogram matching maximize the controllability but also introduce a lack of realism or are complex to automate. On the contrary, GANs that specialize in realism are difficult to control. To overcome these challenges, we propose a novel GAN architecture leveraging any differentiable segmentation model. We demonstrate the genericness of our framework that presents state of the art results on different use cases. It generates images that look realistic while offering a precise color control.
Cite this paper
@inproceedings{auriau2023weak,
title = {Weak Segmentation-Guided GAN for realistic color edition},
author = {Vincent Auriau and Emmanuel Malherbe and Matthieu Perrot},
booktitle = {International Conference on Image Analysis and Processing (ICIAP 2023)},
year = {2023},
doi = {10.1007/978-3-031-43148-7_41},
url = {https://doi.org/10.1007/978-3-031-43148-7_41}
}Copied
Introduction
Color edition control is the process of modifying an object's color in a graphical representation. A user can control the edition by specifying desired colors. It is a great tool for images post processing. By altering the color palette, it is possible to modify the global atmosphere or perception of the image [25]. One might want to be more precise and only adjust the color of a single area: a lighter blue sky in a landscape photograph or changing an actor's hair color in a movie. Simulating several color variations of the same car or garment can help to choose the right color among the millions of possibilities before any material realization. It can also be used to help customers select the right make up or hair coloration they desire. While physical renderers handle colors very well [26], it is still a real challenge to work with existing photographic pictures. Color transfer [15] and colorization [29] are two other applications that can be seen as specific cases of color edition. Most recent methodologies use neural networks and particularly GANs [30], however they still meet challenges with some non satisfying results.
Our goal is to realistically and precisely change an object's color in an image. We consider the general color perception of an object in the image, characterizing the object by a single color. In order to keep the human control simple, interaction of light with the object's geometry or local color variations coming from the textures are to be handled automatically.
To better define the objective, we enumerate four properties to evaluate the performances of a color edition model:
(i) Colorization accuracy: The perceived resulting color of the object is as close as possible as the desired one (ii) Realism: The generated image is realistic to the human eye (iii) Stability: The geometry of the considered object and local color variations are kept unchanged (iv) Restraint: Objects and areas that should not be modified, or "background", are left untouched
We describe our robust method for color edition that overcomes the two main difficulties of existing techniques: producing realistic results while reaching a precise color control. Our main contributions are:
A generic model architecture and training strategy for editing human perceived color while ensuring realism, stability and constraint
A versatile object-aware color edition tool based on segmentation that addresses various usecases and applications: color edition, color transfer and colorization
Experimental comparison on various datasets and use cases that show how our approach achieves the best trade-off compared to the state-of-the art models
Related Work
Color manipulation in images is a long-addressed problem. Different semi-automatic or fully automatic methods have been developed, with different advantages and drawbacks. We specifically focus on color edition on the core of this paper, however inspirational technologies have been developed for color transfer or colorization.
Color Transfer consists of extracting the right color features from a reference image, and to transfer them to the content image. In [21], a simple but effective function for color transfer is given. The color reference image and the content image are described respectively by and , the mean and standard deviation of the color distributions of each image in the L*a*b* space. The color transfer function is then defined as:
More complex transformationmanipulate thewhole color histogram[18][27]. It enablesmodifications of the color palettes that would not be possible with a simple linear translation. In return, the needed computation is much greater. Most state of the art are today produced by deep learning. In [5] a neural color transfer method between images is proposed. It uses a trained VGG-19 to match semantically meaningful entities between the reference and content images, before applying Equation 1. While having an image to transfer the color from is of great help, it might be long or complicated to find the very example image that perfectly fits the user's intention. It also limits creativity, forcing the use of already existing color palettes.
Convolution neural network have also shown the first good results on automatic Gray Image Colorization [6]. The use of conditional GAN with the pix2pix model [7] have led to more realistic results. These methods do not allow any color controlability as the resulting color cannot be decided by the user. Such control is introduced in [24] with colored drawn strokes. No measure of the color precision is developed and background is often impacted, creating undesired artifacts.
In Color Edition Control, a user can modify at will the colors of an object in an image. Pixels to be edited can be selected using a segmentation model [20], which was more recently performed using neural segmentation [13, 27]. The desired color is defined by the user in the form of a histogram or color look up tables. Respectively histogram matching algorithms and interpolation are then applied to modify the selected pixels. While providing good results, these methods suffer in terms of realism, particularly around the edges of the computed mask where artifacts tend to appear. Moreover the color formats are complicated to manipulate for a user.
Another strategy that overcomes those limitations is to use a conditional GAN architecture [17] such as the one of StarGAN [2], with the colors as condition variables. CAGAN [10] proposes to automatically extract colors and let the generator indirectly focus on the right area without further explicit supervision. The major persisting challenges are generated images color precision and the inherent modifications of background pixels, that create inconsistencies. To overcome this issue, MagGAN [31] suggests to feed the model with manually labelled masks to improve the focus on a specific zone. However it is not designed for continuous color space and requires mask labels as input.
In this paper, we aim at bridging the different approaches presented above, GANs for realism and segmentation for object selection. It leads us to create an accurate, controllable and versatile coloring tool for edition.
Proposed model
Our approach consists of Generator that produces the transformed image from the input image , with the considered object colorized as described by the color vector . We also define , a generic and differentiable segmentation model such that is the probability for each pixel to represent the object: where . In practice we use a neural network for that is trained separately from the rest of the framework and frozen, but it can be generalized to any differentiable function.
is a convolutional neural network with an encoder-decoder architecture. The decoder takes the image features created by the encoder and the desired color as inputs and generates the colorized image. is trained to optimize four modules that ensure the required properties: for colorization accuracy, for realism, for stability and finally for restraint. The general organisation is illustrated Figure 2, and the modules described in the following sections.
Color Estimation module
We need a robust color estimation function that should be differentiable for later optimization purposes. We describe an object’s color as an average value over its representing pixels. This estimator characterizes well the general color of a uniformly colored object and can be easily represented and understood by a user. The weighted mean color of an object is then:
with the color vector at pixel (i, j). It is illustrated in Figure 3.
This color estimator is used to estimate the color of our object in the generated image and compare it to the desired color . The color loss is a loss computed in the color space as it better matches human perception [10, 22].
Thanks to the use of , we are sure to extract and therefore control the color of the object itself.
Discriminator module
The GAN structure ensures that the main coloring model produces realistic results by adversarially training a discriminator neural network, . It tries to distinguish real images from the one edited by . Our adversarial loss is the standard Wasserstein GAN loss with gradient penalty [1]:
with randomly obtained for each batch by interpolating between real images and generated images .
Reconstruction module
In order to ensure stability, we use the popular cycle consistency loss introduced in CycleGAN [33] for image to image translation. The model is trained to be able to recreate the original image from its own generation. It ensures that maintains the objects geometry and that no pixel or information is lost through the process. The reconstruction loss is defined as:
The reconstruction module is illustrated in Figure 4.
Object Focus module
With our frozen segmentation model , we can also ensure restraint, meaning that keeps background pixels unchanged. We only want pixels that relate to the object’s color change to be edited by the model. These background alterations is a common artifact produced by GAN based approaches. The Object Focus loss penalizes any change operated outside of the segmentation mask representing our object:
with 1 the matrix of same shape as and filled with ones and the element wise product on the R, G and B channels. The resulting object focus module is illustrated in Figure 5.
General objective
We summarize the final objective to train and as follows:
where the different are used to set up and control the importance of the different losses in the final objective. The general workflow of the model is illustrated in Figure 2. Models and are trained by this process, is trained beforehand separately.
We have presented our framework to edit a single object's color. It can be easily extended to any number of objects. One only needs to sum the losses over the different objects.



Experiments
Datasets
We have tested our framework on three different use cases supported by open-source datasets designed to train the segmentation model. First, we used CelebA-HQ dataset [12] to train our hair and lips segmentation network. It was then completed with the FFHQ dataset [8] to improve the data diversity. Secondly, the cat and dogs dataset [16] was used for coloring pets. For this use case, we used an already trained segmentation network from [4]. We plugged this model to our framework that works without further need of adaptation. Finally, the clothing dataset [11] was used to train the segmentation model as well as the color edition model for the garnments use-case. Example of results can be found in Figure 1. The results presented in this part are all obtained using the first datasets. Additional material and examples are shared in the appendix (Appendix can be found at: https://github.com/VincentAuriau/wsg-gan-color-edition/blob/main/pdf_files/appendix.pdf).
Implementation
For the following experiments, the parameters described in this part were used, unless it is specifically specified otherwise. The models were trained on 256 pixels images resized by bicubic interpolation. For the trained segmentation models, we used a U-Net segmentation network [23]. The generator and discriminator architectures can be found in the Appendix (Appendix can be found at: https://github.com/VincentAuriau/wsg-gan-color-edition/blob/main/pdf_files/appendix.pdf). For losses weighting, we used the parameters: and . We trained both networks with the Adam optimizer with learning rates 5 for the generator and for the discriminator.
Evaluation Protocol
In order to compare our framework with other approaches, we use quantitative metrics computed with the following protocol: We select a random subset composed of 10k images that we keep for testing. We select a second subset , of same size as . We generate for each to build the dataset .
Metrics For realism quantification, we use the Fréchet Inception Distance, or FID [19]. We compare our generated images with : . For color precision estimation, we use . We also compute a modified version of to quantify how well the different models perform on the task of focusing on the right pixels. is defined as:
with being all the images of the manually annotated mask corresponding to the corresponding generated image and 1 the matrix filled with ones. represents the average modification of a background pixel’s channel. The norm is taken to better express human perception in [3].
User test We have performed a user study for human quantitative evaluation of the different approaches. We have asked five annotators which was the most realistic edition among the one generated by the different approaches. We have repeated the experience with 30 random triplets of editions, totalling 150 annotations.
Comparison with other approaches
We compare our framework with other approaches that aim at coloring objects in images. The first approach, alpha blending [13][18] uses segmentation paired with RGB shift. For fair comparison, the area to edit is selected using , then Equation 1 is applied for the average color of segmented pixels to match the desired one.
The second one, CAGAN [10], is a straightforward adaptation of StarGAN [2] for color control. A third model is trained besides for color extraction. It uses labels, without any guidance on the object. For fair comparison we extracted color labels using . This third model induces noise in the global color precision of the editions.
Finally, we also benchmark our model with one of the most performing GAN, StyleGAN [9]. As it is not built specifically for coloring, we developed a straight forward strategy on the style space [32] which is detailed in the Appendix (Appendix can be found at: https://github.com/VincentAuriau/wsg-gan-color-edition/blob/main/pdf_files/appendix.pdf). This simple adaptation enables to perform color edition using StyleGAN. More complex adaptation could be designed, but it is beyond the scope of this paper.
Qualitative evaluation Figure 6 shows examples of results for hair colorization. We observed the main defaults of compared approaches. Alpha Blending creates artifacts on the edges of the segmented mask (see (a)). CAGAN tends to edit pixels outside hair pixels. It is particularly obvious on (a) with the face color that is different and on (d) where the background is affected. Finally, StyleGAN which is not built for image-to-image translation changes the faces attributes, the projection failing at perfectly reproducing the original image.
Quantitative evaluation Table 1 shows a metric analysis of the approaches. We observed that our model is a good balance between color precision and realism. Our objective was to compensate alpha blending’s lack of realism using GANs. However, typical GAN approaches come at a cost, particularly on color precision. In addition, it is more difficult to control the outcome of the GAN. It can be seen with for CAGAN and ctrl-StyleGAN, showing that many pixels are modified whereas they should not. We observe that our model outperforms other GAN approaches on these topics.
Our approach obtained the majority of users votes and particularly outperforms the other GANbased approach, CAGAN. Compared to Alpha Blending, our method seems to have better results particularly with the lack of textures in images with darker colored objects.
Ablation Study
We have also analysed the behaviour of the different modules within our framework. We have trained our model and computed the metrics with and without the reconstruction and object focus losses. The results can be found in Table 2. In order to emphasize the importance of , we also train , an equivalent of our framework with losses computed with ground truth masks instead of ’s predictions. We test this strategy for Object Focus, , and combined with Color Estimation, is thus optimized without a fully differentiable .
We observe that optimising the object focus loss fulfills the objective of limiting the modification of pixels outside of the colored object. Combined with reconstruction loss, it further improves all metrics. Finally, the use of a differentiable function considerably improves the results.
Table 1 | Quantitative results of the color edition frameworks. We show that our approach outperforms alpha blending in terms of and other approaches on all metrics. Our model also outperforms others on the users votes. For the first three metrics, lower is better. Best results are in blue and second best in green.
Table 2 | Ablation study of our proposed model. The Object Focus loss improves realism and background preservation while reconstruction positively affects all metrics. For all metrics, lower is better. Best results are in blue and second best in green, identity excluded
Conclusion
We presented our framework for generic objects colorizing. Our new object-aware colorization model based on segmentation, introduces specific losses to improve the realism and the color precision of the results. It can be used on any type of image of objects and only needs a pretrained and differentiable segmentation model to work. We have shown state of the art results on several datasets, with the best balance between realism of generated images, accurate color of transformed object as well as maintained geometry and background. Our framework can be adapted for different applications such as color edition, color transfer or colorization, as shown through the experiments on several use-cases. As future work, we will focus on spatial distribution of the color. In order to let the user manipulate more than one general color of the object while keeping the simplicity of use.
Next step
A problem worth researching?
Tell us what you are trying to solve, and we will put you in touch with the people who work on it.