iGAN
Interactive Image Generation via Generative Adversarial Networks
view repo
Realistic image manipulation is challenging because it requires modifying the image appearance in a user-controlled way, while preserving the realism of the result. Unless the user has considerable artistic skill, it is easy to "fall off" the manifold of natural images while editing. In this paper, we propose to learn the natural image manifold directly from data using a generative adversarial neural network. We then define a class of image editing operations, and constrain their output to lie on that learned manifold at all times. The model automatically adjusts the output keeping all edits as realistic as possible. All our manipulations are expressed in terms of constrained optimization and are applied in near-real time. We evaluate our algorithm on the task of realistic photo manipulation of shape and color. The presented method can further be used for changing one image to look like the other, as well as generating novel imagery from scratch based on user's scribbles.
READ FULL TEXT VIEW PDF
Altering the content of an image with photo editing tools is a tedious t...
read it
Many tasks in computer vision can be cast as a "label changing" problem,...
read it
Developing techniques for editing an outfit image through natural senten...
read it
In this paper, we propose a method to correct for chromatic aberration i...
read it
The garment transfer problem comprises two tasks: learning to separate a...
read it
This paper proposes a way to understand neural network artworks as
juxta...
read it
Learning a good image prior is a long-term goal for image restoration an...
read it
Interactive Image Generation via Generative Adversarial Networks
iGAN: a deep learning software that easily generates images with a few brushstrokes (from UC Berkeley and Adobe CTL)
Today, visual communication is sadly one-sided. We all perceive information in the visual form (through photographs, paintings, sculpture, etc), but only a chosen few are talented enough to effectively express themselves visually. This imbalance manifests itself even in the most mundane tasks. Consider an online shopping scenario: a user looking for shoes has found a pair that mostly suits her but she would like them to be a little taller, or wider, or in a different color. How can she communicate her preference to the shopping website? If the user is also an artist, then a few minutes with an image editing program will allow her to transform the shoe into what she wants, and then use image-based search to find it. However, for most of us, even a simple image manipulation in Photoshop presents insurmountable difficulties. One reason is the lack of “safety wheels” in image editing: any less-than-perfect edit immediately makes the image look completely unrealistic. To put another way, classic visual manipulation paradigm does not prevent the user from “falling off” the manifold of natural images.
Understanding and modeling the natural image manifold has been a long-standing open research problem. But in the last two years, there has been rapid advancement, fueled largely by the development of the generative adversarial networks [1]. In particular, several recent papers [1, 2, 3, 4, 5] have shown visually impressive results sampling random images drawn from the natural image manifold. However, there are two reasons preventing these advances from being useful in practical applications at this time. First, the generated images, while good, are still not quite photo-realistic (plus there are practical issues in making them high resolution). Second, these generative models are setup to produce images by sampling a latent vector-space, typically at random. So, these methods are not able to create and/or manipulate visual content in a user-controlled fashion.
In this paper, we use the generative adversarial neural network to learn the manifold of natural images, but we do not actually employ it for image generation. Instead, we use it as a constraint on the output of various image manipulation operations, to make sure the results lie on the learned manifold at all times. This enables us to reformulate several editing operations, specifically color and shape manipulations, in a natural and data-driven way. The model automatically adjusts the output keeping all edits as realistic as possible (Figure 1).
We show three applications based on our system: (1) Manipulating an existing photo based on an underlying generative model to achieve a different look (shape and color); (2) “Generative transformation” of one image to look more like another; (3) Generate a new image from scratch based on user’s scribbles and warping UI.
All manipulations are performed in a straightforward manner through gradient-based optimization, resulting in a simple and fast image editing tool. We hope that this work inspires further research in data-driven generative image editing, and thus release the code and data at our website.
Image editing and user interaction: Image editing is a well established area in computer graphics where an input image is manipulated to achieve a certain goal specified by the user. Examples of basic editing include changing the color properties of an image either globally [6] or locally [7]. More advanced editing methods such as image warping [8, 9, 10] or structured image editing [11] intelligently reshuffle the pixels in an image following user’s edits. While achieving impressive results in the hands of an expert, when these types of methods fail, they produce results that look nothing like a real image. Common artifacts include unrealistic colors, exaggerated stretching, obvious repetitions and over-smoothing. This is because they rely on low-level principles (e.g., similarity of color, gradients or patches) and do not capture higher-level information about natural images.
Image morphing: There are a number of techniques for producing a smooth visual transition between two input images. Traditional morphing methods [12] combine an intensity blend with a geometric warp that requires a dense correspondence. In Regenerative Morphing [13] the output sequence is regenerated from small patches sampled from the source images. Thus, each frame is constrained to look similar to the two sources. Exploring Photobios [14] presented an alternative way to transition between images, by finding a shortest path in a large image collection based on pairwise image distances. Here we extend this idea and produce a morph that is both close to the two sources and stays on, or close to, the natural image manifold.
Natural image statistics: Generative models of local image statistics have long been used as a prior for image restoration problems such as image denoising and deblurring. A common strategy is to learn local filter or patch models, such as Principal Components, Independent Components, Mixture of Gaussians or wavelet bases [15, 16, 17]. Some methods attempt to capture full-image likelihoods [18] through dense patch overlap, though the basic building block is still small patches that do not capture global image structures and long range relations. Zhu et al. [19] recently showed that discriminative deep neural networks learn a much stronger prior that captures both low-level statistics, as well as higher order semantic or color-balance clues. This deep prior can be directly used for a limited set of editing operations (e.g. compositing). However it does not extend to the diversity of editing operations considered in this work.
Neural generative models:
There is a large body of work on neural network based models for image generation. Early classes of probabilistic models of images include restricted Boltzmann machines (e.g.,
[20]) and their deep variants [21], auto-encoders [20, 22] and more recently, stochastic neural networks [23, 3, 24] and deterministic networks [25]. Generative adversarial networks (GAN), proposed by Goodfellow et al. [1], learn a generative network jointly with a second discriminative adversarial network in a mini-max objective. The discriminator tries to distinguish between the generated samples and natural image samples, while the generator tries to fool the discriminator producing highly realistic looking images. Unfortunately in practice, GAN does not yield a stable training objective, so several modifications have been proposed recently, such as a multi-scale generation [4]and a convolution-deconvolution architecture with batch normalization
[2]. While the above methods attempt to generate an image starting from a random vector, they do not provide tools to change the generation process with intuitive user controls. In this paper we try to remedy this by learning a generative model that can be easily controlled via a few intuitive user edits.Let us assume that all natural images lie on an ideal low-dimensional manifold with a distance function that measures the perceptual similarity between two images . Directly modeling this ideal manifold is extremely challenging, as it involves training a generative model in a highly structured and complex million dimensional space. Following the recent success of deep generative networks in generating natural looking images, we approximate the image manifold by learning a model using generative adversarial networks (GAN) [1, 2] from a large-scale image collection. Beside the high quality results, GAN has a few other useful properties for our task we will discuss next.
Generative Adversarial Networks: A GAN model consists of two neural networks: (1) a generative network that generates an image given a random vector , where denotes a d-dimensional latent space, and (2) a discriminative network
that predicts a probability of a photo being real (
) or generated (). For simplicity, we denote and as and in later sections. One common choice ofis a multivariate uniform distribution
. and are learned using a min-max objective [1]. GAN works well when trained on images of a certain class. We formally define and use it as an approximation to the ideal manifold (i.e ). We also approximate the distance function of two generated images as an Euclidean distance between their corresponding latent vectors, i.e., .GAN as a manifold approximation: We use GAN to approximate an ideal manifold for two reasons: first, it produces high-quality samples (see Figure 2
(a) for example). Though lacking visual details sometimes, the model can synthesize appealing samples with a plausible overall structure. Second, the Euclidean distance in the latent space often corresponds to a perceptually meaningful visual similarity (see Figure
2 (b) for examples). We therefore argue that GAN is a powerful generative model for modeling the image manifold.Traversing the manifold: Given two images on the manifold , one would like to seek a sequence of images with a smooth transition. This is often done by constructing an image graph with images as nodes, and pairwise distance function as the edge, and computing a shortest path between the starting image and end image [14]. In our case, we minimize where is the distance function. In our case , so a simple linear interpolation is the shortest path. Figure 2 (c) shows a smooth and meaningful image sequence generated by interpolating between two points in the latent space. We will now use this approximation of the manifold of natural images for realistic photo editing.
Figure 1 illustrates the overview of our approach. Given a real photo, we first project it onto our approximation of the image manifold by finding the closest latent feature vector of the GAN to the original image. Then, we present a real-time method for gradually and smoothly updating the latent vector so that it generates a desired image that both satisfies the user’s edits (e.g. a scribble or a warp; more details in Section 5
) and stays close to the natural image manifold. Unfortunately, in this transformation the generative model usually looses some of the important low-level details of the input image. We therefore propose a dense correspondence method that estimates both per-pixel color and shape changes from the edits applied to the generative model. We then transfer these changes to the original photo using an edge-aware interpolation technique and produce the final manipulated result.
A real photo lies, by definition, on the ideal image manifold . However for an approximate manifold , our goal here is to find a generated image close to in some distance metric as
(1) |
For the GAN manifold we can rewrite the above equation as follows:
(2) |
Our goal is to reconstruct the original photo using the generative model by minimizing the reconstruction error, where in some differentiable feature space . If , then the reconstruction error is simply pixel-wise Euclidean error. Previous work [5, 26] suggests that using deep neural network activations leads to a reconstruction of perceptually meaningful details. We found that a weighted combination of raw pixels and conv4 features () extracted from AlexNet [27]
trained on ImageNet
[28] to perform best.Projection via optimization: As both the feature extractor and the generative model are differentiable, we can directly optimize the above objective using L-BFGS-B [29]. However, the cascade of makes the problem highly non-convex, and as a result, the reconstruction quality strongly relies on a good initialization of . We can start from multiple random initializations and output the solution with the minimal cost. However the number of random initializations required to obtain a stable reconstruction is prohibitively large (more than 100), which makes real-time processing impossible. We instead train a deep neural network to minimize equation 2 directly.
Projection via a feedforward network: We train a feedforward neural network that directly predicts the latent vector from a . The training objective for the predictive model is written as follows:
(3) |
where denotes the -th image in the dataset. The architecture of the model is equivalent to the discriminator of the adversarial networks, and only varies in the final number of network outputs. Objective 3 is reminiscent of an auto-encoder pipeline, with a encoder and decoder . However, the decoder is fixed throughout the training. While the optimization problem 2 is exactly the same as the learning objective 3, the learning based approach often performs better and does not fall into local optima. We attribute this behavior to the regularity in the projection problem and the limited capacity of the network . Projections of similar images will share similar network parameters and produce a similar result. In some sense the loss for one image provides information for many more images that share a similar appearance [30]. However, the learned inversion is not always perfect, and can often be improved further by a few additional steps of optimization.
A hybrid method: The hybrid method takes advantage of both approaches above. Given a real photo , we first predict and then use it as the initialization for the optimization objective (Equation 2). So the predictive model we have trained serves as a fast bottom-up initialization method for a non-convex optimization problem. Figure 3 shows a comparison of these three methods. See Section 7.4 for a more quantitative evaluation.
With the image projected onto the manifold as via the projection methods just described, we can start modifying the image on that manifold. We update the initial projection by simultaneously matching the user intentions while staying on the manifold, close to the original image .
Each editing operation is formulated as a constraint on a local part of the output image . The editing operations include color, shape and warping constraints, and are further described in Section 5.1. Given an initial projection , we find a new image close to trying to satisfy as many constraints as possible
(4) |
where the data term measures deviation from the constraint and the smoothness term enforces moving in small steps on the manifold, so that the image content is not altered too much. We set in our experiments.
The above equation simplifies to the following on the approximate GAN manifold :
(5) |
Here the last term optionally captures the visual realism of the generated output as judged by the GAN discriminator . This further pushes the image towards the manifold of natural images, and slightly improves the visual quality of the result. By default, we turn off this term to increase frame rates.
Gradient descent update: For most constraints Equation 5 is non-convex. We solve it using gradient descent, which allows us to provide the user with a real-time feedback as she manipulates the image. As a result, the objective 5 evolves in real-time as well. For computational reasons, we only perform a few gradient descent updates after changing the constraints . Each update step takes ms, which ensures an interactive feedback. Figure 4 shows one example of the update of . Given an initial red shoe as shown in Figure 4, the user gradually scribbles a black color stroke (i.e. specifies a region is black) on the shoe image (Figure 4 a). Then our update method smoothly changes the image appearance (Figure 4 b) by adding more and more of the user constraints. Once the final result is computed, a user can see the interpolation sequence between the initial point and (Figure 4 c), and select any intermediate result as the new starting point. Please see supplemental video for more details.
While this editing framework allows us to modify any generated image on the approximate natural image manifold , it does not directly provide us a way to modify the original high resolution image . In the next section we show how edits on the approximate manifold can be transferred to the original image.
Give the original photo (e.g. a black shoe) and its projection on the manifold , and a user modification by our method (e.g. the generated red shoe). The generated image captures the roughly change we want, albeit the quality is degraded w.r.t the original image.
Can we instead adjust the original photo and produce a more photo-realistic result that exhibits the changes in the generated image? A straightforward way is to transfer directly the pixel changes (i.e. . We have tried this approach and it introduces new artifacts due to the misalignment of the two images. To address this issue, we develop a dense correspondence algorithm to estimate both the geometric and color changes induced by the editing process.
Specifically, given two generated images and , we can generate any number of intermediate frames , where consecutive frames only exhibit minor visual variations.
Motion+Color flow algorithm: We then estimate the color and geometric changes by generalizing the brightness constancy assumption in traditional optical flow methods [31, 32]. This results in the following motion+color flow objective^{†}^{†}For simplicity, we omit the pixel subscript for all the variables.:
(6) |
where denotes the RGB values of pixel in the generated image . is the flow vector with respect to the change of , and denotes a color affine transformation matrix. The data term relaxes the color constancy assumption by introducing a locally affine color transfer model [33] while the spatial and color regularization terms encourage smoothness in both the motion and color change. We solve the objective by iteratively estimating the flow using a traditional optical flow algorithm, and computing the color change by solving a system of linear equations [33]. We iterate times. We produce intermediate frames (i.e. ).
We estimate the changes between nearby frames, and concatenate these changes frame by frame to obtain long-range changes between any two frames along the interpolation sequence . Figure 5 shows a warping sequence after we apply the flow to the initial projection .
Transfer edits to the original photo: After estimating the color and shape changes in the generated image sequence, we apply them to the original photo and produce an interesting transition sequence of photo-realistic images as shown in Figure 5. As the resolution of the flow and color fields are limited to the resolution of the generated image (i.e. ), we upsample those edits using a guided image filter [34].
The user interface consists of a main window showing the current edited photo, a display showing thumbnails of all the candidate results, and a slider bar to explore the interpolation sequence between the original photo and the final result. Please see our supplemental video for more details.
Candidate results: Given the objective (Equation 5) derived with the user guidance, we generate multiple different results by initializing as random perturbations of . We generate examples and show the best results sorted by the objective cost (Equation 5).
Relative edits: Once a user finishes one edit, she can drag a slider to see all the intermediate results interpolated between the original and the final manipulated photo. We call this “relative edits” as it allows a user to explore more alternatives with a single edit. Similar to relative attributes [35], a user can express ideas like changing the handle of the handbag to be more red, or making the heel of the shoes slightly higher, without committing to a specific final state.
Our system provides three constraints to edit the photo in different aspects: coloring, sketching and warping. All constraints are expressed as brush tools. In the following, we explain the usage of each brush, and the corresponding constraints.
Coloring brush: The coloring brush allows the user to change the color of a specific region. The user selects a color from a palette and can adjust the brush size. For each pixel marked with this brush we constrain the color of a pixel to the selected values .
Sketching brush: The sketching brush allows the user to outline the shape or add fine details [36]. We constrain a differentiable HOG descriptor [37] at a certain location in the image to be close to the user stroke (i.e. ). We chose the HOG feature extractor because it is binned, which makes it robust to sketching inaccuracies.
Warping brush: The warping brush allows the user to modify the shape more explicitly. The user first selects a local region (a window with adjustable size), and then drag it to another location. We then place both a color and sketching constraint on the displaced pixels encouraging the target patch to mimic the appearance of the dragged region.
Network architecture: We follow the same architecture of deep convolutional generative adversarial networks (DCGAN) [2]
. DCGAN mainly builds on multiple convolution, deconvolution and ReLU layers, and eases the min-max training via batch normalization
[38]. We train the generator to produce a image given a -dimensional random vector. Notice that our method can also use other generative models (e.g. variational auto-encoder [3] or future improvements in this area) to approximate the natural image manifold.Computational time: We run our system on a Titan X GPU. Each update of the vector takes milliseconds, which allows the real-time image editing and generation. Once an edit is finished, it takes seconds for our edit transfer method to produce high-resolution final result.
We first introduce the statistics of our dataset. We then show three main applications: realistic image manipulation, generative image transformation, and generating a photo from scratch using our brush tools. Finally, we evaluate our image reconstruction methods, and perform a human perception study to understand the realism of generated results. Please refer to the supplementary material for more results and comparisons.
Datasets: We experiment with multiple photo collections from various sources as follows: “shoes” dataset [39], which has K shoes collected from Zappos.com (the shoes are roughly centered but not well aligned, and roughly facing left, with frontal to side view); “church outdoor” dataset (K images) from the LSUN challenge [40]; “outdoor natural” images (K) from the MIT Places dataset [41]; and two query-based product collections downloaded from Amazon, including “handbags” (K) and “shirts” (K). The downloaded handbags and shirts are roughly centered but no further alignment has been performed.
Our main application is photo-realistic image manipulation using the brush interactions described in Section 5.1. See Figure 6 for a few examples where the brush edits are depicted on the left (dashed line for the sketch tool, color scribble for the color brush and a red square with arrow for the warp tool). See the supplementary video for more interactive manipulation demos.
An interesting outcome of the editing process is the sequence of intermediate generated images that can be seen as a new kind of image morphing [12, 42, 13]. We call it “generative transformation”. We use this sequence to transform the shape and color of one image to look like another image automatically, i.e., without any user edits. This is done by applying the motion+color flow on either of the sources. Figure 7 shows a few “generative transform” examples.
Another byproduct of our method is that if there is no image to begin with and all we have are the user brush strokes, the method would generate a natural image that best satisfies the user constraints. This could be useful for dataset exploration and browsing. The difference with previous sketch-to-image retrieval methods [43] or AverageExplorer [44], is that due to potentially contradicting user constraints, the result may look very different than any single image from the dataset or an average of such images, and more of a realistic hybrid image [45]. See some examples in Figure 8.
Shoes | Church Outdoor | Outdoor Natural | Handbags | Shirts | |
Optimization-based | 0.155 | 0.319 | 0.176 | 0.299 | 0.284 |
Network-based | 0.210 | 0.338 | 0.198 | 0.302 | 0.265 |
Hybrid (ours) | 0.140 | 0.250 | 0.145 | 0.242 | 0.184 |
Image reconstruction evaluation: We evaluate three image reconstruction methods described in Section 4.1: optimization-based, network-based and our hybrid approach that combines the last two. We run these on test images per category, and evaluate them by the reconstruction error defined in Equation 1. Table 1 shows the mean reconstruction error of these three methods on different datasets. We can see the optimization-based and neural network-based methods perform comparably, where their combination yields better results. See Figure 3 for a qualitative comparison. We include PSNR (in dB) results in the supplementary material.
Class-specific model: So far, we have trained the generative model on a particular class of images. As a comparison, we train a cross-class model on three datasets altogether (i.e. shoes, handbags, and shirts), and observe that the model achieves worse reconstruction error compared to class-specific models (by ). We also have tried to use a class-specific model to reconstruct images from a different class. The mean cross-category reconstruction errors are much worse: shoes model used for shoes: vs. shoes model for handbags: , and for shirts: . However, we expect a model trained on many categories (e.g. ) to generalize better to novel objects.
Perception study: We perform a small perception study to compare the photo realism of four types of images: real photos, generated samples produced by GAN, our method (shape only), and our method (shape+color). We collect annotations for images by asking Amazon Mechanical Turk workers if the image look realistic or not. Real photos: , DCGAN: , ours (shape+color): ; ours (shape only): . DCGAN model alone produces less photo-realistic images, but when combined with our edit transfer, the realism significantly improves.
We presented a step towards image editing with a direct constraint to stay close to the manifold of real images. We approximate this manifold using the state-of-the-art in deep generative models (DCGAN). We show how to make interactive edits to the generated images and transfer the resulting changes in shape and color back to the original image. Thus, the quality of the generated results (low resolution, missing texture and details) and the types of data DCGAN is applicable to (works well on structured datasets such as product images and worse on more general imagery), limits how far we can get with this editing approach. However our method is not tied to a particular generative method and will improve with the advancement of this field. Our current editing brush tools allow rough changes in color and shape but not texture and more complex structure changes. We leave these for future work.
Acknowledgments This work was supported, in part, by funding from Adobe, eBay and Intel, as well as a hardware grant from NVIDIA. J.-Y. Zhu is supported by Facebook Graduate Fellowship.
Extracting and composing robust features with denoising autoencoders.
In: ICML. (2008)Draw: A recurrent neural network for image generation.
ICML (2015)Learning to generate chairs with convolutional neural networks.
In: CVPR. (2015) 1538–1546Learning deep features for scene recognition using places database.
In: NIPS. (2014) 487–495In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. (2013) 2307–2314
Comments
There are no comments yet.