Enhancing Few-Shot Out-of-Distribution Detection via the Refinement of Foreground and Background

Tianyu Li, Zongqian Wu, Songyue Cai, Ping Hu, Xiaofeng ZhuarXiv 2026

TL;DR

FoBoR (Foreground and Background Refinement) is a parameter-free, plug-and-play framework that significantly enhances few-shot out-of-distribution (OOD) detection for CLIP-based models. By adaptively suppressing background patches based on their statistical correlation with target classes and rectifying "confusable" foreground patches, FoBoR prevents shortcut learning and improves model robustness across standard and hard OOD benchmarks.

What Problem Does This Paper Address?

In real-world deployment, machine learning models frequently encounter out-of-distribution (OOD) data—samples from classes they have never seen during training. Detecting these anomalies using only a few in-distribution (ID) examples is known as Few-Shot OOD (FS-OOD) detection.

Recent state-of-the-art methods leverage pre-trained vision-language models like CLIP by decomposing an image into foreground (ID features) and background (surrogate OOD features) regions. However, existing foreground-background (FG-BG) decomposition methods suffer from two major flaws:

  1. Uniform Background Suppression: They treat all background patches equally, ignoring the fact that certain backgrounds frequently co-occur with specific classes (e.g., dogs are often seen on grass, but rarely in front of airplanes). This can lead to shortcut learning.
  2. Semantic Confusion in the Foreground: They overlook "confusable patches" within the foreground—local regions that look highly similar to other classes (e.g., a Husky's ears looking like a wolf's), which can mislead the model during training.

Methods

The authors introduce FoBoR, a framework designed to refine how models handle both background and foreground patches without adding any extra trainable parameters.

The FoBoR framework architecture, highlighting FG-BG Decomposition, Adaptive Background Suppression, and Confusable Foreground Rectification.

FoBoR consists of three core components:

  • Foreground-Background Decomposition: Following prior work, this module uses the similarity between image patch embeddings and class text embeddings to segment the image into foreground and background patches.
  • Adaptive Background Suppression (ABS): Instead of uniform suppression, ABS computes a background-class correlation score using CLIP’s intrinsic local-to-global attention maps. This score is calibrated with the ground-truth class probability to apply stronger entropy regularization to background patches that are highly correlated with the target class.
  • Confusable Foreground Rectification (CFR): CFR automatically identifies "confusable classes" by fusing CLIP's textual and visual semantic similarities. It then localizes the foreground patches that match these confusable classes and applies a binary entropy maximization loss to weaken their misleading discriminative influence.

Datasets

The framework was evaluated using ImageNet-1k as the In-Distribution (ID) dataset. OOD detection performance was measured across several benchmarks:

  • Standard OOD Benchmarks: iNaturalist, SUN, Places, and Texture.
  • OpenOOD Benchmark: Evaluated on Far-OOD (iNaturalist, Texture, OpenImage-O) and Near-OOD (SSB-hard, NINCO, ImageNet-O) datasets.
  • Semantically Constrained Subsets: ImageNet-10, ImageNet-20, and ImageNet-1k-OOD were utilized to facilitate rigorous near-OOD and large-scale hard OOD analysis.

Key Insights and Ideas

  • Not All Backgrounds are Equal: Backgrounds carry varying degrees of statistical correlation with target classes. Suppressing highly correlated backgrounds more aggressively forces the model to focus on robust, class-specific foreground features rather than contextual shortcuts.
Figure 2: Illustration of background-class correlation and its impact on model predictions. The left side shows training samples of the “dog” class under different background conditions. The right side presents the corresponding prediction results when other images are placed under grassland and airplane backgrounds, respectively.
  • Mitigating Ambiguity via Entropy Maximization: Rather than trying to force a model to correctly classify ambiguous, highly similar local features (like a Husky vs. a Wolf patch), it is more effective to maximize the binary entropy between the true class and the confusable class, effectively telling the model to remain neutral on highly ambiguous patches.
  • Zero-Parameter Overhead: By cleverly repurposing CLIP’s internal attention mechanisms and cross-modal representations, FoBoR achieves these refinements entirely through loss function modifications, introducing zero extra parameters or training latency.

Key Results

FoBoR was integrated with several prominent FG-BG decomposition methods (LoCoOp, SCT, and Mambo) and consistently yielded performance gains.

Comprehensive comparison results on ImageNet-1k OOD benchmarks under 1-shot and 16-shot settings.
  • Standard Benchmarks (16-shot): Adding FoBoR reduced the False Positive Rate (FPR95) of LoCoOp, SCT, and Mambo by 2.44%, 1.94%, and 1.10% respectively, while simultaneously boosting AUROC scores.
  • Hard OOD Benchmarks: On the challenging OpenOOD benchmark, FoBoR reduced the average FPR95 by 0.85% compared to the best baseline (Mambo) and by 1.98% compared to the weakest baseline (LoCoOp), proving its capability in handling near-OOD scenarios where ID and OOD classes are semantically similar.

Limitations and Future Work

The authors note that the framework's stability relies on the selection of its balancing hyperparameters ($\alpha$ and $\beta$). Sensitivity analyses showed that if these parameters are set outside of their optimal ranges ($\alpha \in [0.2, 0.25]$ and $\beta \in [0.2, 3.0]$), the model's performance can deteriorate drastically.

Explicit directions for future work were not extensively discussed in the paper, though automating the tuning of these scaling coefficients represents a natural next step.

Summary updated

BibTeX
@misc{li2026enhancing,
  author = {Tianyu Li and Zongqian Wu and Songyue Cai and Ping Hu and Xiaofeng Zhu},
  title = {{Enhancing Few-Shot Out-of-Distribution Detection via the Refinement of Foreground and Background}},
  year = {2026},
  eprint = {2601.15065},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2601.15065},
}
Figure