Abstract
Diffusion models (DMs) have achieved remarkable success in image generation, yet their latent space remains less understood compared to Generative Adversarial Networks (GANs). We present an unsupervised method to discover interpretable, disentangled semantic directions in the latent space of DMs. By leveraging Riemannian geometry and the intermediate feature maps of the U-Net, our approach identifies globally consistent "knobs" for image editing—such as age, rotation, or breed—without requiring text prompts or human labels.
The Challenge of Diffusion Latent Spaces
While GANs offer well-structured latent spaces where linear directions correspond to semantic attributes, DMs are often treated as "black boxes" controlled primarily through text prompts or external guidance. This lack of a fundamental understanding of the DM latent space ($\mathcal{X}$) limits precise, fine-grained control.
Our research bridges this gap by discovering semantic directions in a completely unsupervised manner. We treat the latent space not as a flat Euclidean space, but as a curved manifold. This perspective allows us to find directions that are intrinsic to the model's learned representation.
Mapping the Manifold: Technical Approach
The core of our method lies in the relationship between the raw latent space $\mathcal{X}$ and the intermediate bottleneck feature maps $\mathcal{H}$ of the U-Net. While $\mathcal{X}$ is complex, $\mathcal{H}$ is known to be more linearly structured.
- Pullback Metric and Jacobian SVD: We compute the Jacobian of the mapping from $\mathcal{X}$ to $\mathcal{H}$. By performing Singular Value Decomposition (SVD) on this Jacobian, we identify the directions of greatest semantic change. This "pullback" effectively translates the simple geometry of the features back into the latent space.
- Geodesic Shooting: Because the latent space is curved, linear editing (adding a vector) can lead to distortions. We use "geodesic shooting" to move along the curved surface of the manifold, ensuring edits remain stable and high-quality.
- Normalization: We introduce a specific normalization technique to prevent noise amplification during the denoising process, avoiding the "over-saturated" look common in naive DM edits.
Key Insights and Results
Our experiments across datasets like CelebA-HQ, AFHQ-dog, and Stable Diffusion yielded several critical insights:
- Coarse-to-Fine Timesteps: The timing of an edit is crucial. Edits at early timesteps (high noise) affect coarse attributes like hair color or animal breed. Edits at later timesteps (low noise) refine high-frequency details like wrinkles or makeup.
- Global Consistency: Directions found mathematically are consistent across different samples. A "rotation" direction found for one face will likely rotate another, suggesting a unified internal 3D representation.
- Disentangled Editing: The method successfully identifies independent attributes—for instance, changing a dog's "furriness" without altering its pose—without any attribute labels.
- Stable Diffusion Versatility: In complex text-to-image settings, we discovered "camera lens" knobs, such as a universal "zoom-out" direction that works across diverse prompts.
Limitations and Future Work
While powerful, the method is subject to training data biases. For example, a "long hair" direction might unintentionally change gender if the training set lacks diversity in that attribute. Future research will explore how text prompts and cross-attention mechanisms further warp the latent manifold, potentially enabling even more surgical editing capabilities.
Summary updated