Out-of-distribution (OOD) detection holds significant importance across many applications. While semantic and domain-shift OOD problems are well-studied, this work focuses on covariate shifts - subtle variations in the data distribution that can degrade machine learning performance. We hypothesize that detecting these subtle shifts can improve our understanding of in-distribution boundaries, ultimately improving OOD detection. In adversarial discriminators trained with Batch Normalization (BN), real and adversarial samples form distinct domains with unique batch statistics - a property we exploit for OOD detection. We introduce DisCoPatch, an unsupervised Adversarial Variational Autoencoder (VAE) framework that harnesses this mechanism. During inference, batches consist of patches from the same image, ensuring a consistent data distribution that allows the model to rely on batch statistics. DisCoPatch uses the VAE's suboptimal outputs (generated and reconstructed) as negative samples to train the discriminator, thereby improving its ability to delineate the boundary between in-distribution samples and covariate shifts. By tightening this boundary, DisCoPatch achieves state-of-the-art results in public OOD detection benchmarks. The proposed model not only excels in detecting covariate shifts, achieving 95.5% AUROC on ImageNet-1K(-C) but also outperforms all prior methods on public Near-OOD (95.0%) benchmarks. With a compact model size of 25MB, it achieves high OOD detection performance at notably lower latency than existing methods, making it an efficient and practical solution for real-world OOD detection applications. The code is publicly available.
翻译:分布外(OOD)检测在众多应用中具有重要意义。尽管语义偏移和领域偏移的OOD问题已得到充分研究,但本研究聚焦于协变量偏移——即数据分布中可能降低机器学习性能的细微变化。我们假设检测这些细微偏移能够提升对分布内边界的理解,从而最终改善OOD检测性能。在使用批归一化(BN)训练的对抗判别器中,真实样本与对抗样本会形成具有独特批统计量的不同域——我们利用这一特性进行OOD检测。本文提出DisCoPatch,一种基于此机制的无监督对抗变分自编码器(VAE)框架。在推理阶段,批次由来自同一图像的图像块构成,确保数据分布的一致性,使模型能够依赖批统计量进行判断。DisCoPatch利用VAE生成的次优输出(生成样本与重建样本)作为负样本训练判别器,从而提升其划分分布内样本与协变量偏移边界的能力。通过收紧该边界,DisCoPatch在公开OOD检测基准测试中取得了最先进的性能。该模型不仅在检测协变量偏移方面表现优异(在ImageNet-1K(-C)上达到95.5%的AUROC),同时在公开近分布外(Near-OOD)基准测试中以95.0%的AUROC超越所有现有方法。该模型仅需25MB的紧凑参数量,在显著低于现有方法的延迟下实现了高性能OOD检测,为实际应用提供了高效实用的解决方案。相关代码已公开。