Background Matters: Enhancing Out-of-distribution Detection with Domain Features

Choubo Ding, Guansong Pang, Chunhua Shen

Abstract

Detecting out-of-distribution (OOD) inputs is a principal task for ensuring the safety of deploying deep-neural-network classifiers in open-world scenarios. OOD samples can be drawn from arbitrary distributions and exhibit deviations from in-distribution (ID) data in various dimensions, such as foreground semantic features and background domain features. This paper considers the importance of the domain features in OOD detection and proposes to leverage them to enhance the semantic-feature-based OOD detection methods. We propose a novel generic framework, Disentangled Foreground and Background (DFB), that learns domain features from ID training samples via a dense prediction approach. Extensive experiments show that our approach substantially enhances the performance of four different state-of-the-art (SotA) OOD detection methods and achieves new SotA performance on multiple benchmarks.

Introduction

Deep learning classifiers are notoriously overconfident, often assigning high certainty to Out-of-Distribution (OOD) samples from categories they have never seen. A significant challenge in OOD detection is "foreground-background confusion." While most detectors focus on foreground semantic features (e.g., identifying a horse), models often learn spurious correlations with background domain features (e.g., a green field). If an OOD image shares a similar background or possesses a completely alien texture, standard models struggle.

This paper introduces DFB, a framework that explicitly separates an image's foreground objects from its background. By treating the background as its own distinct class, DFB provides a plug-and-play enhancement that significantly boosts the performance of existing state-of-the-art OOD detection methods.

The DFB Framework

The DFB framework operates through a multi-stage process designed to disentangle features without requiring manual segmentation labels.

The DFB framework compared to existing OOD detection methods.
  1. Weakly-Supervised Disentanglement: Using Class Activation Mapping (CAM) on a pre-trained $K$-class classifier, the model identifies salient pixels to generate pseudo-masks that separate foreground from background.
  2. Dense Prediction Learning: A new $(K+1)$-class "dense prediction" network is trained, where the $(K+1)$-th class is dedicated specifically to the "In-Distribution background."
  3. Lossless Conversion: The dense prediction network is converted back into a standard image classifier by replacing upsampling layers with Global Average Pooling (GAP), maintaining learned features while enabling standard inference.
  4. Joint OOD Scoring: During inference, the model combines a semantic score (foreground) with a background score from the $(K+1)$-th class using temperature-scaled fusion.

Experimental Results

The researchers evaluated DFB using CIFAR-10 and CIFAR-100 as In-Distribution (ID) data against various OOD datasets including SVHN, Places365, and Textures.

Score distributions for foreground and background features, showing improved separation between ID and OOD samples.

A key insight was the effectiveness of the background score. For datasets like Textures, which lack distinct objects, the background score alone often outperformed traditional semantic scores. By combining these signals, DFB achieved new State-of-the-Art (SotA) results:

  • FPR95 Reduction: On CIFAR-10, DFB reduced the False Positive Rate (at 95% True Positive Rate) for the ViM detector from 4.84% to 3.65%.
  • Averaged Gains: Across four base models (MSP, ODIN, Energy, and ViM), DFB improved the average FPR95 by 10.38% on CIFAR-10 and 11.78% on CIFAR-100.
  • Scalability: The method remained robust in large-scale scenarios like ImageNet-1k, consistently outperforming baseline Energy scores.

Conclusion and Future Work

DFB demonstrates that background domain features are a rich, neglected source of information for OOD detection. While highly effective, the method's performance can be sensitive to the temperature hyperparameter ($T$) used in score fusion. Additionally, the quality of disentanglement depends on the initial model's localization capabilities. Future work may involve extending this framework to zero-shot OOD detection using vision-language models like CLIP to better characterize background features through descriptive prompts.

Summary updated

Abstract

Detecting out-of-distribution (OOD) inputs is a principal task for ensuring the safety of deploying deep-neural-network classifiers in open-world scenarios. OOD samples can be drawn from arbitrary distributions and exhibit deviations from in-distribution (ID) data in various dimensions, such as foreground semantic features (e.g., vehicle images vs. ID samples in fruit classification) and background domain features (e.g., textural images vs. ID samples in object recognition). Existing methods focus on detecting OOD samples based on the semantic features, while neglecting the other dimensions such as the domain features. This paper considers the importance of the domain features in OOD detection and proposes to leverage them to enhance the semantic-feature-based OOD detection methods. To this end, we propose a novel generic framework that can learn the domain features from the ID training samples by a dense prediction approach, with which different existing semantic-feature-based OOD detection methods can be seamlessly combined to jointly learn the in-distribution features from both the semantic and domain dimensions. Extensive experiments show that our approach 1) can substantially enhance the performance of four different state-of-the-art (SotA) OOD detection methods on multiple widely-used OOD datasets with diverse domain features, and 2) achieves new SotA performance on these benchmarks.
BibTeX
@inproceedings{ding2024background,
  author = {Choubo Ding and Guansong Pang and Chunhua Shen},
  title = {{Background Matters: Enhancing Out-of-distribution Detection with Domain Features}},
  booktitle = {ACM Multimedia},
  year = {2024},
  doi = {10.1145/3664647.3681614},
}
Figure