Vision-Language Dual-Pattern Matching for Out-of-Distribution Detection

Zihan Zhang, Zhuo Xu, Xiang XiangECCV 2024

Abstract

Out-of-Distribution (OOD) detection is a critical challenge for ensuring the reliability of machine learning models in real-world environments. While Vision-Language Models (VLMs) like CLIP provide a strong foundation for general tasks, existing OOD detection methods typically rely on textual descriptions of known classes, ignoring valuable visual information from the training set. This paper presents Dual-Pattern Matching (DPM), a novel framework that integrates both visual and textual patterns to enhance OOD detection. By utilizing domain-specific feature aggregation and aligning visual features with text prompts, DPM establishes a new state-of-the-art. Evaluations on CIFAR-100 and ImageNet-1k show significant improvements in AUROC and robustness against covariate shifts.

Introduction: The OOD Detection Challenge

In practical applications, models frequently encounter "Out-of-Distribution" (OOD) data—inputs belonging to classes not seen during training. A common failure is for a model to misclassify an unknown object (e.g., a "fox") as a known class (e.g., a "dog") with high confidence.

Comparison between the standard MCM approach and the proposed Dual-Pattern Matching (DPM) framework.

Current methods using VLMs like CLIP often focus on "Text Matching," comparing test images against textual descriptions of In-Distribution (ID) classes. However, this approach ignores the rich visual patterns available in the training data. DPM addresses this by combining textual knowledge with visual patterns, creating a more comprehensive "security guard" for model predictions.

Methodology: Dual-Pattern Matching (DPM)

The DPM framework operates on a "store and compare" logic, utilizing two distinct modalities:

  1. The Textual Pattern: This follows the standard CLIP paradigm, using text features of class names (e.g., "a photo of a dog") as a benchmark for comparison.
  2. The Visual Pattern: Instead of storing raw image features, DPM calculates a visual pattern by aggregating how training images match against text prompts. This approach helps bridge the "modality gap" between CLIP's visual and textual representations.
Detailed architecture of the DPM-T framework, illustrating feature aggregation and the dual-pattern matching process.

Key Components

  • Domain-Specific Feature Aggregation: To ensure stored patterns are clean, DPM uses text cues to distinguish between "foreground" (the object) and "background" (noise) in training images.
  • DPM-F (Training-Free): A plug-and-play version that works directly with pre-trained CLIP models without additional training.
  • DPM-T (Training-Required): A lightweight adaptation version that introduces a small number of learnable parameters (prompts and linear projections) to better align vision and text for specific tasks.

Datasets and Evaluation

The researchers evaluated DPM across several rigorous benchmarks to test both OOD detection and robustness:

  • In-Distribution (ID) Sets: CIFAR-100 and ImageNet-1k.
  • OOD Benchmarks: CIFAR-10, ImageNet-R, LSUN, iNaturalist, SUN, Texture, and Places365.
  • Covariate Shift Sets: ImageNet-V2 and ImageNet-A were used to evaluate performance on images that belong to ID classes but differ in style, lighting, or angle.

Key Results

DPM consistently outperformed existing state-of-the-art methods like MCM and CLIPN:

  • CIFAR-100: DPM-T achieved an AUROC of 91.62%, significantly reducing the False Positive Rate (FPR95) to 38.87%.
  • ImageNet-1k: Using a ViT-B-16 backbone, DPM-T reached an AUROC of 95.72%.
  • Robustness: In covariate shift scenarios, the training-free DPM-F outperformed previous leaders by a wide margin, demonstrating that visual patterns provide much-needed stability when image styles change.

Discussion and Insights

The success of DPM highlights several important principles in VLM-based OOD detection:

  • Multimodal Synergy: Visual patterns are inherently more flexible than rigid text descriptions, making them better at handling variations in lighting and angle.
  • Foreground Focus: Filtering out background noise through text-guided attention makes visual features more distinct across classes.
  • Efficiency: DPM-T achieves high performance with minimal learnable parameters, avoiding the need for full model retraining.

Limitations and Future Work

DPM requires a small set of training samples (typically 20-100 per class) to build its visual patterns, meaning it is not a "zero-data" solution. Future research may explore "prompt enhancement" using Large Language Models (LLMs) to refine textual patterns or investigate even more efficient fine-tuning for extreme few-shot scenarios (1-2 images per class).

Summary updated

BibTeX
@inproceedings{zhang2024vision,
  author = {Zihan Zhang and Zhuo Xu and Xiang Xiang},
  title = {{Vision-Language Dual-Pattern Matching for Out-of-Distribution Detection}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-73013-9\_16},
}
Figure