Table of Contents
Fetching ...

GOOD: Training-Free Guided Diffusion Sampling for Out-of-Distribution Detection

Xin Gao, Jiyao Liu, Guanghao Li, Yueming Lyu, Jianxiong Gao, Weichen Yu, Ningsheng Xu, Liang Wang, Caifeng Shan, Ziwei Liu, Chenyang Si

TL;DR

GOOD addresses robust OOD detection by generating informative OOD samples without retraining diffusion models. It guides diffusion sampling with dual signals from an in-distribution classifier: image-level energy guidance and feature-space sparsity guidance, integrated through Training-Free Guidance. A unified adaptive OOD score combines pixel-level likelihood and feature-distance to improve detection across diverse OOD scenarios. Empirical results on ImageNet-100 and CIFAR-100 demonstrate that GOOD-enhanced Outlier Exposure substantially improves FPR95 and AUROC compared to prior synthesis-based and post-hoc methods, with strong ablations confirming the utility of both guidance channels and the adaptive score. The approach is scalable and avoids embedding perturbations, enabling efficient generation of boundary-adjacent outliers for robust real-world deployment.

Abstract

Recent advancements have explored text-to-image diffusion models for synthesizing out-of-distribution (OOD) samples, substantially enhancing the performance of OOD detection. However, existing approaches typically rely on perturbing text-conditioned embeddings, resulting in semantic instability and insufficient shift diversity, which limit generalization to realistic OOD. To address these challenges, we propose GOOD, a novel and flexible framework that directly guides diffusion sampling trajectories towards OOD regions using off-the-shelf in-distribution (ID) classifiers. GOOD incorporates dual-level guidance: (1) Image-level guidance based on the gradient of log partition to reduce input likelihood, drives samples toward low-density regions in pixel space. (2) Feature-level guidance, derived from k-NN distance in the classifier's latent space, promotes sampling in feature-sparse regions. Hence, this dual-guidance design enables more controllable and diverse OOD sample generation. Additionally, we introduce a unified OOD score that adaptively combines image and feature discrepancies, enhancing detection robustness. We perform thorough quantitative and qualitative analyses to evaluate the effectiveness of GOOD, demonstrating that training with samples generated by GOOD can notably enhance OOD detection performance.

GOOD: Training-Free Guided Diffusion Sampling for Out-of-Distribution Detection

TL;DR

GOOD addresses robust OOD detection by generating informative OOD samples without retraining diffusion models. It guides diffusion sampling with dual signals from an in-distribution classifier: image-level energy guidance and feature-space sparsity guidance, integrated through Training-Free Guidance. A unified adaptive OOD score combines pixel-level likelihood and feature-distance to improve detection across diverse OOD scenarios. Empirical results on ImageNet-100 and CIFAR-100 demonstrate that GOOD-enhanced Outlier Exposure substantially improves FPR95 and AUROC compared to prior synthesis-based and post-hoc methods, with strong ablations confirming the utility of both guidance channels and the adaptive score. The approach is scalable and avoids embedding perturbations, enabling efficient generation of boundary-adjacent outliers for robust real-world deployment.

Abstract

Recent advancements have explored text-to-image diffusion models for synthesizing out-of-distribution (OOD) samples, substantially enhancing the performance of OOD detection. However, existing approaches typically rely on perturbing text-conditioned embeddings, resulting in semantic instability and insufficient shift diversity, which limit generalization to realistic OOD. To address these challenges, we propose GOOD, a novel and flexible framework that directly guides diffusion sampling trajectories towards OOD regions using off-the-shelf in-distribution (ID) classifiers. GOOD incorporates dual-level guidance: (1) Image-level guidance based on the gradient of log partition to reduce input likelihood, drives samples toward low-density regions in pixel space. (2) Feature-level guidance, derived from k-NN distance in the classifier's latent space, promotes sampling in feature-sparse regions. Hence, this dual-guidance design enables more controllable and diverse OOD sample generation. Additionally, we introduce a unified OOD score that adaptively combines image and feature discrepancies, enhancing detection robustness. We perform thorough quantitative and qualitative analyses to evaluate the effectiveness of GOOD, demonstrating that training with samples generated by GOOD can notably enhance OOD detection performance.
Paper Structure (38 sections, 16 equations, 16 figures, 4 tables, 1 algorithm)

This paper contains 38 sections, 16 equations, 16 figures, 4 tables, 1 algorithm.

Figures (16)

  • Figure 1: Limitations of text-conditioned OOD generation (e.g., Dream-OOD du2023dream). Left: Misalignment — Latent perturbations produce samples that either deviate from target semantics or resemble ID images. Right: Limited Diversity — Perturbing only semantic embeddings yields low coverage of broader distributional shifts, such as covariate or domain shift.
  • Figure 2: Overview of the GOOD framework. (a) Guided by feature- and image-level signals, GOOD samples synthetic outliers near the decision boundary. (b) These outliers are used in Outlier Exposure training to separate ID and OOD samples via a regularization loss. (c) At test time, OOD is detected using a unified score that combines feature distance and image likelihood.
  • Figure 3: Visualization of generated OOD samples with increasing step sizes, arranged from top to bottom ($\rho=\mu=0.1 \rightarrow 2 \rightarrow 5$). The samples exhibit varying degrees of anomaly.
  • Figure 4: Energy score analysis (inversely related to image likelihood) on ImageNet-100 ID sets and synthesized OOD samples. (a) OOD energy distributions across different $\rho$ values. (b) Distributions under varying $\mu$. (c) Balanced sampling over all $\rho$–$\mu$ combinations ($5 \times 5 = 25$).
  • Figure 5: Generated OOD samples using two guidance types, with Grad-CAM heatmaps highlighting regions of high gradient response. The class 'hen' is from ImageNet-100.
  • ...and 11 more figures