SEIGAN: Towards Compositional Image Generation by Simultaneously Learning to Segment, Enhance, and Inpaint

Pavel Ostyakov, Roman Suvorov, Elizaveta Logacheva, Oleg Khomenko, Sergey Nikolenko

Introduction

Generating realistic images from scratch using standard Generative Adversarial Networks (GANs) or Variational Autoencoders (VAEs) is notoriously difficult to control. These models often "hallucinate" details that lack structural consistency. An alternative approach is compositional image generation: taking an object from one image and seamlessly pasting it into another.

However, this seemingly simple "cut-and-paste" operation involves three complex sub-problems:

  1. Segmentation: Extracting a pixel-perfect mask to "cut" the object without leaving artifacts or capturing parts of the original background.
  2. Inpainting: "Healing" the void left in the original image so it appears as if the object was never there.
  3. Enhancement: Adjusting the lighting, shadows, and edges of the pasted object to ensure it blends naturally with the new background.
Visualizing the simultaneous segmentation, inpainting, and enhancement process.

Traditionally, solving these tasks requires massive datasets with expensive, hand-drawn pixel masks. SEIGAN (Segment-Enhance-Inpaint GAN) addresses all three tasks simultaneously using only weak supervision (bounding boxes), which are significantly easier to obtain than pixel-level annotations.

Methods

The core of SEIGAN is an architecture that treats image manipulation as a reversible process, inspired by CycleGAN. It consists of five neural networks working in concert:

  • $G_{seg}$ (The Segmenter): Predicts a soft mask for the object within a provided bounding box.
  • $G_{inp}$ (The Inpainter): Fills in the area "behind" the mask in the original image.
  • $G_{enh}$ (The Enhancer): Refines the "coarse" composite (object + new background) to add realistic shadows and color corrections.
  • Discriminators ($D_{bg}$ and $D_{obj}$): These act as critics, distinguishing between real images and the inpainted or enhanced results.
Overview of the SEIGAN architecture and training cycle.

The framework utilizes Cycle Consistency. The model extracts an object from Image A, pastes it into Image B, and then attempts to move it back to Image A. Successful restoration of the original images indicates that the segmentation, inpainting, and enhancement were accurate. Crucially, the masking process is differentiable, allowing the inpainting network to provide feedback to the segmentation network: if the mask is imprecise, the inpainting task becomes impossible, forcing the segmenter to improve.

Datasets and Evaluation

The authors evaluated SEIGAN on three primary datasets:

  • Flickr (Dogs): A custom dataset of dog images used for subjective quality testing.
  • COCO (Common Objects in Context): A standard benchmark used to evaluate segmentation across various object classes (e.g., people, traffic lights).
  • Cityscapes: A dataset of urban street scenes used to test performance in structured, complex environments.

Key Insights

  • Task Synergy: Segmentation and inpainting are complementary. Training them together allows the inpainting task to act as a natural regularizer for segmentation.
  • Texture Loss: Instead of forcing binary masks early on, the authors used a texture loss (based on VGG-19 Gram matrices). This encourages high-contrast masks because "blurry" masks result in unrealistic background textures that the discriminator easily identifies.
  • Weak Supervision Efficacy: The adversarial game, constrained by cycle loss, is sufficient to discover true object boundaries without pixel-level ground truth.

Results

  • Photorealism: In human trials, SEIGAN-generated images were significantly preferred over simple cut-and-paste baselines. SEIGAN won nearly 30% of pairwise comparisons against real ground-truth images, suggesting it approaches photorealism.
  • Segmentation Accuracy: Despite using only bounding boxes, SEIGAN achieved a mean Intersection over Union (mIoU) of 0.762 on COCO and 0.802 on Cityscapes. This performance is remarkably close to fully supervised models (0.83 and 0.867, respectively), which require much more expensive training data.

Limitations and Future Work

Current limitations include a focus on single objects against clear backgrounds and a lack of semantic placement (e.g., the model doesn't know a dog should be on grass rather than in the sky). Future work aims to handle multiple overlapping objects, incorporate 3D context for complex occlusions, and eventually remove the need for bounding box supervision entirely.

Summary updated

BibTeX
@misc{ostyakov2018seigan,
  author = {Pavel Ostyakov and Roman Suvorov and Elizaveta Logacheva and Oleg Khomenko and Sergey Nikolenko},
  title = {{SEIGAN: Towards Compositional Image Generation by Simultaneously Learning to Segment, Enhance, and Inpaint}},
  year = {2018},
  eprint = {1811.07630},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1811.07630},
}
Figure