[Paper Review] ContraCLIP: Interpretable GAN generation driven by pairs of contrasting sentences
ContraCLIP proposes a model-agnostic method for learning non-linear, interpretable latent paths in pre-trained GANs using pairs of contrasting natural language sentences, called semantic dipoles. By projecting these sentence pairs into CLIP's vision-language space and using RBF-based warping to define directional paths, the method enables smooth, high-quality image manipulations that preserve identity and align with semantic attributes, outperforming prior approaches in both qualitative and quantitative benchmarks across diverse GAN architectures and datasets.
This work addresses the problem of discovering non-linear interpretable paths in the latent space of pre-trained GANs in a model-agnostic manner. In the proposed method, the discovery is driven by a set of pairs of natural language sentences with contrasting semantics, named semantic dipoles, that serve as the limits of the interpretation that we require by the trainable latent paths to encode. By using the pre-trained CLIP encoder, the sentences are projected into the vision-language space, where they serve as dipoles, and where RBF-based warping functions define a set of non-linear directional paths, one for each semantic dipole, allowing in this way traversals from one semantic pole to the other. By defining an objective that discovers paths in the latent space of GANs that generate changes along the desired paths in the vision-language embedding space, we provide an intuitive way of controlling the underlying generative factors and address some of the limitations of the state-of-the-art works, namely, that a) they are typically tailored to specific GAN architectures (i.e., StyleGAN), b) they disregard the relative position of the manipulated and the original image in the image embedding and the relative position of the image and the text embeddings, and c) they lead to abrupt image manipulations and quickly arrive at regions of low density and, thus, low image quality, providing limited control of the generative factors. We provide extensive qualitative and quantitative results that demonstrate our claims with two pre-trained GANs, and make the code and the pre-trained models publicly available at: https://github.com/chi0tzp/ContraCLIP
Motivation & Objective
- To discover non-linear, interpretable paths in the latent space of pre-trained GANs in a model-agnostic manner.
- To address limitations of existing methods, including architecture-specific design, disregard for relative positions in embedding spaces, and abrupt, low-quality image manipulations.
- To enable intuitive, semantic control over generative factors using natural language without requiring pre-trained detectors or annotated data.
- To ensure high image quality and identity preservation during attribute editing by leveraging relative positioning in CLIP's embedding space.
- To demonstrate generalization across diverse GAN architectures and image domains, including non-facial datasets.
Proposed method
- Semantic dipoles are defined as pairs of natural language sentences with contrasting semantics, such as 'a young person' vs. 'an old person', which serve as the semantic limits for latent paths.
- The sentences are encoded into CLIP's vision-language space, where their embeddings form 'dipoles' that define the direction and boundaries of the desired latent path.
- RBF-based warping functions are applied to the CLIP text space to generate non-linear, smooth directional paths between the poles of each semantic dipole.
- A contrastive loss is optimized to align the GAN's latent space traversal with the non-linear path in the CLIP embedding space, ensuring that image generation follows the desired semantic trajectory.
- The method is trained end-to-end using a loss that encourages the generated images to match the target text embeddings while preserving the relative position between original and manipulated images in the CLIP space.
- The approach is applied to various pre-trained GANs, including StyleGAN2 and ProGAN, and tested on facial and non-facial datasets (e.g., AFHQ Cats, Dogs, LSUN Cars), demonstrating generalization beyond face editing.
Experimental results
Research questions
- RQ1Can non-linear, interpretable latent paths be discovered in the latent space of pre-trained GANs using only pairs of contrasting natural language sentences?
- RQ2Does the proposed method preserve identity and generate high-quality images during attribute editing, even when the GAN architecture is not specifically designed for such control?
- RQ3How does the method compare to existing approaches like StyleCLIP in terms of image quality, identity preservation, and semantic consistency?
- RQ4Is the method robust to hyperparameters such as the temperature in the contrastive loss and the weighting of the path regularization?
- RQ5Can the method generalize across diverse GAN architectures and image domains beyond facial images?
Key findings
- ContraCLIP achieves significantly higher identity preservation (mean ID score of 0.9245) compared to StyleCLIP* (mean 0.5624) across all semantic dipoles, indicating superior preservation of original identity during editing.
- For the semantic dipole 'a picture of a man with a beard' vs. 'a picture of a shaved man', ContraCLIP achieves an identity preservation score of 0.9407, demonstrating effective control over facial hair attributes.
- The method produces high-quality, semantically consistent image manipulations on non-facial datasets, such as AFHQ Cats, Dogs, and LSUN Cars, confirming its generalization beyond face-centric GANs.
- Ablation studies show that the method is robust to hyperparameters such as the temperature τ in the contrastive loss, with stable performance across τ ∈ {0.01, 0.1, 0.5, 1.0, 5.0}.
- The non-linear paths learned by ContraCLIP result in smoother, more gradual image transitions compared to linear methods, avoiding abrupt changes and low-density regions in latent space.
- Quantitative results on 100 randomly selected latent codes confirm that ContraCLIP consistently outperforms the baseline StyleCLIP* across all 10 semantic dipoles, with the highest improvement observed on 'pale skin' to 'tanned skin' (ID: 0.9344 vs. 0.5642).
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.