Abstract
Out-of-Distribution (OoD) detection aims to justify whether a given sample is from the training distribution of the classifier-under-protection (In-Distribution, InD) or from OoD. Diffusion Models (DMs) are recently utilized in OoD detection by using the perceptual distances between the given image and its DM generation. In this work, we point out two main limitations in DM-based OoD detection methods: (i) perceptual metrics focus only on human-perceived levels, ignoring abstract patterns; (ii) they ignore internal representations from the classifier-under-protection. To this end, our proposed $D^3$ (Diffusion Distribution Disparity) framework looks into deep representations with novel metrics and an anomaly-removal strategy. Our work demonstrates state-of-the-art detection performance among DM-based methods.
Introduction
Deep Neural Networks (DNNs) often exhibit overconfidence when presented with Out-of-Distribution (OoD) data, posing significant safety risks in real-world deployments. Recent approaches leverage Diffusion Models (DMs) trained on In-Distribution (InD) data to "purify" inputs. The core intuition is that a DM will reconstruct an OoD image to look more like an InD sample. However, existing methods rely on human-centric perceptual metrics like LPIPS, which fail to capture the high-level semantic features that the classifier actually utilizes to distinguish between distributions.
The $D^3$ Framework
The proposed $D^3$ framework shifts the focus from pixel-level differences to disparities within the classifier's internal representation space. By analyzing how the model itself perceives the difference between an input and its "ideal" InD reconstruction, the system gains a more robust signal for detection.
As shown in the figure above, the process involves several key stages:
- DM Generation: An input image $x$ undergoes a forward diffusion process followed by a reverse denoising process to produce $\hat{x}$, which is pulled toward the InD manifold.
- Feature Disparity ($\epsilon_{\ell_2}$): Penultimate-layer features ($h_x$ and $h_{\hat{x}}$) are extracted. The $\ell_2$ distance between these normalized vectors captures covariate shifts.
- Probability Disparity ($\epsilon_{KL}$): Softmax output probabilities ($g_x$ and $g_{\hat{x}}$) are compared using a modified KL divergence against a uniform distribution, highlighting concept shifts.
- Anomaly-Removal: To sharpen the disparity, an anomaly-removal strategy (e.g., feature pruning) is applied to the generated image's features, ensuring $\hat{x}$ represents a "clean" InD reference by removing abnormal OoD information.
- Ensemble Scoring: The final OoD score is a weighted combination of these feature and probability metrics.
Experimental Results
The framework was evaluated using ImageNet-1K as InD and four challenging benchmarks (Species, iNaturalist, OpenImage-O, ImageNet-O) as OoD datasets. The framework was tested on standard architectures including ResNet50 and DenseNet121.
As detailed in the table above, $D^3$ achieves state-of-the-art results among DM-based methods. On a ResNet50 backbone, it reached an average AUROC of 85.20%, significantly outperforming previous DM-based methods like DDPM (48.69% AUROC) and DiffGuard. Notably, it also surpasses established non-diffusion methods such as KNN, ViM, and MLS. The $D^3+$ variant, which incorporates additional refinement, further pushes the average AUROC to 85.64%, demonstrating consistent robustness even on the difficult ImageNet-O dataset.
Conclusion
By rethinking how we measure disparities between original and DM-reconstructed images, the $D^3$ framework demonstrates that internal classifier representations are far more effective for OoD detection than standard perceptual metrics. While the computational cost of DM sampling remains a primary bottleneck for real-time applications, the significant gains in detection accuracy provide a strong foundation for future research into efficient, high-fidelity OoD protection.
Summary updated