EditGAN: High-Precision Semantic Image Editing

Huan Ling, Karsten Kreis, Daiqing Li, Seung Wook Kim, Antonio Torralba, Sanja Fidler

Introduction

While Generative Adversarial Networks (GANs) have revolutionized image synthesis, achieving precise semantic control over generated or real images remains a significant challenge. Existing editing methods typically fall short in one of three ways: they only offer high-level attribute control (e.g., changing "age" without preserving specific facial structures), they require massive datasets of pixel-wise segmentation masks (often tens of thousands of examples) to learn editing boundaries, or they rely on optimization-based approaches that are too slow for interactive use.

EditGAN is a novel framework designed to bridge this gap. It provides high-precision, pixel-level semantic image editing by allowing users to modify images simply by redrawing detailed part segmentation masks—such as reshaping a car's headlight or resizing a cat's ears. By leveraging a GAN that jointly models images and their segmentations, EditGAN achieves state-of-the-art results using only a handful of labeled examples and supports real-time editing via learned "editing vectors."

Methodology: Unlocking the Latent Space

EditGAN builds upon the architecture of StyleGAN2 and the data-efficient insights of DatasetGAN. The core premise is that a GAN’s latent space already contains rich, geometrically structured semantic information; the challenge is navigating it precisely.

  • Joint Modeling: The framework adds a segmentation branch to a pre-trained StyleGAN2 model. This branch learns to produce a segmentation mask from the same latent code ($w$) used to generate the RGB image. Because the image and mask share this code, any geometric change in the mask necessitates a corresponding, semantically aware change in the image's pixels.
  • Latent Code Optimization: To perform an edit, a user modifies a segmentation mask. The system then optimizes the latent code to find a new version ($w_{edited}$) that matches the new mask within the edited region, while strictly preserving the original image's appearance elsewhere.
  • Amortized Editing Vectors: To avoid slow optimization for every single edit, EditGAN "amortizes" the process. By performing optimization on a few examples offline, the system identifies "editing vectors" in the latent space that represent specific transformations (e.g., "make eyes larger"). Once learned, these vectors can be applied to new images almost instantaneously.
  • Self-Supervised Refinement: For highly complex edits where a vector might not transfer perfectly, EditGAN includes a brief (30-60 step) refinement process to clean up artifacts and ensure high-fidelity results.

Experimental Results

The authors evaluated EditGAN across four diverse categories: faces (FFHQ), cars, cats, and birds.

Sequential high-precision edits applied to a car and a face using EditGAN.

A standout feature of EditGAN is its extreme label efficiency. While competing methods like MaskGAN require up to 30,000 segmentation masks, EditGAN achieves superior results using as few as 16 to 30 labeled image-mask pairs. This is possible because the pre-trained GAN already understands the visual structure of the objects; it only needs minimal supervision to map pixels to semantic parts.

Key performance highlights include:

  • Quantitative Superiority: On standard editing benchmarks (like the "smile" edit), EditGAN outperformed MaskGAN in semantic correctness (91.5% vs. 77.3%) and identity preservation, despite using nearly 2,000 times fewer labels.
  • Extreme Precision: EditGAN enables edits previously considered impossible for GANs, such as rotating individual wheel spokes, changing pupil size, or removing a side mirror while seamlessly inpainting the underlying texture of the car.
  • Speed and Generalization: Applying a pre-learned editing vector takes only 0.4 seconds, making it highly suitable for interactive creative tools. Furthermore, these vectors generalize remarkably well to out-of-domain images, such as applying face-editing vectors to classical portraits from the MetFaces dataset.

Limitations and Future Directions

While highly capable, EditGAN is inherently limited by the capacity of the underlying GAN. It performs exceptionally well on object-centric datasets (like faces and cars) but would likely struggle with highly diverse, unaligned scenes, such as vivid city streets. Additionally, while many edits are clean, some vectors still suffer from minor disentanglement issues (e.g., changing an eye shape might slightly shift an eyebrow), which is why the optional refinement step remains valuable.

Future work may focus on accelerating the initial embedding of real images into the latent space and developing GAN architectures with even more disentangled latent spaces, potentially eliminating the need for post-edit refinement entirely.

Summary updated

BibTeX
@inproceedings{ling2021editgan,
  author = {Huan Ling and Karsten Kreis and Daiqing Li and Seung Wook Kim and Antonio Torralba and Sanja Fidler},
  title = {{EditGAN: High-Precision Semantic Image Editing}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=jLHWRxwc7_f},
}
Figure