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

BayesDiff: Estimating Pixel-wise Uncertainty in Diffusion via Bayesian Inference

Siqi Kou, Lei Gan, Dequan Wang, Chongxuan Li, Zhijie Deng

The Challenge of Quality Control in Diffusion Models

While diffusion models like Stable Diffusion and DALL-E produce stunning visuals, their outputs are notoriously "hit or miss." Generations often suffer from cluttered backgrounds, anatomical hallucinations (such as the infamous six-fingered hand), or a failure to align with the user's prompt.

The core challenge in addressing these flaws is the lack of a reliable metric to measure the quality of a single generated image. Standard metrics, such as the Fréchet Inception Distance (FID), evaluate large batches of images to determine if the overall distribution appears natural. They cannot assess whether a specific generated subject is coherent or a blurry mess. To solve this, researchers introduce BayesDiff, a mathematically grounded framework that quantifies Bayesian uncertainty—essentially the model’s own "confidence" in every pixel it generates.

The BayesDiff Methodology

BayesDiff treats the denoising process as a Bayesian inference problem. However, making an entire deep neural network Bayesian is computationally prohibitive. To make uncertainty estimation practical for massive diffusion models, the authors propose two main innovations:

  1. Last-Layer Laplace Approximation (LLLA): Instead of applying Bayesian methods to the entire network, the authors apply the Laplace Approximation only to the last layer of the noise-prediction network. By treating the last layer's weights as a Gaussian distribution, the model outputs not just a noise prediction, but a variance (uncertainty) for that prediction.
  2. Uncertainty Iteration Principle: Because diffusion is an iterative process, uncertainty at step $T$ affects step $T-1$. The authors derived a novel recursive formula to track how this pixel-wise variance propagates through the reverse Stochastic Differential Equation (SDE) or Ordinary Differential Equation (ODE) solvers used during sampling.
BayesDiff Architecture

To maintain efficiency, the team also developed BayesDiff-Skip, an accelerated version that calculates uncertainty on only a subset of the denoising steps.

Key Insights and Applications

By estimating pixel-wise uncertainty, BayesDiff unlocks several powerful capabilities without requiring the underlying model to be retrained:

  • Filtering Low-Quality Images: High image-wide uncertainty (the sum of all pixel-wise variances) strongly correlates with cluttered or low-fidelity images. By simply discarding the top 16% most uncertain images, the overall quality of the remaining set improves significantly.
  • Understanding Precision vs. Recall: The authors found a fascinating link between uncertainty and traditional generative metrics. Low-uncertainty images exhibit high precision (they look highly realistic), while high-uncertainty images exhibit high recall (they are more diverse and unique).
  • Semantic Uncertainty Maps: Uncertainty is not just random noise. In face generation tasks (evaluated on CelebA), uncertainty peaks around complex features like eyes, noses, and mouths. In general scenes, it highlights the contours of objects.
  • Localized Healing and Artifact Rectification: Because the uncertainty is calculated pixel-by-pixel, users can identify exactly where a model is struggling. If a generated animal has a mangled face, that specific area will show high uncertainty. By resampling only from those high-uncertainty regions during the diffusion process, the model can rectify localized artifacts.

Results and Performance

The researchers evaluated BayesDiff across standard benchmarks, including ImageNet and Stable Diffusion (v1.5).

  • Filtering Efficacy: On ImageNet 512x512, using BayesDiff to filter out uncertain images improved the FID score from 17.72 to 16.87.
  • Artifact Rectification: In text-to-image tests, BayesDiff successfully fixed misspelled text and anatomical errors, achieving an estimated 60% success rate in turning flawed samples into desirable ones through uncertainty-guided resampling.
  • Speed: The BayesDiff-Skip optimization provides a 5x speedup over the full BayesDiff implementation, consuming no more than twice the time of vanilla sampling while maintaining high accuracy.

Limitations and Future Directions

Despite its advantages, BayesDiff introduces some computational overhead. Even with the "Skip" optimization, it remains slower than standard sampling due to the additional Monte Carlo passes required to estimate covariance. Furthermore, because LLLA only evaluates the last layer, it might miss deeper structural uncertainties inherent in the earlier layers of the U-Net architecture.

While this study focuses primarily on image generation, the authors suggest the BayesDiff framework holds promise for other diffusion-based domains, such as audio synthesis, molecular design, and natural language processing.

Summary updated

BibTeX
@inproceedings{kou2024bayesdiff,
  author = {Siqi Kou and Lei Gan and Dequan Wang and Chongxuan Li and Zhijie Deng},
  title = {{BayesDiff: Estimating Pixel-wise Uncertainty in Diffusion via Bayesian Inference}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=YcM6ofShwY},
}
Figure