OT-DETECTOR: Delving into Optimal Transport for Zero-shot Out-of-Distribution Detection

Yu Liu, Hao Tang, Haiqi Zhang, Jing Qin, Zechao Li · DOI

Abstract

Zero-shot Out-of-Distribution (OOD) detection aims to identify samples from unknown classes without requiring model retraining or exposure to OOD data during training. While Vision-Language Models (VLMs) like CLIP have advanced this field, they often struggle with "hard OOD" samples that share semantic similarities with In-Distribution (ID) data. This paper introduces OT-DETECTOR, a framework that leverages Optimal Transport (OT) to measure both semantic similarity and distributional gaps. By combining a Semantic-aware Content Refinement (SaCR) module with a dual-component OT scoring mechanism, OT-DETECTOR achieves state-of-the-art performance on challenging benchmarks, significantly reducing false positive rates in complex scenarios.

1. Introduction

In safety-critical applications such as autonomous driving and medical diagnostics, the ability of a machine learning model to recognize what it does not know is as crucial as its classification accuracy. This task, known as Out-of-Distribution (OOD) detection, becomes particularly challenging in "zero-shot" settings where the model must generalize to unseen OOD categories using only pre-trained knowledge.

Existing VLM-based detectors primarily rely on semantic matching—calculating the cosine similarity between image embeddings and text labels. However, this approach faces two significant hurdles:

  1. Semantic Over-reliance: Models often ignore the underlying distributional characteristics of the data, focusing solely on label-to-image alignment.
  2. The "Hard OOD" Challenge: Samples that share visual attributes or backgrounds with ID classes (e.g., distinguishing between two similar bird species where one is ID and the other is OOD) frequently lead to high-confidence misclassifications.

2. Methodology

OT-DETECTOR addresses these challenges through a two-stage pipeline: feature refinement and optimal transport scoring.

2.1 Semantic-aware Content Refinement (SaCR)

To mitigate the influence of distracting backgrounds and non-discriminative features, the SaCR module "cleans" the input image. The process involves:

  • Multi-view Generation: Creating multiple random crops of the input image.
  • Consistency Filtering: Retaining only those views whose predicted labels align with the original image's prediction, ensuring semantic integrity.
  • Feature Fusion: Using a margin-based confidence function to fuse the most discriminative views into a single refined feature vector.

This refinement ensures the model focuses on the object of interest, amplifying the subtle differences between ID and hard-OOD samples.

2.2 Optimal Transport (OT) Scoring

Rather than treating OOD detection as a simple similarity search, OT-DETECTOR frames it as a distribution matching problem. By treating a batch of test images and the set of ID text labels as two distributions, the model calculates the "transport cost" required to map one to the other. This yields two distinct scores:

  • Semantic-wise Score ($S_{sem}$): This measures the maximum transport mass from a visual sample to any specific ID label. High mass indicates a strong semantic match to a known class.
  • Distribution-wise Score ($S_{dist}$): Derived from the Wasserstein distance, this quantifies the overall cost to bridge the modality gap between the visual and textual spaces. OOD samples, even those semantically similar to ID classes, typically exhibit a higher transport cost due to their inherent distributional shift.

By integrating these scores, OT-DETECTOR captures both class-specific alignment and broader distributional anomalies.

3. Experimental Evaluation

3.1 Setup

The authors evaluated OT-DETECTOR using ImageNet-1K as the In-Distribution set. Performance was tested against four diverse OOD datasets: iNaturalist, SUN, Places, and Texture. To test the limits of the framework, "Hard OOD" benchmarks were constructed using semantically overlapping subsets of ImageNet (e.g., ImageNet-100 as ID vs. ImageNet-10 as OOD).

3.2 Results

OT-DETECTOR established new state-of-the-art (SOTA) benchmarks across all tested scenarios:

  • Standard Benchmarks: On ImageNet-1K, the model achieved an average FPR95 of 23.65% and an AUROC of 94.49%, outperforming previous methods like NegLabel (25.40% FPR95).
  • Hard OOD Performance: In the most challenging tasks, OT-DETECTOR demonstrated its primary strength, improving FPR95 by 43.78% compared to the previous best-performing zero-shot methods.
  • Architecture Agnosticism: The framework showed consistent gains across various CLIP backbones, including ViT-B/16, ViT-B/32, and ResNet50, proving its robustness to different feature extractors.

4. Discussion and Insights

The success of OT-DETECTOR highlights a critical shift in OOD detection philosophy: semantic similarity is necessary but insufficient. The "aha" moment of this research is the realization that the cost of transporting features across the vision-text gap reveals outliers that simple cosine similarity misses. Furthermore, the SaCR module acts as a necessary pre-processor that prevents the OT mechanism from being "fooled" by background noise, effectively widening the gap between ID and OOD distributions.

One notable advantage of this method is that it requires no external knowledge (like LLM-generated descriptions) or auxiliary negative labels, making it more efficient and easier to deploy in privacy-sensitive environments.

5. Limitations and Future Work

Despite its performance, OT-DETECTOR is sensitive to batch size because Optimal Transport is inherently a distribution-level calculation. Performance is optimal when larger batches are available, which may pose challenges for real-time, single-sample inference. Additionally, the SaCR module's effectiveness is tied to the diversity and coverage of the ID label set. Future research will likely focus on adapting OT-based detection for streaming data and low-label regimes to enhance its practical utility in edge computing and real-time robotics.

Summary updated

BibTeX
@inproceedings{liu2025ot,
  author = {Yu Liu and Hao Tang and Haiqi Zhang and Jing Qin and Zechao Li},
  title = {{OT-DETECTOR: Delving into Optimal Transport for Zero-shot Out-of-Distribution Detection}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.24963/ijcai.2025/184},
}
Figure