scieee AI-readable full text Open interactive document viewer

Attribute transfer in image generation using conditional GANs

Pueyo Morillo, Jorge

Abstract

Research in the state of the art methods of Conditional Image Generation using GANs and development of a method to automatically change the visual style of a bedroom.

Full text

Attribute Transfer in Image Generation using Conditional GANs Degree Thesis Jorge Pueyo Morillo In partial fulfillment of the requirements for the degree in Telecommunications Technologies and Services Engineering Director: Javier Ruiz Hidalgo Barcelona, Date 19/06/2021 Contents List of Figures 4 1 Introduction 9 1.1 Objectives.................................... 10 1.2 Planification................................... 10 2 Review of the Literature 12 2.1 Fundamentals.................................. 12 2.1.1 Convolutional Neural Network . . . . . . . . . . . . . . . . . . . . . 12 2.1.2 Generative Adversarial Network . . . . . . . . . . . . . . . . . . . . 13 2.2 StateoftheArt................................. 14 2.2.1 StyleGAN2 ............................... 14 2.2.2 VOGUE................................. 14 2.2.3 ADGAN................................. 15 2.2.4 MixNMatch............................... 15 2.2.5 Pix2Pix ................................. 16 2.2.6 SPADE ................................. 17 3 Methodology 18 3.1 Datasets..................................... 18 3.2 RoomGAN ................................... 20 3.2.1 Layout.................................. 21 3.2.2 Traininginputs ............................. 22 3.2.3 Losses .................................. 24 3.3 MixNMatch ................................... 25 3.4 Pix2Pix ..................................... 26 4 Experiments and results 27 4.1 Implementation................................. 27 4.2 Parameters ................................... 27 4.3 EvaluationMetrics ............................... 27 4.4 RoomGAN ................................... 28 4.4.1 Firstexperiment ............................ 28 4.4.2 Second experiment . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 4.4.3 Thirdexperiment............................ 31 4.4.4 Fourth experiment . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 4.4.5 InferenceTime ............................. 34 4.5 MixNMatch ................................... 34 4.6 SPADE ..................................... 37 4.7 Pix2Pix ..................................... 39 4.8 Comparison ................................... 42 5 Conclusions 45 5.1 FutureWork................................... 45 2 References 46 3 List of Figures 1 Attribute transfer over bedrooms. . . . . . . . . . . . . . . . . . . . . . . . 9 2 Separation of tasks performed. Green indicates tasks performed by both of us, yellow denotes tasks performed by Aleix and blue for the ones I carried out. ....................................... 10 3 Gantt diagram of the project . . . . . . . . . . . . . . . . . . . . . . . . . 11 4 Single step of a 2D convolution operation, using a 3x3 kernel [15] . . . . . 12 5 Typesofpooling[10]............................... 12 6 Example of a CNN structure [14]. . . . . . . . . . . . . . . . . . . . . . . . 13 7 GANstructure[2]. ............................... 13 8 Demonstration of the VOGUE capabilities. This method can switch both top and bottom garments. . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 9 Source person synthesized in different poses. . . . . . . . . . . . . . . . . . 15 10 Garment transfer on both upper and bottom clothes. . . . . . . . . . . . . 15 11 Example of usage proposed by MixNMatch. . . . . . . . . . . . . . . . . . 16 12 Examples of Image-to-Image translation. . . . . . . . . . . . . . . . . . . . 16 13 Output generated by the SPADE model. . . . . . . . . . . . . . . . . . . . 17 14 Different synthesized images, generated from the same semantic layout, depending on the image provided as style. . . . . . . . . . . . . . . . . . . 17 15 Example of an entry on the ADE20K dataset. . . . . . . . . . . . . . . . . 18 16 Example of the generated semantic segmentations. . . . . . . . . . . . . . . 19 17 Example of bad quality entries on the dataset. . . . . . . . . . . . . . . . . 19 18 Example of bad quality entries that could not be automatically removed. . 20 19 Structure of the ADGAN model. . . . . . . . . . . . . . . . . . . . . . . . 21 20 Examples of pose encoding used by ADGAN. . . . . . . . . . . . . . . . . 21 21 Semantic segmentation to layout process. . . . . . . . . . . . . . . . . . . . 22 22 Inputs and output of the ADGAN method at training time. . . . . . . . . 23 23 Structure of the RoomGAN method. . . . . . . . . . . . . . . . . . . . . . 24 24 Conversion from semantic layout to bounding box. . . . . . . . . . . . . . . 26 25 Training losses for a batch size of 1. Blue lines correspond to the actual losses, while the orange lines are a smoother version. . . . . . . . . . . . . 28 26 From left to right: source image, semantic segmentation of Is, target image, semantic segmentation of Itand generated output. . . . . . . . . . . . . . . 29 27 Training losses for a batch size of 4. Blue lines correspond to the actual losses, while the orange lines are a smoother version. . . . . . . . . . . . . 30 28 Examples of generated images at training time. . . . . . . . . . . . . . . . 31 29 The model only generates black images. . . . . . . . . . . . . . . . . . . . . 31 30 Training losses for a batch size of 4. Blue lines correspond to the actual losses, while the orange lines are a smoother version. . . . . . . . . . . . . 32 31 From left to right: source image, semantic segmentation of Is, target image, semantic segmentation of Itand generated output. . . . . . . . . . . . . . . 33 32 Results on the first stage. . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 33 Results on the second stage. . . . . . . . . . . . . . . . . . . . . . . . . . . 34 34 MixNMatch results on the first experiment. . . . . . . . . . . . . . . . . . 35 35 Comparison between 256x256 and 128x128 input size. . . . . . . . . . . . . 36 4 36 Comparison between training with the ADE20K or the LSUN dataset. . . 37 37 From left to right: real image, semantic segmentation of said image and synthesized image produced by SPADE using the segmentation as input. . 38 38 Training losses for a batch size of 1. Blue lines correspond to the actual losses, while the orange lines are a smoother version. . . . . . . . . . . . . 39 39 Training losses for a batch size of 4. . . . . . . . . . . . . . . . . . . . . . . 40 40 Training losses for a batch size of 32. . . . . . . . . . . . . . . . . . . . . . 41 41 Comparison between different batch sizes. . . . . . . . . . . . . . . . . . . 42 42 Comparison between Pix2Pix and SPADE. . . . . . . . . . . . . . . . . . . 43 43 From left to right: source image, semantic segmentation of Is, target image, semantic segmentation of Itand generated output. . . . . . . . . . . . . . . 44 5 Abbreviations ADGAN Attribute-Decomposed GAN CNN Convolutional Neural Network CSAIL Computer Science and Artificial Intelligence Laboratory DNN Deep Neural Network GAN Generative Adversarial Network SPADE Spatially-Adaptive Normalization 6 Abstract Deep Learning and Computer Vision have had a rapid evolution over the past few years, and new techniques have risen to give response to multiple tasks. One of those tasks is Attribute Transferring, or the ability to transfer visual components of an image (from textures or shapes to more concrete ones such as facial features) to another. The goal of this thesis is to research the state of the art methods in this field and develop our own model to perform Attribute Transferring over bedrooms. This model, deployed as part of an app, would allow the user to take a picture of its bedroom and swap its appearance with the one of a desired bedroom, conserving the original elements and their disposition. 7 Revision history and approval record Revision Date Purpose 0 26/04/2021 Document creation 1 16/06/2021 Document revision DOCUMENT DISTRIBUTION LIST Name e-mail Jorge Pueyo Morillo [email protected] Aleix Clemens Suriol [email protected] Javier Ruiz Hidalgo [email protected] Written by: Reviewed and approved by: Date 26/04/2021 Date 16/06/2021 Name Jorge Pueyo Morillo Name Javier Ruiz Hidalgo Position Project Author Position Project Supervisor 8 1 Introduction The aim of this thesis is to examine the state of the art in Deep Learning applied to images, specially the Generative Adversarial Networks, and the techniques used to perform attribute transfer. Attribute transferring involves any task with the objective of transferring a visual attribute from one image to another. These attributes include facial features (hair, mouth, glasses) or clothes, but also more generic ones such as shape or color. Originally we planned to apply our research to perform attribute transfer over people’s clothes, with the final goal being an application capable of switching the clothes from the image of one person over to another one. However, we found out that there were already many solutions for this problem, so we decided to apply our research to perform attribute transfer over rooms, more precisely bedrooms. We begin by examining the Attribute-Decomposed GAN (ADGAN) model [12], which can perform both pose and clothes transfer over people. Using ADGAN as our foundation, we have developed a new model called RoomGAN, which performs attribute transfer over bedrooms (Figure 1). Our method can transfer the shape, pose and texture from the different components of a bedroom (bed, lamp, window, ...) to another one. (a) Desired appearance (b) Original bedroom (c) Result Figure 1: Attribute transfer over bedrooms. The motivation behind this research was to end up offering an application that would allow the user to visualize how their bedrooms would look like in a different style. The user would be able to take a picture of their own bedroom and the picture of another bedroom whose appearance would like to have, and the app would output the result with the smallest delay possible. 9 Figure 11: Example of usage proposed by MixNMatch. 2.2.5 Pix2Pix Pix2Pix [3] is a model that seeks to provide a general solution for the image-to-image translation problem using Conditional Generative Adversarial Networks. The fact that GANs not only learn the mapping between input and output, but also a loss function to train said mapping, makes it possible to apply the same generic approach to different problems (e.g. Figure 12) that would have required very specific solutions using traditional methods like CNNs. Figure 12: Examples of Image-to-Image translation. 16 2.2.6 SPADE The Spatially-Adaptive Normalization (SPADE) model [13] proposes a method to synthesize photorealistic images given an input semantic layout (Figure 13). Figure 13: Output generated by the SPADE model. The main difference with a traditional Image- to-Image translation approach is that instead of feeding the semantic layout through a Deep Neural Network consisting of normalization, convolution and nonlinear layers, the layout is used to modulate the activations of the normalization layers, which effectively propagates the semantic information throughout the network. This method produces better results, since it has been proven that the normalization layers tend to deteriorate the semantic information from the input. Furthermore, SPADE also supports styleguided generation (Figure 14). A style encoder is attached to capture the style of a target image, which will then be fed to the network instead of plain random noise, thus allowing to control the general appearance of the output image. Figure 14: Different synthesized images, generated from the same semantic layout, depending on the image provided as style. 17 3 Methodology 3.1 Datasets For the purpose of our research we needed a dataset consisting of images of indoor environments, specially those containing bedrooms. Ideally, the dataset would also contain the ground truth semantic segmentation of all its images. The only dataset that fullfilled every requirement was the ADE20K [19] (see Figure 15 for an example), from the MIT Computer Science and Artificial Intelligence Laboratory (CSAIL), which includes 150 semantic categories. The dataset contains 25,574 training images and 2,000 validation images, with dimensions 256x256. Of those, 1,130 training images and 204 validation ones correspond to bedrooms. (a) Image. (b) Semantic segmentation. Figure 15: Example of an entry on the ADE20K dataset. These numbers were enough to start experimenting with the dataset and obtain reasonable training results, but we realized we would need a lot more images if we aimed to obtain respectable test results. Since there were not any other datasets that matched our requirements, we decided to synthesize our own. To find the most number of bedroom images we used the LSUN Bedrooms dataset [17], which consists of 196,224 images. To obtain the semantic segmentation of said images, we used the CSAIL semantic segmentator [18] with the ResNet18 pretrained model, which offers a good balance between accuracy and speed, something important due to the high number of images to process. We resized all the images to the same 256x256 dimensions of the ADE20K dataset. Overall, the dataset contains high quality pictures of regular bedrooms, with which the segmentator performs great (e.g. Figure 16). However, some of the images have a poor quality, only show a small part of a room (not even a bedroom) or even have no relation to a room (e.g. Figure 17) 18 (a) Images. (b) Semantic segmentations. Figure 16: Example of the generated semantic segmentations. (a) Images. (b) Semantic segmentations. Figure 17: Example of bad quality entries on the dataset. 19 We managed to improve the consistency of the dataset by removing those images in which the segmentator found people and those for which the total of the image that corresponded to a bed was too small (less than 5% of the image). Unfortunately, there were a few outliers remaining which we couldn’t automatically remove since they didn’t check the two conditions just mentioned (e.g. Figure 18). (a) Image. (b) Semantic segmentation. Figure 18: Example of bad quality entries that could not be automatically removed. 3.2 RoomGAN RoomGAN is our very own method to perform attribute transfer over bedrooms. Our model is capable of synthesizing a bedroom with arbitrary components (bed, windows, wardrobe, ...) in a certain disposition. RoomGAN takes as input two images, a source image, from which the different elements will be taken, and a target image which will be used as the layout for the generated output. Our method is based on the ADGAN model [12], which is able to produce realistic person images with desired human attributes and in any given pose. The feature that interested us the most is not actually the component transfer part of the model, which can mix characteristics from two different people, but the pose transfer. Our main objective was to use the pose transfer ability of this network to change the layout of a room, thus generating a new bedroom with the same elements but a different layout. To do so, we performed several changes to the original ADGAN’s structure (Figure 19) so as to implement our method. 20 Figure 19: Structure of the ADGAN model. 3.2.1 Layout Figure 20: Examples of pose encoding used by ADGAN. During test time, ADGAN takes two inputs to perform the pose transfer: source image, from which we extract the textures, and target image, which gives the desired pose. These poses P∈R18xHxW (e.g. Figure 20) represent the location of 18 joints of the human body, and can be automatically extracted from an image using a pose estimation method [1]. Our first change was to find a suitable substitute for the poses, that could be extracted from a room. Originally, we planned to use RoomNet [7] or similar methods to extract a 2D layout estimation based on keypoints such as floors, walls and ceiling. However, we felt that these few keypoints could not capture the dispositions of all the elements in the room so we finally discarded the idea. Instead, we opted for encoding the semantic segmentation of the room. To do so, we use a layout L∈RNxHxW , where Nare the number of objects to encode. Ideally we would want to perform the layout transfer to every elements of the room, but since there could be an unlimited number of them we selected the most frequent ones, according to their appearance on the ADE20K dataset, that made sense to be found in bedrooms. We ended up picking 18 objects, out of the 150 available, same as the number of joints used in the original pose: •Bed •Wall •Window •Chair •Lamp •Pillow 21 •Floor •Door •Curtain •Blanket •Cabinet •Ceiling •Table •Mirror •Plant •Shelf •Painting •Carpet To create a layout L(Figure 21), we begin by splitting the semantic segmentation of an image into 18 different masks, each one corresponding to an object. The mask will be a binary image where 1’s represent the section of the original image in which the object was present. In case the image did not contain some of the objects, their masks won’t be created since their values would be all 0’s. Then, we proceed to stack the masks into the final layouts L∈R18x256x256, in which every object has a fixed channel. Figure 21: Semantic segmentation to layout process. 3.2.2 Training inputs At training time, ADGAN takes three inputs (Figure 22): a source image Is, representing the person whose pose will be altered, a target pose Pt, containing the desired pose of the generated image, and the target image It, which is the ground truth of the person shown in Isposing like Pt. 22 (a) Is(b) Pt(c) It(d) Ig Figure 22: Inputs and output of the ADGAN method at training time. It follows a GAN structure (see Figure 7) with one generator and two discriminators Dp and Dt.Dpis used to guarantee the alignment of the pose of the generated image Igwith the target pose Pt. It takes two pairs of inputs, the target pose Ptconcatenated with the generated image Igas a fake input, and the same pose Ptconcatenated with the target image Itas a real input. Dtis used to ensure the similarity of the appearance texture of the source image Iswith Ig. It also takes two input pairs, Isconcatenated with Igas fake and the same Isconcatenated with Itas real. One of the main differences between RoomGAN and ADGAN, substitution of Ptby target layout Ltaside, is the use of the target image It. ADGAN uses ground truth images of the source person in the desired target pose Pt, while RoomGAN does not have that option since the datasets we are using do not contain images of the same room in different layouts or even from different perspectives. Therefore, our Itis the image of the room from which we extract the layout. Adapting to this difference was one of the most challenging parts of our research. We started by removing Dt, because unlike in the case of ADGAN, we could not use the discriminator to ensure the similarity of the textures since our Itdid not have the same appearance as the Is. The resulting structure of RoomGAN is presented in Figure 23. 23 Figure 23: Structure of the RoomGAN method. 3.2.3 Losses The training losses of the generator also suffered multiple changes. The model uses four different losses: Adversarial (1), Reconstruction (2), Perceptual (3) and Contextual (4). Ladv =E[log (Dt(Is, It)·Dp(Pt, It))] + E[log ((1 −Dt(Is, Ig)) ·(1 −Dp(Pt, Ig)))] (1) Lrec =kIg−Itk1(2) Lper =1 WlHlCl Wl X x=1 Hl X y=1 Cl X z=1   φl(Ig)x,y,z −φl(It)x,y,z  1(3) LCX =−log CX Fl(Ig),Fl(It) (4) The adversarial loss tells the generator how real its outputs are perceived by the discriminators. The loss computes the binary cross-entropy between the outputs of the discriminators when fed with the real pairs and fake pairs. It increases if the generator can not fool the discriminator, forcing the former to improve the realism of its outputs. The reconstruction loss is the L1 distance between Igand It. Those two losses were not modified, but the perceptual and contextual losses did. The perceptual loss exploits deep features extracted from certain layers of the pretrained VGG network (used in the texture encoder, see Figure 19) for texture matching, which has been proven to be effective in image synthesis. It computes the L1 distance between the output features from layer 3 of the VGG (φ3) for inputs Igand It. Similar to what happened with the discriminator Dt, in the case of RoomGAN the Itused does not have 24 the same textures as Is, thus making the image useless in terms of texture matching. We decided to substitute Itfor Isas one of the inputs, due to the fact that even though the alignment won’t be the same, the network could still take advantage of the textures. Since we could not use Itthe way it was originally intended, we decided to add a second kind of perceptual loss that would use Igand It, but instead of using the layer 3 would use the layer 14. Shallower layers tend to extract high-level features such as colors, while deeper layers extract more complex features, like detailed shapes. Our goal was to use this second perceptual layer to better define the shapes of the objects in Ig. The contextual loss [11] is designed to measure the similarity between two non-aligned images for image generation. It computes the logarithm of the similarity metric CX of the feature maps Flextracted from layer lof the pretrained VGG. It does not require pixel-to-pixel alignment, thus allowing spatial deformations with respect to the target, getting less texture distortion and more reasonable outputs. Since the loss does not penalize pixel-to-pixel dealignement as much as a traditional L1 loss, we decided to substitute again Itfor Is, since the textures between Igand Isare the ones that should match. Finally, we realized that for the training to make sense we had to select pairs of image that included the same elements, otherwise the model would try to learn to transfer textures of objects that are not present in the target image. We developed a script that classified each image according to the elements present on its segmentation (out of the 18 used to generate the layouts). That way images can only be paired if they have the same objects present, thus optimizing the training and avoiding possible misbehaviours. 3.3 MixNMatch Our main goal with this model was to use it to perform a similar task to the RoomGAN model, which is performing attribute transfer throughout the different elements of a bedroom. By selecting the color from one of the elements of the source image, and the shape, pose and background of the same element from the target image, we wanted to check whether the MixNMatch method would perform better than the RoomGAN. MixNMatch can only act over one object at a time, so our first approach was to pick the most common element in a bedroom, the bed. As explained in the State of the Art section, the MixNMatch model is trained in an unsupervised way, but it does require bounding boxes around the objects of interest to model the background. The bedroom datasets at our disposition do not contain bounding boxes, but it quite straightforward to transform the semantic segmentations into bounding boxes. To get the bounding boxes as accurate as possible, we decided to use the ADE20K dataset, which provides ground truth masks. To convert the semantic layout into a bounding box around the bed (Figure 24), we select only the pixels corresponding to the bed label. Then, from that set of pixels, we select the maximum and minimum positions values of X and Y, and get the corners of the bounding box according to the next criteria: 25 4.4.4 Fourth experiment Finally, once the dataset was cleansed and we checked that the model no longer generated black outputs, we ran one last training phase that included all the changes described in the Methodology. The main difference with the last training, dataset apart, is the split of the perceptual loss. In Figure 30 we can see how the L1, Contextual and the new perceptual loss using Itall decrease, even though in a slower pace than in previous experiments. The Adversarial loss also decreases, which is a huge improvement from the last training phase in which the loss showed an increasing tendency. The discriminator and the percentual loss that uses Isdo not decrease, although the perceptual loss is already at very low values. (a) DpLoss (b) L1 Loss (c) Adversarial Loss (d) Perceptual Loss (Target) (e) Perceptual Loss (Source) (f) Perceptual Loss (Target) Figure 30: Training losses for a batch size of 4. Blue lines correspond to the actual losses, while the orange lines are a smoother version. The results, shown in Figure 31, are promising. The model does exceptionally well on transferring the overall appearance as well as the predominant colors, specially those of the walls. Nonetheless, it fails to properly transfer the texture of some beds, specially if they contain complex patterns, and the general look of the outputs is not very realistic. We noticed the importance of the quality of the semantic segmentation of the inputs in the quality of the result. In Figure 31(e) we can see how the lamp is present in the segmentation and the model is able to properly transfer it, even the fact that it is on. In Figure 31(f) however, the lamp is not present in the mask (black void) and therefore the model is unable to generate it in the result. 32 (a) (b) (c) (d) (e) (f) Figure 31: From left to right: source image, semantic segmentation of Is, target image, semantic segmentation of Itand generated output. 33 4.4.5 Inference Time The average total inference time of our model is 22.8 seconds. The tests were run in the GPI computing server, which has the following specs: •Ubuntu 18.04. •3 Intel CPUs. •10 GB of RAM memory. •2 NVIDIA Tesla V100 GPUs. More detailed information about the inference time can be found in the thesis of Aleix [16]. 4.5 MixNMatch The first experiment we ran with this model uses the ADE20K dataset, consisting of aroung 1,000 images, which contains ground truth semantic segmentations, thus making the bounding boxes needed for the training extremely accurate. The training phase consists of two stages. In the first stage the encoders learn to disentagle the features, while in the second stage the model focuses on extracting the shape and pose features. These stages are trained sequentially, and the user has control over the iterations that each of them perform. Since the implementation provided by the authors does not allow to retrain a stage once it has finished, our first goal was to find the maximum number of iterations for each stage that could be run withing the 24 hours limit on the GPI server. These values turned out to be 1,200 iterations for the first stage and 2,400 for the second one. Another important hyperparameter to tune are the super categories and the fine categories. Super categories tell the model the number of expected different shapes that the network should try to learn, while fine categories are the different textures to expect. We selected these values to be 100 and 400 respectively. The rest of settings are left as default: an Adam optimizer with a learning rate of .0002 and a batch size of 12. (a) Real images. (b) Generated images. Figure 32: Results on the first stage. (a) Real images. (b) Generated images. Figure 33: Results on the second stage. 34 Both stages produce images (Figure 32-33) along the training, and although the model does not provide feedback on any training loss, we can use the generated images to follow the training process. The model outputs 128x128 images. To perform the attribute transfer task, we will select the texture from an image (source) and the pose, shape and background from another image (target). The goal is to obtain a picture that preserves the pose, shape and background of the bed in the target image, while the bed’s texture has been swapped with the one of the source image. As we can see in Figure 34, the results are not promising. (a) Source images (b) Target images (c) Generated images Figure 34: MixNMatch results on the first experiment. The model does great at keeping the pose, shape and background from the target images, but it transfers the bed’s colors to the whole image rather than only to the bed. Since the main problem seemed to be that the network was not capable of identifying the object of interest, we decided to resize the whole dataset to the 128x128 format used in the output, to check whether or not that was causing this behaviour. The results were even worse. Compared to the model trained used 256x256 inputs (Figure 36), the network fails to retain the shape and pose and keeps being unable to transfer the texture to the object of interest only. 35 (a) Source image (b) Target image (c) 256x256 input (d) 128x128 input Figure 35: Comparison between 256x256 and 128x128 input size. Finally, we wanted to check whether feeding the model with a substantially bigger number of images could improve its performance. Instead of using the ADE20K dataset (around 1,000 images) we trained the model with the synthesized LSUN dataset, selecting only 50,000 images from the total available. To fit each stage in one day we had to decrease the number of iteration over ten times, 100 iterations for the first stage and 200 for the second. As a reference, we will be comparing the results to the ones generated by the model when trained with an input of 256x256 since it proved to perform better than its 128x128 counterpart. In Figure 35 we can see how the model does not perform nearly as well. Although the previous training failed to deliver a proper texture transfer in the object of interest, it does much better at transferring the shape and background. The model trained with the LSUN dataset fails to acurrately recreate the shapes of the target image, let alone transfer any kind of realistic textures. The outliers and the less accurate masks failed to outweight the benefits of the increased number of images of the LSUN dataset. 36 (a) Source image (b) Target image (c) ADE20K (d) LSUN Figure 36: Comparison between training with the ADE20K or the LSUN dataset. We believe that the reason why the model could not perform as well as showcased in the paper [9] for other kinds of objects (birds, cars and dogs) is due to the fact that beds do not stand out against the background as much, and have similar shapes as other objects around them, thus making it harder for the model to disentangle its components from the rest of the image. 4.6 SPADE The SPADE model is already pretrained in the whole ADE20K Indoor dataset. We wanted to test its performance on the subset of bedrooms from the very same ADE20K. This method takes as input a semantic segmentation, but it also accepts an optional style image, from which the model will try to extract a general appearance. This feature adds some extra control over the overall style of the generated output. However, it requires an attached encoder that is not provided in the official code, and therefore we won’t test it. The results, shown in Figure 37, are fantastic. Unlike RoomGAN the model generates every object defined in the segmentation, and does it with a high quality in terms of shapes and textures, giving the final result a much more realistic look. 37 (a) Ground truth (b) Semantic segmentation (c) Output Figure 37: From left to right: real image, semantic segmentation of said image and synthesized image produced by SPADE using the segmentation as input. 38 4.7 Pix2Pix In the case of the Pix2Pix model, another reason to use the Pytorch implementation [4] was that it allegedly outperforms the original TensorFlow implementation. Pix2Pix is the least conditioned model, in the sense that it does not allow any control over the style of the generated image. Therefore, it will be the model that is expected to perform better in terms of photo-realistic results, since it has less constrains to take into account. This model does provide feedback of the four losses it uses for training: •Adversarial Loss •L1 Loss •Discriminator loss for real images •Discriminator loss for fake images The first experiment will use the dataset and split mentioned in the methodology section. It will run using all the default options, including a batch size of 1. The model performs around 30 epochs per day, so it took a couple of days to get conclusive results. The model run for a total of 120 batches (around 1,500,000 iterations). As we can observer in Figure 38, all the training losses are quite noisy, but on average the tendency shows that the model is indeed learning, with the exception of the Adversarial loss. (a) Adversarial Loss (b) L1 Loss (c) Discriminator Loss (Real Images) (d) Discriminator Loss (Fake Images) Figure 38: Training losses for a batch size of 1. Blue lines correspond to the actual losses, while the orange lines are a smoother version. 39 The Adversarial Loss tells the generator how plausible are the generated images to belong to the target domain. In other words, how ’real’ the images seem. In this particular case, the fact that the loss is increasing could be due to the fact that some of the generated masks are not perfectly generated, or it could also be caused by some of the outliers in the dataset. Either way, one of the ways of reducing the impact of these isolated entries is to increase the batch size. As a first approach, we increased the batch size to 4. As shown in Figure 39, the results are considerable better. The L1 loss continues to show a decreasing tendency, while both Discriminator losses only show a residual worsening. As for the Adversarial Loss, even though we did not manage to make it decrease, has clearly improved. (a) Adversarial Loss (b) L1 Loss (c) Discriminator Loss (Real Images) (d) Discriminator Loss (Fake Images) Figure 39: Training losses for a batch size of 4. To further confirm this approach, we then increased the batch size to 32 and used two GPUs to perform the training. We gave the model the same training time (around 3 days), which resulted in less total iterations (around 200,000) due to the bigger batch size. As expected, increasing the batch size considerably smoothens the losses (Figure 40). It does not have much effect on the Discriminator losses, but we can clearly appreciate an improvement on the Adversarial loss, which even decreases until the 50,000 iterations mark and does not spike after. The L1 loss does not suffer much improvement apart from a huge noise reduction. 40 (a) Adversarial Loss (b) L1 Loss (c) Discriminator Loss (Real Images) (d) Discriminator Loss (Fake Images) Figure 40: Training losses for a batch size of 32. These results confirm our hypothesis that the Adversarial loss was being heavily affected by some of the outliers in the dataset. To compare how well the model performs when trained with the different batch sizes, we ran the method on 100 images from the test set. The results (Figure 41) are somewhat similar. The smaller batch sizes result in simpler images, with less complex textures and less defined shapes. However, the bigger batch sizes tend to apply too many textures resulting in a less realistic image. This is quite contradictory with our expectations on the Adversarial Loss, which saw an improvement when using bigger batch sizes. 41