Universal Guidance for Diffusion Models

Arpit Bansal, Hong-Min Chu, Avi Schwarzschild, Roni Sengupta, Micah Goldblum, Jonas Geiping, Tom Goldstein

Diffusion models like Stable Diffusion are incredibly powerful, but they are often restricted to the specific conditioning they were trained on—usually just text. If a user wants to guide a model using a segmentation map, a specific person's face, or precise object locations, they typically have to train a new model from scratch or use heavy-duty adapters like ControlNet.

The core challenge is the domain shift: diffusion models operate on noisy images, but standard "off-the-shelf" computer vision models (like face recognizers or style extractors) are trained on clean, natural images. If you try to pass a noisy image through a standard face recognizer to get a gradient for guidance, the output is essentially unusable because the model doesn't "understand" noise.

In Universal Guidance for Diffusion Models, researchers propose an algorithm that enables pre-trained diffusion models to be controlled by any off-the-shelf guidance model without requiring retraining or fine-tuning. By performing guidance on denoised estimates of the final image rather than the noisy latent states, the authors bridge the domain gap that previously prevented standard models from controlling the diffusion process.

Examples of Universal Guidance across various modalities including segmentation, identity, object location, and style.

How Universal Guidance Works

The authors propose a three-pronged algorithm to enable this flexible control:

  1. Forward Universal Guidance: Instead of calculating the guidance gradient on the noisy state ($z_t$), the algorithm first predicts a "clean" version of the image ($\hat{z}_0$) using the current denoising estimate. It then runs the guidance function (e.g., a segmentation network) on this predicted clean image. This allows the use of any standard differentiable model as a guide.
  2. Backward Universal Guidance: To more strictly enforce constraints like exact object placement, the authors introduce an optimization step. They solve for a small change ($\Delta z_0$) in the clean image space that minimizes the guidance loss, and then mathematically map that change back into the noisy latent space. This is more computationally efficient and effective than standard forward gradients for complex spatial constraints.
  3. Universal Stepwise Refinement (USR): Aggressive guidance can sometimes push an image away from the "manifold" of natural-looking images, resulting in artifacts. USR addresses this by re-adding a small amount of noise and repeating the denoising step multiple times at the same noise level. This acts as a projection mechanism that keeps the image looking realistic while adhering to the guidance.

Key Insights

  • The $\hat{z}_0$ Proxy is Sufficient: The most significant insight is that even a blurry, imperfect estimate of the clean image ($\hat{z}_0$) contains enough structural information for off-the-shelf models to provide a useful gradient.
  • Guidance over Conditioning: The paper argues that guidance is fundamentally superior to conditioning because of its modularity. Users can swap guidance models in and out like Lego bricks without ever touching the weights of the massive foundational diffusion model.
  • Closing the Gap via Sampling: Instead of spending thousands of GPU hours retraining a CLIP model or a classifier to handle noise, the domain gap can be closed simply by changing how we sample, making the noise irrelevant to the guidance model.

Experimental Results

The researchers evaluated their method using foundation models like Stable Diffusion (for text-to-image tasks) and OpenAI’s ImageNet Diffusion (to demonstrate structure generation in unconditional models). They utilized several off-the-shelf networks for guidance, including MobileNetV3 for segmentation, FaceNet for identity, Faster-RCNN for object detection, and CLIP for style.

The algorithm demonstrated successful control across a wide array of modalities:

  • Segmentation: Achieved a high mIoU of 0.898, showing near-perfect adherence to layout maps.
  • Face Recognition: Successfully generated images of specific identities with a face similarity score of 0.642 (where >0.5 is typically considered a match).
  • Object Detection: On ImageNet models, adding Backward Guidance improved the Mean Average Precision (mAP) from 0.39 to 0.90 for specific bounding box constraints, proving the optimization step is crucial for strict spatial control.
  • Style Transfer: Using CLIP as a guidance function allowed for the application of artistic styles to unconditional models, even for objects the model wasn't specifically trained to generate in that style.

Limitations and Future Work

While highly flexible, Universal Guidance comes with trade-offs:

  • Computational Overhead: The method is slower than standard sampling. Stepwise Refinement requires multiple iterations per timestep, and Backward Guidance involves an internal optimization loop.
  • Hyperparameter Sensitivity: The guidance strength ($s_0$) and the number of refinement steps ($k$) currently need manual tuning for different guidance models to balance image quality against constraint satisfaction.
  • Memory Constraints: If the chosen guidance model is extremely large (e.g., a massive Vision Transformer), the memory requirements for backpropagating through it during every sampling step could become a bottleneck on consumer hardware.

Summary updated

BibTeX
@inproceedings{bansal2024universal,
  author = {Arpit Bansal and Hong-Min Chu and Avi Schwarzschild and Roni Sengupta and Micah Goldblum and Jonas Geiping and Tom Goldstein},
  title = {{Universal Guidance for Diffusion Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=pzpWBbnwiJ},
}
Figure