SemanticStyleGAN: Learning Compositional Generative Priors for Controllable Image Synthesis and Editing

Yichun Shi, Xiao Yang, Yangyue Wan, Xiaohui Shen

Abstract

Recent studies have shown that StyleGANs provide promising prior models for downstream tasks on image synthesis and editing. However since the latent codes of StyleGANs are designed to control global styles it is hard to achieve a fine-grained control over synthesized images. We present SemanticStyleGAN where a generator is trained to model local semantic parts separately and synthesizes images in a compositional way. The structure and texture of different local parts are controlled by corresponding latent codes. Experimental results demonstrate that our model provides a strong disentanglement between different spatial areas. When combined with editing methods designed for StyleGANs it can achieve a more fine-grained control to edit synthesized or real images. The model can also be extended to other domains via transfer learning. Thus as a generic prior model with built-in disentanglement it could facilitate the development of GAN-based applications and enable more potential downstream tasks.

Introduction

State-of-the-art generative models like StyleGAN2 produce stunningly realistic images, but they are notoriously difficult to control. Their latent spaces are inherently "entangled": modifying a latent vector to change a subject’s hair color often inadvertently alters their nose shape or the background. This occurs because StyleGAN is designed to control global styles across the entire image. While researchers have identified latent directions for certain attributes, these edits often lack local precision. SemanticStyleGAN addresses this by providing a "generative prior" that is inherently compositional, allowing for independent control over the geometry and appearance of specific semantic regions.

Compositional Generator Architecture

The core innovation of SemanticStyleGAN is a compositional generator architecture that replaces the monolithic StyleGAN generator with a set of $K$ local generators ($g_k$). Each local generator is a modulated MLP focusing on a specific semantic area (e.g., eyes, mouth, or hair).

Local semantic control: The model allows for independent editing of specific regions such as the eyes by manipulating local latent codes.

These local generators take three inputs: a shared "coarse structure" code ($w^{base}$) for global pose, a local shape code ($w^s_k$), and a local texture code ($w^t_k$). To combine these outputs, the model utilizes a pseudo-depth mechanism. Each local generator outputs a feature map and a pseudo-depth map; a softmax function determines which local feature "wins" at any given pixel, effectively creating a z-buffering effect that learns spatial relationships without explicit 3D supervision.

Experimental Results and Disentanglement

The model was trained primarily on CelebAMask-HQ, utilizing its 28,000 face images and detailed segmentation masks. It was further validated on datasets like FFHQ, DeepFashion, and specialized domains like BitMoji via transfer learning.

Quantitatively, SemanticStyleGAN achieved an FID of 6.42 on CelebAMask-HQ, performing significantly better than previous semantic generators like SemanticGAN (FID 18.54) and remaining competitive with the unconstrained StyleGAN2 (FID 4.45). Qualitatively, the model demonstrates near-perfect spatial disentanglement.

Spatial disentanglement: Changing the background latent code preserves the foreground subject perfectly, demonstrating the model's ability to isolate semantic regions.

By splitting the local latent code into shape ($w^s$) and texture ($w^t$), the model can modify the geometry of a feature (e.g., making eyes larger) independently of its appearance. Furthermore, when combined with existing tools like StyleCLIP, SemanticStyleGAN achieves much higher "pixel preservation," allowing for edits like adding bangs while leaving the rest of the face untouched.

Conclusion and Future Work

SemanticStyleGAN successfully breaks the "black box" of global image synthesis by introducing a compositional inductive bias. While highly effective for domains with a manageable number of classes like faces or fashion, scaling the architecture to complex outdoor scenes with hundreds of object types remains a challenge. Future research will focus on developing unsupervised versions of the model that can discover semantic parts without the need for explicit segmentation masks during training.

Summary updated

BibTeX
@misc{shi2021semanticstylegan,
  author = {Yichun Shi and Xiao Yang and Yangyue Wan and Xiaohui Shen},
  title = {{SemanticStyleGAN: Learning Compositional Generative Priors for Controllable Image Synthesis and Editing}},
  year = {2021},
  eprint = {2112.02236},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2112.02236},
}
Figure