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.
