Compositional GAN: Learning Conditional Image Composition

Samaneh Azadi, Deepak Pathak, Sayna Ebrahimi, Trevor DarrellarXiv 2018

Abstract

Generative Adversarial Networks (GANs) can produce images of remarkable complexity and realism but are generally structured to sample from a single latent source, ignoring the explicit spatial interaction between multiple entities. Capturing such complex interactions—including relative scaling, spatial layout, occlusion, or viewpoint transformation—is a challenging problem. We propose a novel self-consistent Composition-by-Decomposition (CoDe) network to compose a pair of objects. Given object images from two distinct distributions, our model generates a realistic composite image from their joint distribution following the texture and shape of the input objects. Our results indicate that the learned model captures potential interactions between the two object domains and generates realistic composed scenes at test time.

Introduction

While GANs excel at image-to-image translation, they often struggle with the spatial and geometric nuances of composition. A natural scene is more than just a style; it is a 2D projection of multiple 3D objects interacting. Standard GANs typically fail to handle relative scaling, occlusion, or perspective matching when placing one object near another.

To address this, we introduce Compositional GAN, a framework designed to learn the joint distribution of object pairs. By enforcing a "self-consistency" rule—where a composite image must be decomposable back into its original components—the model masters complex spatial interactions without requiring perfectly paired training data.

Overview of the Compositional GAN framework, showing the composition of various object pairs including furniture, accessories, and vehicles.

Methodology

The core of our approach is the Composition-by-Decomposition (CoDe) network. The pipeline integrates several specialized modules to ensure realistic merging:

  1. Spatial and Viewpoint Alignment: A Relative Spatial Transformer Network (STN) handles scaling and shifting, while a Relative Appearance Flow Network (RAFN) synthesizes matching perspectives for object pairs like chairs and tables.
  2. Self-Consistent Composition: A generator ($G_c$) creates the composite, which a decomposition generator ($G_{dec}$) then attempts to reverse. The difference between the original inputs and the decomposed outputs forms a self-consistency loss, preventing the model from distorting object identities.
  3. Example-Specific Meta-Refinement (ESMR): At test time, the model briefly fine-tunes its weights on a specific input pair using the decomposition signal. This "self-check" significantly sharpens results and removes artifacts.
  4. Inpainting for Unpaired Data: To train on real-world images lacking "before" shots, we use self-supervised inpainting to create synthetic training pairs from single composite images.

Experimental Results

We evaluated Compositional GAN on synthetic (ShapeNet) and real-world (CelebA, Cityscapes) datasets. Our model was compared against baselines such as Pix2Pix, CycleGAN, and ST-GAN.

Qualitative comparison of Face-Sunglasses and Street Scene-Car composition results against the ST-GAN baseline.

User evaluations via Amazon Mechanical Turk (AMT) demonstrated a strong preference for our method. In the "Face-Sunglasses" task, users preferred Compositional GAN over ST-GAN 84% of the time for paired data and 73% for unpaired data. Furthermore, the Meta-Refinement step proved crucial; for the "Chair-Table" task, users preferred refined images 71.3% of the time. Qualitatively, the model excels at handling difficult occlusions, such as basket handles appearing correctly in front of bottles, where other models produce blurring.

Conclusion

Compositional GAN provides a robust framework for binary image composition. While currently limited to two objects and focused primarily on geometry and texture rather than complex lighting/shadows, it represents a significant step toward generative models that understand the 3D interactions of the physical world. Future work will explore scaling to multi-object scenes and modeling non-rigid deformations.

Summary updated

BibTeX
@misc{azadi2018compositional,
  author = {Samaneh Azadi and Deepak Pathak and Sayna Ebrahimi and Trevor Darrell},
  title = {{Compositional GAN: Learning Conditional Image Composition}},
  year = {2018},
  eprint = {1807.07560},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1807.07560},
}
Figure