NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Exploring Compositional Visual Generation with Latent Classifier Guidance

Changhao Shi, Haomiao Ni, Kai Li, Shaobo Han, Mingfu Liang, Martin Renqiang Min · DOI

Introduction

Compositional image generation—the ability to synthesize images that satisfy multiple, often independent, semantic constraints—remains a cornerstone of controllable generative modeling. This paper introduces Latent Classifier Guidance (LCG), a framework designed to perform precise compositional generation and editing by operating within the latent spaces of pre-trained generative models like StyleGAN2. By integrating diffusion models directly into these latent manifolds, LCG achieves high-fidelity control over multiple attributes while preserving image quality and identity more effectively than traditional image-space or linear arithmetic methods.

The Challenge of Compositional Generation

Generating a "smiling woman with glasses and blonde hair" requires a model to navigate complex attribute interactions without introducing artifacts or losing the underlying identity of the subject. Existing research typically follows two paths:

  1. Image-Space Methods: These apply diffusion or energy-based models directly to pixels. While expressive, they are computationally intensive and often fail to leverage the disentangled semantic properties inherent in latent spaces.
  2. Latent-Space Methods: These often rely on linear "vector arithmetic" (e.g., adding a "smile" direction). While efficient, these methods can push latent codes into low-density regions of the distribution, leading to blurry or distorted outputs.

LCG bridges this gap by applying the probabilistic rigor of diffusion models to the efficient, semantic structure of latent spaces.

Latent Classifier Guidance (LCG)

The core of the LCG framework is a Latent Diffusion Model (LDM) trained to model the distribution of latent codes (such as the $W$ space in StyleGAN2). This LDM acts as a "safety rail," ensuring that any generated or edited code remains within the high-density regions of the latent space.

High-quality generation of male faces with the "glasses" attribute guided by LCG.

The process utilizes auxiliary latent classifiers to provide gradients that "nudge" the denoising process toward desired attributes. For compositional tasks, gradients from multiple classifiers are combined using logical operations (e.g., summing for "AND"). To preserve identity during editing, a source image regularization term anchors the diffusion process to the original latent code.

Key Insights

  • Latent Space Robustness: Latent classifiers are often more reliable than image-space counterparts because the latent space is already partially disentangled, reducing the likelihood of the model relying on spurious "shortcuts."
  • Diffusion as a Prior: The LDM prevents "over-editing" artifacts common in linear methods. By keeping the latent code within the learned distribution, it maintains realism even under extreme attribute modifications.
  • Linearity vs. Non-linearity: Interestingly, the authors found that a linear version of LCG (LCG-Linear) is highly competitive. If a latent space is sufficiently well-disentangled, principled vector arithmetic can be remarkably effective.

Results and Performance

LCG demonstrates superior performance in both attribute accuracy and identity preservation. In compositional tasks involving gender, expression, and age, LCG-Linear achieved a gender accuracy of 98.0%, significantly outperforming StyleFlow's 71.8%.

Examples of smiling female faces generated using LCG, demonstrating consistent attribute application and high image quality.

Furthermore, in sequential editing scenarios, LCG-Diffusion maintained the highest image realism, achieving an FID of 24.06 compared to 27.49 for LACE-ODE. This highlights the value of the diffusion prior in maintaining coherence across multiple stacked edits.

Conclusion

Latent Classifier Guidance offers a robust and efficient approach to compositional visual generation. By combining the strengths of latent space representations with the probabilistic modeling of diffusion, the framework enables fine-grained control over image attributes without sacrificing realism or identity. Future work may extend this paradigm to more complex hierarchical attribute relationships and diverse datasets beyond human faces.

Summary updated

BibTeX
@misc{shi2023exploring,
  author = {Changhao Shi and Haomiao Ni and Kai Li and Shaobo Han and Mingfu Liang and Martin Renqiang Min},
  title = {{Exploring Compositional Visual Generation with Latent Classifier Guidance}},
  year = {2023},
  eprint = {2304.12536},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2304.12536},
}
Figure