NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Enhancing Anomaly Detection Generalization through Knowledge Exposure: The Dual Effects of Augmentation

Mohammad Akhavan Anvari, Rojina Kashefi, Vahid Reza Khazaie, Mohammad Khalooei, Mohammad Sabokrou · DOI · OpenReview

TL;DR

This paper tackles the challenge of anomaly detection models failing to generalize to real-world data where transformations can subtly alter an object's meaning. They introduce "Knowledge Exposure" (KE), a method that uses a pre-trained CLIP model to dynamically identify which data augmentations preserve an object's semantics and which change it, leading to significantly improved generalization performance.

What Problem Does This Paper Address?

Traditional anomaly detection methods often assume that "normal" data during testing will look very similar to the "normal" data seen during training. However, in real-world scenarios, data often undergoes transformations (like rotations, changes in lighting, etc.) that can shift its distribution. The critical issue is that some transformations preserve the core meaning of an object (e.g., rotating a bird doesn't make it an anomaly), while others fundamentally change it (e.g., rotating a car by 90 degrees might make it appear anomalous in certain contexts). Current anomaly detection models struggle with this nuance, often misclassifying transformed normal samples as anomalies or failing to detect genuinely anomalous samples that have undergone subtle shifts. This lack of robustness hinders their reliability in practical applications.

Methods

The core of the proposed solution is Knowledge Exposure (KE). KE leverages the rich visual understanding of a pre-trained CLIP (Contrastive Language–Image Pre-training) model. The idea is that CLIP, having been trained on a massive dataset of image-text pairs, has a sophisticated grasp of how different transformations affect the semantic meaning of objects.

Here's how it works:

  1. Transformation Analysis: For a given dataset, the authors apply various geometric and non-geometric transformations to the images.
  2. CLIP Embeddings: These original and transformed images are then passed through the CLIP image encoder to obtain their feature representations (embeddings).
  3. Wasserstein Distance: The Wasserstein distance is used to quantify how much the distribution of embeddings for a transformed image set differs from the distribution of embeddings for the original, untransformed images.
  4. Dynamic Pair Selection:
    • Transformations resulting in a small Wasserstein distance are considered positive pairs – they preserve the semantic meaning of the original object.
  5. Transformations resulting in a large Wasserstein distance are considered negative pairs – they significantly alter the semantic meaning, making the transformed object potentially anomalous.
  6. Contrastive Learning: These dynamically selected positive and negative pairs are then used to train a standard anomaly detection model (e.g., a ResNet-18) using a contrastive learning loss. This loss encourages the model to learn representations where positive pairs are similar and negative pairs are dissimilar.

This approach allows the model to learn what constitutes a "normal" variation versus a semantically significant shift, leading to better generalization.

Datasets

The authors evaluated their method on three standard datasets:

  • CIFAR-10: A dataset of 60,000 color images across 10 classes.
  • CIFAR-100: A dataset of 60,000 color images across 100 classes.
  • SVHN (Street View House Numbers): A dataset of over 600,000 color images of house numbers.

They also introduced new testing protocols:

  • Semantic-Preserving Augmentation (SPA) Setup: This setup aims to create a benchmark with significant intra-class distribution shifts, expecting models to be robust to various transformations.
  • Semantic-Shift Aware (SSA) Setup: This is presented as the most realistic setup, where they carefully determine which transformations maintain semantic normality and which alter it, reflecting real-world anomaly detection challenges.

Key Insights and Ideas

  • Transformations are not monolithic: The core insight is that data augmentations are not all equal. Some preserve meaning, others change it, and this distinction is crucial for robust anomaly detection.
  • CLIP as a semantic oracle: Leveraging a large pre-trained vision-language model like CLIP provides a powerful, data-driven way to understand the semantic impact of transformations without manual labeling for every scenario.
  • Dynamic pair selection is key: Instead of fixed augmentation strategies, dynamically selecting positive and negative pairs based on semantic preservation (via CLIP and Wasserstein distance) allows models to learn more nuanced representations.
  • Real-world anomaly detection is about semantic shifts: The paper argues that true anomaly detection generalization hinges on understanding when a transformation alters an object's fundamental meaning, not just its appearance.

Key Results

The proposed Knowledge Exposure (KE) method, combined with contrastive learning, demonstrated superior performance compared to existing anomaly detection methods on the CIFAR-10, CIFAR-100, and SVHN datasets, particularly under the more realistic SPA and SSA testing protocols. While specific AUROC percentages vary across tables, the paper consistently shows that their method maintains higher AUROC scores, indicating better generalization and robustness against distribution shifts. For instance, Table 1 shows their "Ours" method achieving significantly higher AUROC scores in the SSA setting for CIFAR-10 compared to other methods.

Limitations and Future Work

  • Reliance on Pre-trained Models: The primary limitation acknowledged is the method's reliance on a pre-trained network (like CLIP) to provide the necessary knowledge for all transformations. This could restrict its applicability if such models are unavailable or unsuitable for a specific domain.
  • Hyperparameter Tuning: The paper mentions that the effect of the hyperparameter K (number of positive/negative pairs) was analyzed, suggesting that tuning such parameters is important for optimal performance.
  • Future Work: The authors suggest that future research could explore alternative pre-trained encoders beyond CLIP, though CLIP yielded the best results due to its extensive training. They also highlight the need for continued development of robust anomaly detection models that can handle complex real-world scenarios.

Summary updated

BibTeX
@misc{anvari2024enhancing,
  author = {Mohammad Akhavan Anvari and Rojina Kashefi and Vahid Reza Khazaie and Mohammad Khalooei and Mohammad Sabokrou},
  title = {{Enhancing Anomaly Detection Generalization through Knowledge Exposure: The Dual Effects of Augmentation}},
  year = {2024},
  eprint = {2406.10617},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.10617},
}
Figure