Transfer-Based Semantic Anomaly Detection

Lucas Deecke, Lukas Ruff, Robert A. Vandermeulen, Hakan BilenICML 2021

Introduction: The Challenge of Semantic Anomalies

Anomaly Detection (AD) aims to identify "unusual" samples within a dataset. While traditional deep learning methods excel at spotting "low-level" anomalies—such as noise, artifacts, or blurred edges—they frequently struggle with semantic anomalies. These are situations where an image is technically flawless, but its content does not belong (e.g., a dog appearing in a dataset exclusively containing cats).

Semantic anomaly detection in feature space

The core challenge lies in the absence of a single mathematical definition for "unusual." Previous approaches attempted to solve this using self-supervision, such as teaching a model to predict if an image has been rotated. However, these proxy tasks often force the model to focus on low-level geometric features rather than high-level "objectness." The authors argue that to detect a new object class as an anomaly, a model fundamentally needs a prior understanding of what "objects" are. This paper demonstrates that the secret to detecting semantic anomalies isn't just better self-supervision, but leveraging the rich representations already learned by large-scale pretrained models.

Methods: Transfer Learning as an Inductive Bias

Instead of learning from scratch, the authors propose transferring knowledge from a semantically rich task (like ImageNet classification) and using it as a strong inductive bias. A major hurdle in fine-tuning pretrained models on a narrow "normal" dataset is "catastrophic forgetting"—the model quickly loses its general semantic power, becoming a specialist in the normal data but losing the broader context needed to recognize novel objects.

To prevent this, the authors introduce two specific methods:

  1. ADIB (Anomaly Detection with an Inductive Bias): This method utilizes standard Outlier Exposure (OE), training the model to distinguish "normal" data from a large, unrelated corpus of images. Crucially, it adds an $L_2$ regularization term that penalizes the model if its weights drift too far from the original pretrained ImageNet weights.
  2. ADRA (Anomaly Detection with Residual Adaptation): A more parameter-efficient approach. It keeps the pretrained 3x3 convolutional filters fixed and only learns small 1x1 "correction" layers (residual adapters). This forces the model to rely almost entirely on the pretrained features while allowing just enough flexibility to adapt to the specific "normal" class.

Datasets and Intervention Experiments

The paper evaluates these methods across several challenging scenarios, including CIFAR-10 and STL-10 for Semantic AD (where multiple classes are "normal" and one is the anomaly) and the classic One-versus-Rest benchmark.

A standout contribution is the use of the MPI3D dataset, a high-resolution dataset of a robot arm, for "intervention" experiments. Here, the authors systematically change single factors—like object color, shape, or size—to see exactly what the model perceives as anomalous.

Intervention experiments on the MPI3D dataset

By using these interventions, the authors proved that without Outlier Exposure (seeing what different looks like), models are almost blind to color changes. However, to successfully detect shape or size changes, models require both Outlier Exposure and the strong inductive bias provided by ADIB or ADRA.

Key Results

The performance gains achieved by introducing this inductive bias are substantial, particularly on the most difficult tasks:

  • Semantic AD (CIFAR-10): ADIB achieved a remarkable 74.6 mAP, shattering the previous state-of-the-art of 41.6 mAP.
  • One-versus-Rest (CIFAR-10): The methods raised the bar from 96.1 mAUC to 99.1 mAUC, nearing "solved" status for this classic benchmark.
  • Efficiency: ADRA (the residual adaptation method) achieved performance nearly as good as ADIB while being significantly more memory-efficient. This makes it a prime candidate for edge computing or federated learning applications.

Limitations and Future Work

While highly effective, these methods have limitations. They rely heavily on Auxiliary Data for Outlier Exposure, requiring a large, diverse dataset (like CIFAR-100 or ImageNet) to act as a proxy for "the rest of the world." In specialized domains where such broad data doesn't exist (e.g., specific medical imaging tasks), applying this method might be challenging.

Furthermore, the authors note that while their models are robust, they do not explicitly disentangle factors like color from shape. An open question remains: would a model that explicitly understands and separates these generative factors achieve even better anomaly detection performance? Finally, the importance of the transfer task increases as the outlier data becomes less similar to the target domain, meaning choosing the right pretraining task for specific AD domains is a critical area for future study.

Summary updated

BibTeX
@inproceedings{deecke2021transfer,
  author = {Lucas Deecke and Lukas Ruff and Robert A. Vandermeulen and Hakan Bilen},
  title = {{Transfer-Based Semantic Anomaly Detection}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
  url = {https://openreview.net/forum?id=9mCa0E5W-hT},
}
Figure