unsupervised/unpaired image-to-image translation using coupled GANs
Unsupervised image-to-image translation aims at learning a joint distribution of images in different domains by using images from the marginal distributions in individual domains. Since there exists an infinite set of joint distributions that can arrive the given marginal distributions, one could infer nothing about the joint distribution from the marginal distributions without additional assumptions. To address the problem, we make a shared-latent space assumption and propose an unsupervised image-to-image translation framework based on Coupled GANs. We compare the proposed framework with competing approaches and present high quality image translation results on various challenging unsupervised image translation tasks, including street scene image translation, animal image translation, and face image translation. We also apply the proposed framework to domain adaptation and achieve state-of-the-art performance on benchmark datasets. Code and additional results are available in https://github.com/mingyuliutw/unit .READ FULL TEXT VIEW PDF
Unsupervised Image-to-Image Translation achieves spectacularly advanced
Unsupervised image-to-image translation aims at learning the mapping fro...
One task that is often discussed in a computer vision is the mapping of ...
There has been remarkable recent work in unpaired image-to-image transla...
We address the task of multi-view image-to-image translation for person ...
A good image-to-image translation model should learn a mapping between
Recent GAN-based architectures have been able to deliver impressive
unsupervised/unpaired image-to-image translation using coupled GANs
Translate face images from male2female & female2male
Many computer visions problems can be posed as an image-to-image translation problem, mapping an image in one domain to a corresponding image in another domain. For example, super-resolution can be considered as a problem of mapping a low-resolution image to a corresponding high-resolution image; colorization can be considered as a problem of mapping a gray-scale image to a corresponding color image. The problem can be studied in supervised and unsupervised learning settings. In the supervised setting, paired of corresponding images in different domains are availableisola2016image ; ledig2016photo . In the unsupervised setting, we only have two independent sets of images where one consists of images in one domain and the other consists of images in another domain—there exist no paired examples showing how an image could be translated to a corresponding image in another domain. Due to lack of corresponding images, the UNsupervised Image-to-image Translation (UNIT) problem is considered harder, but it is more applicable since training data collection is easier.
When analyzing the image translation problem from a probabilistic modeling perspective, the key challenge is to learn a joint distribution of images in different domains. In the unsupervised setting, the two sets consist of images from two marginal distributions in two different domains, and the task is to infer the joint distribution using these images. The coupling theory lindvall2002lectures states there exist an infinite set of joint distributions that can arrive the given marginal distributions in general. Hence, inferring the joint distribution from the marginal distributions is a highly ill-posed problem. To address the ill-posed problem, we need additional assumptions on the structure of the joint distribution.
To this end we make a shared-latent space assumption, which assumes a pair of corresponding images in different domains can be mapped to a same latent representation in a shared-latent space. Based on the assumption, we propose a UNIT framework that are based on generative adversarial networks (GANs) and variational autoencoders (VAEs). We model each image domain using a VAE-GAN. The adversarial training objective interacts with a weight-sharing constraint, which enforces a shared-latent space, to generate corresponding images in two domains, while the variational autoencoders relate translated images with input images in the respective domains. We applied the proposed framework to various unsupervised image-to-image translation problems and achieved high quality image translation results. We also applied it to the domain adaptation problem and achieved state-of-the-art accuracies on benchmark datasets. The shared-latent space assumption was used in Coupled GANliu2016coupled for joint distribution learning. Here, we extend the Coupled GAN work for the UNIT problem. We also note that several contemporary works propose the cycle-consistency constraint assumption zhu2017unpaired ; kim2017learning , which hypothesizes the existence of a cycle-consistency mapping so that an image in the source domain can be mapped to an image in the target domain and this translated image in the target domain can be mapped back to the original image in the source domain. In the paper, we show that the shared-latent space constraint implies the cycle-consistency constraint.
|Roles||VAE for||Image Translator||GAN for||VAE-GAN larsen2015autoencoding||CoGAN liu2016coupled|
Let and be two image domains. In supervised image-to-image translation, we are given samples drawn from a joint distribution . In unsupervised image-to-image translation, we are given samples drawn from the marginal distributions and . Since an infinite set of possible joint distributions can yield the given marginal distributions, we could infer nothing about the joint distribution from the marginal samples without additional assumptions.
We make the shared-latent space assumption. As shown Figure 1, we assume for any given pair of images and , there exists a shared latent code in a shared-latent space, such that we can recover both images from this code, and we can compute this code from each of the two images. That is, we postulate there exist functions , , , and such that, given a pair of corresponding images from the joint distribution, we have and conversely and . Within this model, the function that maps from to can be represented by the composition . Similarly, . The UNIT problem then becomes a problem of learning and . We note that a necessary condition for and to exist is the cycle-consistency constraint zhu2017unpaired ; kim2017learning : and . We can reconstruct the input image from translating back the translated input image. In other words, the proposed shared-latent space assumption implies the cycle-consistency assumption (but not vice versa).
To implement the shared-latent space assumption, we further assume a shared intermediate representation such that the process of generating a pair of corresponding images admits a form of
Consequently, we have and where is a common high-level generation function that maps to and and are low-level generation functions that map to and , respectively. In the case of multi-domain image translation (e.g., sunny and rainy image translation), can be regarded as the compact, high-level representation of a scene ("car in front, trees in back"), and can be considered a particular realization of through ("car/tree occupy the following pixels"), and and would be the actual image formation functions in each modality ("tree is lush green in the sunny domain, but dark green in the rainy domain"). Assuming also allow us to represent and by and .
In the next section, we discuss how we realize the above ideas in the proposed UNIT framework.
Our framework, as illustrated in Figure 1, is based on variational autoencoders (VAEs) kingma2013auto ; rezende2014stochastic ; larsen2015autoencoding and generative adversarial networks (GANs) goodfellow2014generative ; liu2016coupled . It consists of 6 subnetworks: including two domain image encoders and , two domain image generators and , and two domain adversarial discriminators and . Several ways exist to interpret the roles of the subnetworks, which we summarize in Table 1. Our framework learns translation in both directions in one shot.
VAE. The encoder–generator pair constitutes a VAE for the domain, termed VAE. For an input image , the VAE first maps to a code in a latent space via the encoder and then decodes a random-perturbed version of the code to reconstruct the input image via the generator . We assume the components in the latent spaceand the distribution of the latent code is given by where
is an identity matrix. The reconstructed image is. Note that here we abused the notation since we treated the distribution of as a random vector of and sampled from it. Similarly, constitutes a VAE for : VAE where the encoder outputs a mean vector and the distribution of the latent code is given by . The reconstructed image is .
Utilizing the reparameterization trick kingma2013auto
, the non-differentiable sampling operation can be reparameterized as a differentiable operation using auxiliary random variables. This reparameterization trick allows us to train VAEs using back-prop. Let
be a random vector with a multi-variate Gaussian distribution:. The sampling operations of and can be implemented via and , respectively.
Weight-sharing. Based on the shared-latent space assumption discussed in Section 2, we enforce a weight-sharing constraint to relate the two VAEs. Specifically, we share the weights of the last few layers of and that are responsible for extracting high-level representations of the input images in the two domains. Similarly, we share the weights of the first few layers of and responsible for decoding high-level representations for reconstructing the input images.
Note that the weight-sharing constraint alone does not guarantee that corresponding images in two domains will have the same latent code. In the unsupervised setting, no pair of corresponding images in the two domains exists to train the network to output a same latent code. The extracted latent codes for a pair of corresponding images are different in general. Even if they are the same, the same latent component may have different semantic meanings in different domains. Hence, the same latent code could still be decoded to output two unrelated images. However, we will show that through adversarial training, a pair of corresponding images in the two domains can be mapped to a common latent code by and , respectively, and a latent code will be mapped to a pair of corresponding images in the two domains by and , respectively.
The shared-latent space assumption allows us to perform image-to-image translation. We can translate an image in to an image in through applying . We term such an information processing stream as the image translation stream. Two image translation streams exist in the proposed framework: and . The two streams are trained jointly with the two image reconstruction streams from the VAEs. Once we could ensure that a pair of corresponding images are mapped to a same latent code and a same latent code is decoded to a pair of corresponding images, would form a pair of corresponding images. In other words, the composition of and functions approximates for unsupervised image-to-image translation discussed in Section 2, and the composition of and function approximates .
GANs. Our framework has two generative adversarial networks: and . In , for real images sampled from the first domain, should output true, while for images generated by , it should output false. can generate two types of images: 1) images from the reconstruction stream and 2) images from the translation stream . Since the reconstruction stream can be supervisedly trained, it is suffice that we only apply adversarial training to images from the translation stream, . We apply a similar processing to where is trained to output true for real images sampled from the second domain dataset and false for images generated from .
Cycle-consistency (CC). Since the shared-latent space assumption implies the cycle-consistency constraint (See Section 2), we could also enforce the cycle-consistency constraint in the proposed framework to further regularize the ill-posed unsupervised image-to-image translation problem. The resulting information processing stream is called the cycle-reconstruction stream.
Learning. We jointly solve the learning problems of the VAE, VAE, GAN and GAN for the image reconstruction streams, the image translation streams, and the cycle-reconstruction streams:
VAE training aims for minimizing a variational upper bound In (2), the VAE objects are
where the hyper-parameters and control the weights of the objective terms and the KL divergence terms penalize deviation of the distribution of the latent code from the prior distribution. The regularization allows an easy way to sample from the latent space kingma2013auto . We model and using Laplacian distributions, respectively. Hence, minimizing the negative log-likelihood term is equivalent to minimizing the absolute distance between the image and the reconstructed image. The prior distribution is a zero mean Gaussian .
In (2), the GAN objective functions are given by
The objective functions in (5) and (6) are conditional GAN objective functions. They are used to ensure the translated images resembling images in the target domains, respectively. The hyper-parameter controls the impact of the GAN objective functions.
We use a VAE-like objective function to model the cycle-consistency constraint, which is given by
where the negative log-likelihood objective term ensures a twice translated image resembles the input one and the KL terms penalize the latent codes deviating from the prior distribution in the cycle-reconstruction stream (Therefore, there are two KL terms). The hyper-parameters and control the weights of the two different objective terms.
Inheriting from GAN, training of the proposed framework results in solving a mini-max problem where the optimization aims to find a saddle point. It can be seen as a two player zero-sum game. The first player is a team consisting of the encoders and generators. The second player is a team consisting of the adversarial discriminators. In addition to defeating the second player, the first player has to minimize the VAE losses and the cycle-consistency losses. We apply an alternating gradient update scheme similar to the one described in goodfellow2014generative to solve (2). Specifically, we first apply a gradient ascent step to update and with , , , and fixed. We then apply a gradient descent step to update , , , and with and fixed.
Translation: After learning, we obtain two image translation functions by assembling a subset of the subnetworks. We have for translating images from to and for translating images from to .
We first analyze various components of the proposed framework. We then present visual results on challenging translation tasks. Finally, we apply our framework to the domain adaptation tasks.
Performance Analysis. We used ADAM kingma2014adam for training where the learning rate was set to 0.0001 and momentums were set to 0.5 and 0.999. Each mini-batch consisted of one image from the first domain and one image from the second domain. Our framework had several hyper-parameters. The default values were , and . For the network architecture, our encoders consisted of 3 convolutional layers as the front-end and 4 basic residual blocks he2016deep as the back-end. The generators consisted of 4 basic residual blocks as the front-end and 3 transposed convolutional layers as the back-end. The discriminators consisted of stacks of convolutional layers. We used LeakyReLU for nonlinearity. The details of the networks are given in Appendix A.
), which contained corresponding pairs of images in two domains (satellite image and map) useful for quantitative evaluation. Here, the goal was to learn to translate between satellite images and maps. We operated in an unsupervised setting where we used the 1096 satellite images from the training set as the first domain and 1098 maps from the validation set as the second domain. We trained for 100K iterations and used the final model to translate 1098 satellite images in the test set. We then compared the difference between a translated satellite image (supposed to be maps) and the corresponding ground truth maps pixel-wisely. A pixel translation was counted correct if the color difference was within 16 of the ground truth color value. We used the average pixel accuracy over the images in the test set as the performance metric. We could use color difference for measuring translation accuracy since the target translation function was unimodal. We did not evaluate the translation from maps to images since the translation was multi-modal, which was difficult to construct a proper evaluation metric.
In one experiment, we varied the number of weight-sharing layers in the VAEs and paired each configuration with discriminator architectures of different depths during training. We changed the number of weight-sharing layers from 1 to 4. (Sharing 1 layer in VAEs means sharing 1 layer for and and, at the same time, sharing 1 layer for and .) The results were reported in Figure 2(b). Each curve corresponded to a discriminator architecture of a different depth. The x-axis denoted the number of weigh-sharing layers in the VAEs. We found that the shallowest discriminator architecture led to the worst performance. We also found that the number of weight-sharing layer had little impact. This was due to the use of the residual blocks. As tying the weight of one layer, it effectively constrained the other layers since the residual blocks only updated the residual information. In the rest of the experiments, we used VAEs with 1 sharing layer and discriminators of 5 layers.
We analyzed impact of the hyper-parameter values to the translation accuracy. For different weight values on the negative log likelihood terms (i.e., , ), we computed the achieved translation accuracy over different weight values on the KL terms (i.e., , ). The results were reported in Figure 2(c). We found that, in general, a larger weight value on the negative log likelihood terms yielded a better translation accuracy. We also found setting the weights of the KL terms to 0.1 resulted in consistently good performance. We hence set and .
We performed an ablation study measuring impact of the weight-sharing and cycle-consistency constraints to the translation performance and showed the results in Figure 2(d). We reported average accuracy over 5 trials (trained with different initialized weights.). We note that when we removed the weight-sharing constraint (as a consequence, we also removed the reconstruction streams in the framework), the framework was reduced to the CycleGAN architecture zhu2017unpaired ; kim2017learning . We found the model achieved an average pixel accuracy of 0.569. When we removed the cycle-consistency constraint and only used the weight-sharing constraint111We used this architecture in an earlier version of the paper., it achieved 0.568 average pixel accuracy. But when we used the full model, it achieved the best performance of 0.600 average pixel accuracy. This echoed our point that for the ill-posed joint distribution recovery problem, more constraints are beneficial.
Street images. We applied the proposed framework to several unsupervised street scene image translation tasks including sunny to rainy, day to night, summery to snowy, and vice versa. For each task, we used a set of images extracted from driving videos recorded at different days and cities. The numbers of the images in the sunny/day, rainy, night, summery, and snowy sets are 86165, 28915, 36280, 6838, and 6044. We trained the network to translate street scene image of size 640480. In Figure 6, we showed several example translation results . We found that our method could generate realistic translated images. We also found that one translation was usually harder than the other. Specifically, the translation that required adding more details to the image was usually harder (e.g. night to day). Additional results are available in https://github.com/mingyuliutw/unit.
Synthetic to real. In Figure 6, we showed several example results achieved by applying the proposed framework to translate images between the synthetic images in the SYNTHIA dataset RosCVPR16 and the real images in the Cityscape dataset cordts2015cityscapes . For the real to synthetic translation, we found our method made the cityscape images cartoon like. For the synthetic to real translation, our method achieved better results in the building, sky, road, and car regions than in the human regions.
Dog breed conversion.
We used the images of Husky, German Shepherd, Corgi, Samoyed, and Old English Sheep dogs in the ImageNet dataset to learn to translate dog images between different breeds. We only used the head regions, which were extracted by a template matching algorithm. Several example results were shown in Figure6. We found our method translated a dog to a different breed.
Cat species conversion. We also used the images of house cat, tiger, lion, cougar, leopard, jaguar, and cheetah in the ImageNet dataset to learn to translate cat images between different species. We only used the head regions, which again were extracted by a template matching algorithm. Several example results were shown in Figure 6. We found our method translated a cat to a different specie.
Face attribute. We used the CelebA dataset liu2015deep for attribute-based face images translation. Each face image in the dataset had several attributes, including blond hair, smiling, goatee, and eyeglasses. The face images with an attribute constituted the 1st domain, while those without the attribute constituted the 2nd domain. In Figure 6, we visualized the results where we translated several images that do not have blond hair, eye glasses, goatee, and smiling to corresponding images with each of the individual attributes. We found that the translated face images were realistic.
We applied the proposed framework to the problem for adapting a classifier trained using labeled samples in one domain (source domain) to classify samples in a new domain (target domain) where labeled samples in the new domain are unavailable during training. Early works have explored ideas from subspace learningfernando2013unsupervised
to deep feature learningganin2016domain ; liu2016coupled ; taigman2016unsupervised .
|Method||SA fernando2013unsupervised||DANN ganin2016domain||DTN taigman2016unsupervised||CoGAN||UNIT (proposed)|
We performed multi-task learning where we trained the framework to 1) translate images between the source and target domains and 2) classify samples in the source domain using the features extracted by the discriminator in the source domain. Here, we tied the weights of the high-level layers ofand . This allows us to adapt a classifier trained in the source domain to the target domain. Also, for a pair of generated images in different domains, we minimized the L1 distance between the features extracted by the highest layer of the discriminators, which further encouraged and to interpret a pair of corresponding images in the same way. We applied the approach to several tasks including adapting from the Street View House Number (SVHN) dataset netzer2011reading to the MNIST dataset and adapting between the MNIST and USPS datasets. Table 2 reported the achieved performance with comparison to the competing approaches. We found that our method achieved a 0.9053 accuracy for the SVHNMNIST task, which was much better than 0.8488 achieved by the previous state-of-the-art method taigman2016unsupervised . We also achieved better performance for the MNISTSVHN task than the Coupled GAN approach, which was the state-of-the-art. The digit images had a small resolution. Hence, we used a small network. We also found that the cycle-consistency constraint was not necessary for this task. More details about the experiments are available in Appendix B.
Several deep generative models were recently proposed for image generation including GANs goodfellow2014generative , VAEs kingma2013auto ; rezende2014stochastic , and PixelCNN van2016conditional . The proposed framework was based on GANs and VAEs but it was designed for the unsupervised image-to-image translation task, which could be considered as a conditional image generation model. In the following, we first review several recent GAN and VAE works and then discuss related image translation works.
GAN learning is via staging a zero-sum game between the generator and discriminator. The quality of GAN-generated images had improved dramatically since the introduction. LapGAN denton2015deep proposed a Laplacian pyramid implementation of GANs. DCGAN radford2015unsupervised used a deeper convolutional network. Several GAN training tricks were proposed in salimans2016improved . WGAN arjovsky2017wasserstein used the Wasserstein distance.
VAEs optimize a variational bound. By improving the variational approximation, better image generation results were achieved maaloe2016auxiliary ; kingma2016improving . In larsen2015autoencoding , a VAE-GAN architecture was proposed to improve image generation quality of VAEs. VAEs were applied to translate face image attribute in yan2015attribute2image .
Conditional generative model is a popular approach for mapping an image from one domain to another. Most of the existing works were based on supervised learningledig2016photo ; isola2016image ; johnson2016perceptual . Our work differed to the previous works in that we do not need corresponding images. Recently, taigman2016unsupervised
proposed the domain transformation network (DTN) and achieved promising results on translating small resolution face and digit images. In addition to faces and digits, we demonstrated that the proposed framework can translate large resolution natural images. It also achieved a better performance in the unsupervised domain adaptation task. Inshrivastava2016learning
, a conditional generative adversarial network-based approach was proposed to translate a rendering images to a real image for gaze estimation. In order to ensure the generated real image was similar to the original rendering image, the L1 distance between the generated and original image was minimized. We note that two contemporary paperszhu2017unpaired ; kim2017learning independently introduced the cycle-consistency constraint for the unsupervised image translation. We showed that that the cycle-consistency constraint is a natural consequence of the proposed shared-latent space assumption. From our experiment, we found that cycle-consistency and the weight-sharing (a realization of the shared-latent space assumption) constraints rendered comparable performance. When the two constraints were jointed used, the best performance was achieved.
We presented a general framework for unsupervised image-to-image translation. We showed it learned to translate an image from one domain to another without any corresponding images in two domains in the training dataset. The current framework has two limitations. First, the translation model is unimodal due to the Gaussian latent space assumption. Second, training could be unstable due to the saddle point searching problem. We plan to address these issues in the future work.
Conference on Computer Vision and Pattern Recognition Workshop, 2015.
Domain-adversarial training of neural networks.
Journal of Machine Learning Research, 2016.
Image-to-image translation with conditional adversarial networks.Conference on Computer Vision and Pattern Recognition, 2017.
Stochastic backpropagation and variational inference in deep latent gaussian models.International Conference on Machine Learning, 2014.
The network architecture used for the unsupervised image-to-image translation experiments is given in Table 3
. We use the following abbreviation for ease of presentation: N=Neurons, K=Kernel size, S=Stride size. The transposed convolutional layer is denoted by DCONV. The residual basic block is denoted as RESBLK.
MNISTUSPS. For the MNIST and USPS adaptation experiments, we used the entire training sets in the two domains (60000 training images for MNIST and 7291 training images for USPS) for learning and reported the classification performance on the test sets (10000 test images for MNIST and 2007 test images for USPS). The MNIST and USPS images had different sizes, we resized them to 2828 for facilitating the experiments. We trained the Coupled GAN algorithm liu2016coupled using the same setting for a fair comparison.
SVHNMNIST. For the SVHN and MNIST domain adaptation experiment, we used the extra training set (consisting of 531131 images) in the SVHN dataset for the source domain and the training set (consisting of 60000 images) in the MNIST dataset for the target domain as in the DTN work taigman2016unsupervised . The test set consists of 10000 images in the MNIST test dataset. The MNIST images were in gray-scale. We converted them to RGB images and performed a data augmentation where we also used the inversions of the original MNIST images for training. All the images were resized to 3232 for facilitating the experiment. We also found spatial context information was useful. For each input image, we created a 5-channel variant where the first three channels were the original RGB images and the last two channels were the normalized x and y coordinates.
The encoder and generator architecture was the same as the one used in the MNISTUSPS domain adaptation. For the discriminators and the classifier, we used a network architecture akin to the one used in the DTN paper. The details are given in Table 6. We used dropout at every layer in the classifier for avoiding over-fitting.
|1||CONV-(N64,K5,S2), BatchNorm, LeakyReLU||No|
|2||CONV-(N128,K5,S2), BatchNorm, LeakyReLU||Yes|
|3||CONV-(N256,K8,S1), BatchNorm, LeakyReLU||Yes|
|4||CONV-(N512,K1,S1), BatchNorm, LeakyReLU||Yes|
|1||DCONV-(N512,K4,S2), BatchNorm, LeakyReLU||Yes|
|2||DCONV-(N256,K4,S2), BatchNorm, LeakyReLU||Yes|
|3||DCONV-(N128,K4,S2), BatchNorm, LeakyReLU||Yes|
|4||DCONV-(N64,K4,S2), BatchNorm, LeakyReLU||No|
FC-(N500), ReLU, Dropout