CLIP-Guided StyleGAN Inversion for Text-Driven Real Image Editing

Ahmet Canberk Baykal, Abdul Basit Anees, Duygu Ceylan, Erkut Erdem, Aykut Erdem, Deniz Yuret

Abstract

Recent advances in Generative Adversarial Networks (GANs) have enabled high-quality image synthesis, yet editing real-world images via natural language remains a significant challenge. This paper introduces CLIPInverter, a novel framework designed for high-fidelity, multi-attribute editing of real images. By integrating lightweight CLIPAdapter layers into a GAN inversion pipeline and employing a CLIPRemapper for latent refinement, the system achieves superior text-to-image manipulation. Experimental results across human faces, cats, and birds demonstrate that CLIPInverter significantly outperforms existing state-of-the-art methods in both accuracy and identity preservation.

Introduction

Editing real-world images using StyleGAN typically involves "inversion"—the process of finding a latent code that accurately reconstructs the original image. Once inverted, these codes can be manipulated to alter specific attributes. However, performing these manipulations using natural language descriptions is notoriously difficult.

Existing approaches generally fall into two categories: optimization-based and mapper-based. Optimization-based methods are computationally expensive, often requiring several minutes per image. Conversely, mapper-based methods are fast (feed-forward) but frequently struggle with complex, multi-attribute prompts. For instance, a request to make a subject "chubby with a goatee and a necktie" might result in the model successfully applying only one attribute or losing the subject's original identity entirely. CLIPInverter bridges this gap by providing a fast, feed-forward solution capable of handling complex descriptions while maintaining high identity fidelity.

Methodology

The CLIPInverter architecture enhances standard inversion networks (such as e4e) with two primary novel components designed to leverage the power of CLIP (Contrastive Language-Image Pre-training) embeddings.

CLIPAdapter

Rather than simply adding a residual direction to the final latent code, CLIPInverter introduces CLIPAdapter layers directly into the encoder. These layers utilize Adaptive Group Normalization (AdaGN) to modulate the encoder's intermediate feature maps using CLIP text embeddings. This integration allows the text description to guide the inversion process from the initial feature extraction stages, ensuring the resulting latent code is conditioned on the desired edits from the ground up.

CLIPRemapper

To further refine the manipulation, the authors include a CLIPRemapper module. This component takes the initial predicted latent code and applies a "nudge" in the latent space to better align the image with the CLIP embedding of the target text. A learned blending coefficient is used to ensure this refinement enhances text alignment without compromising the photorealism of the generated image.

Cyclic Training

The model is trained using a cyclic consistency strategy. During training, the model manipulates an image based on a target description and then attempts to reverse the edit using the original image's description. This cycle ensures that the transformation is reversible and that the core identity of the subject remains consistent throughout the editing process.

Experimental Setup

The framework was evaluated across three diverse domains:

  • Human Faces: Multi-Modal CelebA-HQ (30,000 images).
  • Birds: CUB Birds (11,788 images).
  • Cats: AFHQ-Cats (5,653 images).

To rigorously assess performance, the authors introduced two new metrics:

  1. Attribute Manipulation Accuracy (AMA): Utilizes a pre-trained classifier to verify the presence of requested attributes in the edited image.
  2. CLIP Manipulative Precision (CMP): Measures the alignment between the edited image and the text prompt while penalizing unnecessary or extraneous pixel changes.

Key Insights

  • Modulation vs. Mapping: A core finding of this research is that modulating feature maps during the inversion process is significantly more effective for multi-attribute editing than calculating a single residual vector for the final latent code.
  • Leveraging CLIP: By utilizing CLIP’s joint vision-language space, CLIPInverter can handle "out-of-distribution" prompts—words not explicitly seen during training—and perform image-to-image translations without additional fine-tuning.
  • Balancing Identity and Editability: The two-step process (Adapter followed by Remapper) allows the model to strike an optimal balance between maintaining the subject's identity (low distortion) and following complex text instructions (high editability).

Results

CLIPInverter demonstrates a substantial performance leap over previous methods. On the CelebA-HQ dataset, the model achieved an AMA (Multiple) score of 41.7%, nearly tripling the 15.1% achieved by the previous state-of-the-art, HairCLIP. Despite these intensive edits, the model maintained competitive identity similarity scores, ensuring the subject remains recognizable.

Furthermore, the model exhibited impressive zero-shot capabilities, successfully processing novel prompts like "curly hair" or "facial hair" even when those terms were underrepresented in the training data. In user studies, participants consistently ranked CLIPInverter as the most accurate and realistic method compared to five other leading approaches.

Limitations and Future Work

While highly effective, CLIPInverter is not without limitations. Because it relies on a pre-trained StyleGAN and an e4e encoder, it inherits their specific constraints; if the initial inversion is poor (due to extreme lighting or poses), the subsequent edits will suffer. Additionally, the model can reflect biases present in training data, such as associating specific hairstyles with a particular gender. Future research will focus on utilizing more balanced datasets and adapting the framework for emerging generative architectures beyond the StyleGAN family.

Summary updated

BibTeX
@article{baykal2023clip,
  author = {Ahmet Canberk Baykal and Abdul Basit Anees and Duygu Ceylan and Erkut Erdem and Aykut Erdem and Deniz Yuret},
  title = {{CLIP-Guided StyleGAN Inversion for Text-Driven Real Image Editing}},
  journal = {ACM Trans. Graphics},
  year = {2023},
}
Figure