TL;DR
GANformer2 is an iterative, object-oriented transformer that generates complex images by first "planning" a schematic layout and then "executing" the final render. By moving away from monolithic "black-box" architectures, it achieves state-of-the-art results in image quality while providing unprecedented local controllability and interpretability.
The Challenge of Compositionality in GANs
Most modern Generative Adversarial Networks (GANs), such as StyleGAN, operate as "black boxes." They take a single, flat latent vector and transform it into a complete image in one go. While this works beautifully for centered, single-subject images like human faces, it struggles with compositionality—the way real-world scenes are built from multiple, interacting objects.
In standard GANs, it is difficult to change one specific object (like moving a chair) without unintentionally altering the rest of the image. Furthermore, these models lack transparency; there is no clear intermediate step that explains why the model placed an object in a certain location. GANformer2 aims to bridge this gap by mimicking the human artistic process: starting with a rough sketch and gradually refining the details.
Methods: A Two-Stage Generative Process
To achieve this, the authors introduce a two-stage generative architecture that separates layout planning from pixel execution.
- The Planning Phase: Instead of generating pixels immediately, the model recurrently builds a schematic layout. It samples a variable number of latent variables (representing objects) and iteratively determines their shape, position, semantic category, and—crucially—their unsupervised depth-ordering. This allows the model to understand which objects occlude others without needing explicit 3D labels.
- The Execution Phase: The model takes the planned layout and translates it into a high-resolution image. It uses a bipartite transformer where latent variables "cooperate" to guide the style and texture of their respective segments.
Novel Loss Functions
To ensure the model stays true to its plan without sacrificing creativity, the authors propose two new losses:
- Semantic Matching: A discriminator-side U-Net predicts a segmentation map from the generated image and compares it to the original plan.
- Segment Fidelity: The discriminator evaluates the realism of individual object segments rather than just the whole image, ensuring that even small, peripheral objects are high-quality.
Key Insights and Ideas
- Iterative Refinement is Key: By generating the scene segment-by-segment, the model captures long-range dependencies and object interactions more effectively than single-pass models.
- Unsupervised Depth Discovery: One of the most striking findings is that the model learns relative depth (which object is in front) entirely on its own. It discovers this because it's the most efficient way to "stitch" overlapping segments into a realistic layout.
- Amodal Completion: Because the model processes objects sequentially, it often "imagines" the hidden parts of occluded objects. If you remove a foreground object, the model can often realistically reveal what was "behind" it.
- Diversity via One-to-Many Mapping: Unlike previous layout-to-image models (like SPADE) that use restrictive reconstruction losses, GANformer2’s structural losses allow for high visual diversity.
As seen above, a single layout can produce many different versions of a scene, varying in colors, textures, and lighting, while strictly adhering to the spatial plan.
Key Results
The model was evaluated across a diverse range of benchmarks, from simple geometric reasoning (CLEVR) to complex real-world synthesis (COCO, LSUN Bedrooms, Cityscapes, and FFHQ). GANformer2 outperforms several strong baselines, including StyleGAN2 and the original GANformer:
- Visual Quality: On the CLEVR dataset, it achieved an FID of 4.70, a massive improvement over StyleGAN2’s 16.05.
- Diversity: It shows significantly higher LPIPS scores (a measure of image diversity) compared to conditional models like Pix2PixHD or SPADE, which tend to produce very similar images for a given layout.
- Controllability: Qualitative results demonstrate that users can move, resize, or change the material of a single object in a generated scene while the rest of the image remains perfectly consistent.
Limitations and Future Work
While powerful, the iterative nature of the planning phase and the use of transformers make GANformer2 more computationally expensive than simpler, convolutional GANs. Additionally, while the model can work in an unpaired setting, it performs best when trained with panoptic segmentation data, which may not be available for all domains.
Future directions suggested by the authors include extending this compositional approach to video generation, where maintaining object consistency over time is a major challenge, and integrating more explicit 3D priors to further enhance the planning stage.
Summary updated