Generating Images Part by Part with Composite …alanwags/DLAI2016/16. (Kwak+...Image generation...

5
Generating Images Part by Part with Composite Generative Adversarial Networks Hanock Kwak and Byoung-Tak Zhang School of Computer Science and Engineering, Seoul National University {hnkwak, btzhang}@bi.snu.ac.kr Abstract Image generation remains a fundamental problem in artificial intelligence in general and deep learn- ing in specific. The generative adversarial network (GAN) was successful in generating high quality samples of natural images. We propose a model called composite generative adversarial network, that reveals the complex structure of images with multiple generators in which each generator gener- ates some part of the image. Those parts are com- bined by alpha blending process to create a new single image. It can generate, for example, back- ground and face sequentially with two generators, after training on face dataset. Training was done in an unsupervised way without any labels about what each generator should generate. We found possibil- ities of learning the structure by using this genera- tive model empirically. 1 Introduction Images are composed of several different objects forming a hiarchical structure with various styles and shapes. Recently, deep learning models are used to implicitly disentangle those complex underlying patterns [Reed et al., 2014], form dis- tributed feature representations [Hinton and Salakhutdinov, 2006], and solve classification [Krizhevsky et al., 2012] and generation [Radford et al., 2015] problems using large dataset. While lots of classification problems have focused on abstraction for finite number of labels, generation prob- lems need a concretizing process starting from latent vari- ables. In other words, the latent variables of generative mod- els must contain concrete information about the data, which is not the case for the features of discriminative models. This gives us interesting challenges in generation task which is a fundamental problem of artificial intelligence. Even though we can easily imagine a scene by combining and mixing se- mantic parts, current generative models are far from reaching our abilities. Generative adversarial networks (GAN) [Goodfellow et al., 2014], based on deep neural networks, are successful un- supervised learning models that can generate samples of nat- ural images generalized from the training data. It provides an alternative to intractable maximum likelihood estimation and Figure 1: Examples of generated images from CGAN with three generators. C 1 ,C 2 ,C 3 are images generated from three generators, respectively, and O (3) is final output. Sim- ilar real images are shown for comparison. Black and white checkerboard is the default background for transparent im- ages. pixel-wise loss functions. GAN simultaneously trains two models: a generator G that tries to generate real images, and a discriminator D that classifies between the real images that came from the training data and the fake images that came from G. The D alleviates lack of semantic consideration in pixel-wise loss function used in most auto-encoder models. It is proven that if the GAN has enough capacity, data dis- tribution formed by G can converge to the distribution over real data [Goodfellow et al., 2014]. In practice, however, the convergence is intractable and it is easy to overfit due to ex- ponential complexity of images in which multiple objects ex- ist in any position with noisy features like shape, color, and size. To solve this issue, we propose a composite generative adversarial network (CGAN) that can generate images part by part instead of generating whole images directly. CGAN differs from other recurrent generative models [Mansimov et al., 2015; Im et al., 2016], which simply add the sequence of generated images blurring each image in the overlapping areas. In order to address this problem, CGAN uses an alpha channel for opacity along with RGB channels to stack images iteratively with alpha blending process. The alpha blending process maintains previous image in some areas and overlap the new image perfectly in other areas. For instance, given a transparent image the model may put a snowy background first, then later add trees and characters sequentially as shown in Figure 1.

Transcript of Generating Images Part by Part with Composite …alanwags/DLAI2016/16. (Kwak+...Image generation...

Page 1: Generating Images Part by Part with Composite …alanwags/DLAI2016/16. (Kwak+...Image generation remains a fundamental problem in artificial intelligence in general and deep learn-ing

Generating Images Part by Part with Composite Generative Adversarial Networks

Hanock Kwak and Byoung-Tak ZhangSchool of Computer Science and Engineering, Seoul National University

{hnkwak, btzhang}@bi.snu.ac.kr

AbstractImage generation remains a fundamental problemin artificial intelligence in general and deep learn-ing in specific. The generative adversarial network(GAN) was successful in generating high qualitysamples of natural images. We propose a modelcalled composite generative adversarial network,that reveals the complex structure of images withmultiple generators in which each generator gener-ates some part of the image. Those parts are com-bined by alpha blending process to create a newsingle image. It can generate, for example, back-ground and face sequentially with two generators,after training on face dataset. Training was done inan unsupervised way without any labels about whateach generator should generate. We found possibil-ities of learning the structure by using this genera-tive model empirically.

1 IntroductionImages are composed of several different objects forming ahiarchical structure with various styles and shapes. Recently,deep learning models are used to implicitly disentangle thosecomplex underlying patterns [Reed et al., 2014], form dis-tributed feature representations [Hinton and Salakhutdinov,2006], and solve classification [Krizhevsky et al., 2012]and generation [Radford et al., 2015] problems using largedataset. While lots of classification problems have focusedon abstraction for finite number of labels, generation prob-lems need a concretizing process starting from latent vari-ables. In other words, the latent variables of generative mod-els must contain concrete information about the data, whichis not the case for the features of discriminative models. Thisgives us interesting challenges in generation task which is afundamental problem of artificial intelligence. Even thoughwe can easily imagine a scene by combining and mixing se-mantic parts, current generative models are far from reachingour abilities.

Generative adversarial networks (GAN) [Goodfellow etal., 2014], based on deep neural networks, are successful un-supervised learning models that can generate samples of nat-ural images generalized from the training data. It provides analternative to intractable maximum likelihood estimation and

Figure 1: Examples of generated images from CGAN withthree generators. C1, C2, C3 are images generated fromthree generators, respectively, and O(3) is final output. Sim-ilar real images are shown for comparison. Black and whitecheckerboard is the default background for transparent im-ages.

pixel-wise loss functions. GAN simultaneously trains twomodels: a generator G that tries to generate real images, anda discriminator D that classifies between the real images thatcame from the training data and the fake images that camefrom G. The D alleviates lack of semantic consideration inpixel-wise loss function used in most auto-encoder models.

It is proven that if the GAN has enough capacity, data dis-tribution formed by G can converge to the distribution overreal data [Goodfellow et al., 2014]. In practice, however, theconvergence is intractable and it is easy to overfit due to ex-ponential complexity of images in which multiple objects ex-ist in any position with noisy features like shape, color, andsize. To solve this issue, we propose a composite generativeadversarial network (CGAN) that can generate images partby part instead of generating whole images directly. CGANdiffers from other recurrent generative models [Mansimov etal., 2015; Im et al., 2016], which simply add the sequenceof generated images blurring each image in the overlappingareas. In order to address this problem, CGAN uses an alphachannel for opacity along with RGB channels to stack imagesiteratively with alpha blending process. The alpha blendingprocess maintains previous image in some areas and overlapthe new image perfectly in other areas. For instance, givena transparent image the model may put a snowy backgroundfirst, then later add trees and characters sequentially as shownin Figure 1.

Page 2: Generating Images Part by Part with Composite …alanwags/DLAI2016/16. (Kwak+...Image generation remains a fundamental problem in artificial intelligence in general and deep learn-ing

Figure 2: The structure of CGAN. At first step, the RNNaccepts noise z as an input, and then it feeds ht−1 back intoitself at each step t. The RNN recursively generates inputsh1, h2, ..., hn which are then passed through each generatorindependently creating images C1, C2, ..., Cn having RGBAchannels. The images are then combined sequentially by al-pha blending process to form the final output O(n). Note thatgenerators do not share weights, meaning that they are all dif-ferent networks

Understanding the sparse and hiarchical structure in an im-age is one of the expected functionalities of future intelligentagents. Our work tries to implement this functionality by us-ing CGAN.

To illustrate how CGAN generates complicated imagespart by part, we used collection of cartoon videos for chil-dren, titled “Pororo”, and CelebA dataset consisting of faceimages.

2 Related WorksVariants of probablistic graphical models have been intro-duced to capture the data distribution. Undirected graphicalmodels with latent variables, such as restricted Boltzmannmachines (RBMs) and deep Boltzmann machines (DBMs)[Salakhutdinov and Hinton, 2009] provided underlying dis-cipline for pretraining deep neural networks. Deep belief net-works (DBNs) [Hinton and Salakhutdinov, 2006] and its vari-ants are hybrid models in which pretrained DBMs and sig-moid belief networks are mixed layer-wise. DBNs are ableto reproduce the input from multiple hidden layers, but theyare restricted to a simple dataset due to the computationallycostly step of Markov chain Monte Carlo (MCMC) methods.

[Kingma and Welling, 2014] have proposed the variationalauto-encoder (VAE) which has an encoder that approximatesthe posterior distribution of continuous latent variables, anda decoder that reconstructs the data from latent variables,trained by stochastic variational inference algorithm. [Gregoret al., 2015] have extended VAE to deep recurrent attentionwriter (DRAW) in which VAE is processed recurrently in-corporating differentiable attention mechanism. ConditionalalignDRAW model [Mansimov et al., 2015] is an extensionof DRAW that generates an image conditioned on a sentence.

Since VAE optimizes pixel-wise loss functions, images gen-erated by VAE tend to be blurred.

Similar to the DRAW, a recurrent adversarial network [Imet al., 2016] adds generated images from multiple generatorssequentially and puts the sigmoid function at the end. Simplyadding the images based on RGB channels results blurring ef-fects. Our proposed CGAN uses the additional alpha channelto avoid this issue.

Some of the variants of GAN, such as LAPGAN [Dentonet al., 2015], DCGAN [Radford et al., 2015], and recurrentadversarial network [Im et al., 2016], improved the quality ofgenerated images. VAE/GAN [Larsen et al., 2015] replacedpixel-wise loss function of VAE with feature-wise loss func-tion where the features come from the discriminator of GAN.[Ulyanov et al., 2016] have used two GAN: the Structure-GAN generates structures; the Style-GAN puts styles on thestructures.

3 ModelIn this section, we first review GAN in detail and describehow we combined GAN with alpha blending process. In addi-tion to the basic idea, several recent deep learning techniques(batch normalization [Ioffe and Szegedy, 2015], ADAM[Kingma and Ba, 2015], LSTM [Hochreiter and Schmidhu-ber, 1997], etc.), critical to the performance of CGAN, wereutilized.

3.1 Generative Adversarial NetworksA GAN has two networks: a generatorG that tries to generatereal data given a noize z ∼ pz(z), and a discriminator D ∈[0, 1] that classifies the real data x ∼ pdata(x) and the fakedata G(z) generated from G. The objective of G is to fitthe true data distribution deceiving D by playing followingminimax game:

minθG

maxθD

Ex∼pdata(x)[logD(x)]

+ Ez∼pz(z)[log(1−D(G(z)))],(1)

where θG and θD are parameters of G and D, respectively.Given mini-batch of {x1, x2, ..., xm} and {z1, z2, ..., zm}, θGand θD are updated for each iteration as following:

θG ← θG − γ∇θGm∑i=1

log(1−D(G(zi)))

θD ← θD + γ∇θDm∑i=1

logD(xi) + log(1−D(G(zi))),

(2)

where γ is a learning rate which could be different for Gand D.

3.2 Alpha BlendingThe alpha blending combines two translucent images, pro-ducing a new blended image. The value of alpha is between0.0 and 1.0, where a pixel is fully trasparent if 0.0, and fullyopaque if 1.0. We denote CijRGB

as a 3-dimensional vector

Page 3: Generating Images Part by Part with Composite …alanwags/DLAI2016/16. (Kwak+...Image generation remains a fundamental problem in artificial intelligence in general and deep learn-ing

Figure 3: Samples from CGAN after being trained on (a) CelebA, and (b) Pororo datasets. Black and white checkerboard is thedefault background for trasparent images.

of RGB values in position (i, j) and CijA as a scalar alphavalue of the same position. A CGAN uses alpha blendingwhich covers the previous image C(prev) with the next imageC(next) to make the new image C(new):

C(new)ijRGB

= C(prev)ijRGB

C(prev)ijA

(1− C(next)ijA

) + C(next)ijRGB

C(next)ijA

.

(3)

Assuming that the new image is opaque, C(new)ijA

is always1. This process maintains colors of the next image whereC

(next)ijA

is nearly one, and that of the previous image where

C(next)ijA

is nearly zero.

3.3 Composite Generative Adversarial NetworksA CGAN, a extension of GAN, consists of multiple gener-ators connected with a recurrent neural network (RNN) asshown in Figure 2. The generators in CGANs are differentfrom that of GANs as there are additional alpha channels inthe output. The images are then combined sequentially withalpha blending to form a final image.

Given a input noise z of CGAN, the RNN produces inputsh1, h2, ..., hn of each generator sequentially as following:

z ∼ pz(z) (4)h0 = z (5)ht = RNN(ht−1) (6)

The RNN preserves the consistency between the genera-tors, so that the generated images are all related. We denote

the generators and the generated images as G1, G2, ..., Gn,and C(1), C(2), ..., C(n), respectively. Note that C(i) is aRGBA image in which all pixels are four dimensional vec-tors. To illustrate how a final output image O(n) is made, wedenote intermediate images as O(1), O(2), ..., O(n−1). Then,the following explains how O(n) is formed:

C(t) = Gi(ht) (7)

O(t)ijRGB

=

{C

(1)ijRGB

C(1)ijA

if t = 1

O(t−1)ijRGB

(1− C(t)ijA

) + C(t)ijRGB

C(t)ijA

if t > 1

(8)

The objective of generators in whole is same as that ofGAN, and the algorithm of CGAN is similar to that of GANas illustrated in algorithm 1.

4 ExperimentsEvaluation of generative models is problematic [Theis et al.,2016] due to various objectives (density estimator, featurelearning, clustering, etc.) of unsupervised learning. Sinceour objective is to generate images part by part, qualitativeanalysis takes most part in assessment of CGAN.

All images are resized to 64×64 with antialiasing. We usedlong short-term memory (LSTM) [Hochreiter and Schmidhu-ber, 1997] architecture for RNN. The structures of each gen-erator are identical and similar to that of DCGAN [Radfordet al., 2015] which has series of four frationally strided con-volutions (or transposed convolution).

Page 4: Generating Images Part by Part with Composite …alanwags/DLAI2016/16. (Kwak+...Image generation remains a fundamental problem in artificial intelligence in general and deep learn-ing

Algorithm 1 The algorithm of CGANInput: dataset X , the number of generators n, mini-batchsize mInitialize θD, θG1 , θG2 , ..., θGn .for number of training iterations do

Select m data {x1, x2, ..., xm} ⊂ X randomlyDraw m noises {z1, z2, ..., zm} ∼ pz(z)

θD ← θD + γ∇θDm∑i=1

logD(xi) + log(1−D(G(zi)))

for i = 1 to n do

θG ← θGi− γ∇θGi

m∑i=1

log(1−D(G(zi)))

end forend for

4.1 CelebA face imagesCelebA dataset contains 202,599 face images, 11,177 numberof identities. The images in this dataset cover large pose vari-ations and background clutter. We used two generators on thisdataset and the result is shown in Figure 3 (a). The first gen-erator generated backgrounds and the second one generatedfaces mostly, yet sometime second one only generates hairsand other parts are supported by the first one. Even thoughoverall process is stochastic and behavior of CGAN is unpre-dictable due to its unsupervised setting, CGAN successfullygenerates full images while all generators share their effortsfairly.

4.2 Pororo cartoon videoPororo is a cartoon video that consists of 183 episodes with1,232 minutes of playing time. The dataset has large diver-sities of poses, sizes, and positions of characters, yet mostof the backgrounds come from snowy mountains, glaciers,forests and wooden houses. We captured frames for each sec-ond from the video and shuffled to avoid bias. As shownin Figure 3 (b), some final images are generated combiningbackgrounds, trees and characters separately. The ways ofgeneration are diverse due to complexity of the real images.

5 DiscussionDisentanglement of high dimensional data has been thorouglystudied, yet it has not been sufficiently solved using unsuper-vised learning. Compared to humans who see the video ofreal life for numerous years, 100K ∼ 1M of images might betoo small for learning tasks like distinguishing objects fromscenes. Yet we found implicit possibilities of structure learn-ing from images without any labels by constructing the hier-archical structures of the images. With a larger dataset, futuremodels could understand images in more detail and might becapable of changing arrangement of characters dynamicallywithout touching the backgrounds.

Our model could be extended to other domains such asvideo, text, audio, or a combination of them. One of the maingoal of unsupervised learning is any modality to any modalitymapping. Since most of the data has hierarchical structures,

studies on decomposing the combined data are essential tofinding correlation between multimodal data.

6 AcknowlegementsThis work was partly supported by the Institute for Informa-tion & Communications Technology Promotion (R0126-16-1072-SW.StarLab), Korea Evaluation Institute of IndustrialTechnology (10044009-HRI.MESSI, 10060086-RISF), andAgency for Defense Development (UD130070ID-BMRR)grant funded by the Korea government (MSIP, DAPA).

References[Denton et al., 2015] Emily L Denton, Soumith Chintala,

Rob Fergus, et al. Deep generative image models usinga laplacian pyramid of adversarial networks. In Advancesin Neural Information Processing Systems, pages 1486–1494, 2015.

[Goodfellow et al., 2014] Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley,Sherjil Ozair, Aaron Courville, and Yoshua Bengio. Gen-erative adversarial nets. In Advances in Neural Informa-tion Processing Systems, pages 2672–2680, 2014.

[Gregor et al., 2015] Karol Gregor, Ivo Danihelka, AlexGraves, Danilo Jimenez Rezende, and Daan Wierstra.DRAW: A recurrent neural network for image generation.In Proceedings of the 32nd International Conference onMachine Learning, ICML 2015, Lille, France, 6-11 July2015, pages 1462–1471, 2015.

[Hinton and Salakhutdinov, 2006] Geoffrey E Hinton andRuslan R Salakhutdinov. Reducing the dimensionality ofdata with neural networks. Science, 313(5786):504–507,2006.

[Hochreiter and Schmidhuber, 1997] Sepp Hochreiter andJurgen Schmidhuber. Long short-term memory. Neuralcomputation, 9(8):1735–1780, 1997.

[Im et al., 2016] Daniel Jiwoong Im, Chris Dongjoo Kim,Hui Jiang, and Roland Memisevic. Generating im-ages with recurrent adversarial networks. arXiv preprintarXiv:1602.05110, 2016.

[Ioffe and Szegedy, 2015] Sergey Ioffe and ChristianSzegedy. Batch normalization: Accelerating deep net-work training by reducing internal covariate shift. InFrancis R. Bach and David M. Blei, editors, ICML, vol-ume 37 of JMLR Proceedings, pages 448–456. JMLR.org,2015.

[Kingma and Ba, 2015] Diederik Kingma and Jimmy Ba.Adam: A method for stochastic optimization. In Proceed-ings of the International Conference on Learning Repre-sentations (ICLR), 2015.

[Kingma and Welling, 2014] Diederik P Kingma and MaxWelling. Auto-encoding variational bayes. In Proceedingsof the International Conference on Learning Representa-tions (ICLR), 2014.

[Krizhevsky et al., 2012] Alex Krizhevsky, Ilya Sutskever,and Geoffrey E Hinton. Imagenet classification with deep

Page 5: Generating Images Part by Part with Composite …alanwags/DLAI2016/16. (Kwak+...Image generation remains a fundamental problem in artificial intelligence in general and deep learn-ing

convolutional neural networks. In Advances in neural in-formation processing systems, pages 1097–1105, 2012.

[Larsen et al., 2015] Anders Boesen Lindbo Larsen,Søren Kaae Sønderby, and Ole Winther. Autoencodingbeyond pixels using a learned similarity metric. arXivpreprint arXiv:1512.09300, 2015.

[Mansimov et al., 2015] Elman Mansimov, Emilio Parisotto,Jimmy Lei Ba, and Ruslan Salakhutdinov. Generatingimages from captions with attention. In Proceedings ofthe International Conference on Learning Representations(ICLR), 2015.

[Radford et al., 2015] Alec Radford, Luke Metz, andSoumith Chintala. Unsupervised representation learningwith deep convolutional generative adversarial networks.In Proceedings of the International Conference onLearning Representations (ICLR), 2015.

[Reed et al., 2014] Scott Reed, Kihyuk Sohn, Yuting Zhang,and Honglak Lee. Learning to disentangle factors of vari-ation with manifold interaction. In Proceedings of the 31stInternational Conference on Machine Learning (ICML-14), pages 1431–1439, 2014.

[Salakhutdinov and Hinton, 2009] Ruslan Salakhutdinovand Geoffrey E Hinton. Deep boltzmann machines. InInternational conference on artificial intelligence andstatistics, pages 448–455, 2009.

[Theis et al., 2016] L. Theis, A. van den Oord, andM. Bethge. A note on the evaluation of generative models.Nov 2016. International Conference on Learning Repre-sentations.

[Ulyanov et al., 2016] Dmitry Ulyanov, Vadim Lebedev,Andrea Vedaldi, and Victor Lempitsky. Texture networks:Feed-forward synthesis of textures and stylized images.arXiv preprint arXiv:1603.03417, 2016.