Source-linked AI summary
Catching Both Gray and Black Swans: Open-set Supervised Anomaly Detection
Choubo Ding, Guansong Pang, Chunhua Shen
TL;DR
Existing supervised anomaly detectors can use scarce labeled anomalies but may fail on unseen anomaly classes. DRA learns disentangled seen, pseudo, and latent residual abnormality representations, and experiments on nine datasets report superior detection across diverse settings. The paper identifies generalization from fewer anomaly examples as an important challenge for further work.
Problem
Existing methods either use only normal data or overfit scarce seen anomalies, leaving detection of unseen anomaly classes insufficiently addressed.
Method
DRA uses a multi-head network to learn disentangled representations from seen anomalies, pseudo anomalies, and latent residual anomalies.
Results
DRA substantially outperforms five state-of-the-art detectors across nine real-application datasets and diverse settings.
Takeaways & Limitations
The three complementary abnormality representations support detection of both seen and unseen anomalies, including challenging one-example settings.
Takeaways & Limitations
Generalization from smaller anomaly sets remains a major challenge requiring further investigation.
Abstract
from arXiv · showhide
Despite most existing anomaly detection studies assume the availability of normal training samples only, a few labeled anomaly examples are often available in many real-world applications, such as defect samples identified during random quality inspection, lesion images confirmed by radiologists in daily medical screening, etc. These anomaly examples provide valuable knowledge about the application-specific abnormality, enabling significantly improved detection of similar anomalies in some recent models. However, those anomalies seen during training often do not illustrate every possible class of anomaly, rendering these models ineffective in generalizing to unseen anomaly classes. This paper tackles open-set supervised anomaly detection, in which we learn detection models using the anomaly examples with the objective to detect both seen anomalies (`gray swans') and unseen anomalies (`black swans'). We propose a novel approach that learns disentangled representations of abnormalities illustrated by seen anomalies, pseudo anomalies, and latent residual anomalies (i.e., samples that have unusual residuals compared to the normal data in a latent space), with the last two abnormalities designed to detect unseen anomalies. Extensive experiments on nine real-world anomaly detection datasets show superior performance of our model in detecting seen and unseen anomalies under diverse settings. Code and data are available at: https://github.com/choubo/DRA.
1. Introduction
Anomaly detection often relies only on normal training data, although labeled anomalies are available in many applications. DRA addresses the resulting open-set challenge by learning representations for both seen and unseen anomaly classes.
- Anomaly detection has broad applications, including medical lesion detection, industrial defect inspection, video surveillance, and autonomous driving.
- Most existing methods use only normal training samples, so they cannot exploit the application-specific knowledge in available labeled anomalies.
- Supervised methods improve detection of anomalies resembling training examples but can overfit because seen anomalies do not cover every possible anomaly class.
- DRA tackles open-set supervised anomaly detection by targeting both seen gray swans and unseen black swans.
- DRA learns disentangled representations from seen anomalies, pseudo anomalies, and latent residual-based anomalies using a multi-head network.
- The experiments evaluate DRA against five state-of-the-art detectors on nine real-application datasets across diverse settings.
2. Related Work
Prior anomaly-detection approaches either lack anomaly information or risk overfitting to the few anomalies observed during training. DRA is distinguished by combining supervised anomaly examples with mechanisms aimed at broader anomaly generalization.
- Unsupervised Approaches: Unsupervised methods train only on normal data, avoiding bias toward seen anomalies but lacking knowledge that helps distinguish anomalies from normal samples.
- Supervised Approaches: Supervised methods use small anomaly datasets through one-class metric learning or anomaly-focused deviation losses.
- Supervised Approaches: These supervised models can rely heavily on seen anomalies and overfit the known abnormality.
- Learning In- and Out-of-distribution: OOD detection and open-set recognition seek accurate multi-class inlier classification alongside OOD detection, whereas DRA focuses exclusively on anomaly detection.
- Learning In- and Out-of-distribution: Pseudo-anomaly methods such as outlier exposure can be effective, but related OOD and open-set models generally assume true anomalous samples are unavailable.
3. Proposed Approach
DRA jointly learns separate representations for seen, pseudo, and latent residual anomalies, while also modeling normality. Its heads use complementary feature spaces and scoring strategies to detect diverse abnormalities.
- Problem Statement: The problem provides many normal samples and a small annotated anomaly set from seen classes, with the goal of scoring both seen and unseen anomalies above normal samples.
- Overview of Our Approach: DRA learns abnormality representations from seen anomalies, pseudo anomalies, and latent residual anomalies to reduce bias toward seen anomalies.
- Overview of Our Approach: A shared feature network feeds independent abnormality heads, each learning an anomaly score for one abnormality type under a joint objective.
- Learning Disentangled Abnormalities: The seen-anomaly head uses top-K multiple-instance learning over patch representations to focus image scoring on the most anomalous patches.
- Learning Disentangled Abnormalities: The pseudo-anomaly head uses separately parameterized learning with CutMix-style or externally sourced pseudo anomalies to model abnormalities differing from seen examples.
- Learning Disentangled Abnormalities: The residual head subtracts a fixed mean normal reference feature map from each sample's feature map and classifies the resulting residual features.
- Learning Disentangled Abnormalities: A separate normality head learns holistic global scores because the abnormality heads do not adequately model normal features.
4. Experiments
Experiments on nine real-world datasets evaluate DRA across application domains, sample budgets, open-set protocols, and ablations. DRA generally achieves stronger AUC, sample efficiency, and unseen-anomaly generalization than competing methods, while ablations support disentangled and fused abnormality learning.
- Application Domain Perspective: DRA achieves the best AUC on eight of nine datasets in one-shot and seven of nine in ten-shot evaluation, with up to 5% AUC gains on challenging datasets.The challenging datasets include MVTec AD, AITEX, Mastcam, and Hyper-Kvasir.
- Sample Efficiency: DRA has better sample efficiency, averaging a 15.1% AUC decrease with fewer anomaly examples versus 22.3% for DevNet, 21.6% for FLOS, 19.7% for SAOE, and 21.6% for MLEP.With one anomaly example, DRA can outperform competing detectors trained with ten examples on several datasets.
- Comparison to Unsupervised Baseline: With one training anomaly, DRA remains clearly better than KDAD on most datasets, including challenging MVTec AD, AITEX, and Mastcam cases.The advantage is reported for the more open-set one-shot scenario, whereas models generally perform better with ten examples.
- Application Domain Perspective: Under the hard setting, DRA increases mean AUC by about 2%-10% over the best contender on most of six datasets, indicating stronger generalizability to unseen anomaly classes.The hard setting trains on one known anomaly class and evaluates on the remaining classes.
- Sample Efficiency: Under the hard setting, DRA’s average one-shot-to-ten-shot AUC decrease is 5.5%, compared with 9.8% for DevNet, 7.1% for FLOS, 7.8% for SAOE, and 10% for MLEP.DRA trained with one anomaly example also outperforms ten-shot competitors by large margins on many subsets and overall datasets.
- Ablation and Sensitivity Analysis: Ablations show that pseudo abnormalities improve DRA1A, latent residual heads improve DRA2A, and fusing residual with holistic normality representations is needed for the full model’s effectiveness.Fully disentangled learning improves detection across three application domains; pseudo-anomaly methods vary by domain, with external data more effective on medical datasets.
5. Conclusions and Discussions
DRA learns three disentangled abnormality representations to detect both seen and unseen anomalies. Results support its value as a strong baseline while leaving challenges for broader generalization.
- DRA combines seen, pseudo, and latent residual-based abnormality representations to detect both seen and unseen anomalies.The three representations are intended to cover largely varying anomalies.
- Generalization from smaller anomaly examples spanning fewer classes remains a major challenge for further investigation.The paper presents DRA and its benchmark results as a baseline for this under-explored problem.
A.1. Key Statistics of Datasets
The evaluation uses real-world image datasets spanning industrial defects, planetary exploration, medical imaging, and synthetic optical inspection. Dataset descriptions specify anomaly types, preprocessing, normal-data splits, and available download resources.
- MVTec AD contains 15 classes and 73 fine-grained defective classes at texture or object level.Its normal samples follow the original training and test split.
- AITEX, SDD, and ELPV provide industrial defect data with pixel-level annotations or solar-cell defect classes.AITEX images are cropped into 256 × 256 patches, while SDD images are vertically divided into three segments.
- Mastcam contains typical and 11 novel geologic classes from Mars-rover multispectral imagery, using the shorter-wavelength channel here.
- BrainMRI and HeadCT are medical datasets for brain-tumor and brain-hemorrhage detection, respectively.
- Hyper-Kvasir contributes gastroscopy images labeled with anatomical landmarks as normal and pathological findings as anomalies.The dataset contains four main categories and 23 subcategories.
- The appendix provides dataset statistics, examples of normal and anomalous images, and download links.For datasets other than MVTec AD, normal samples are randomly split into training and test sets at a 3/1 ratio.
A.2. Dataset Split
The study evaluates open-set anomaly detection under general and hard sampling protocols. One-shot and ten-shot comparisons use the same test data, differing only in the number of training anomaly examples.
- General setting: The general setting samples few labeled anomalies randomly across all possible anomaly classes and removes them from the test set.This can leave test data containing seen and unseen classes, or only seen classes, depending on the dataset.
- Hard setting: The hard setting restricts training anomalies to one class and removes that class from testing, leaving unseen anomaly classes for evaluation.
- Shot comparison: The one-shot anomaly is sampled from the ten-shot examples, and both protocols evaluate on exactly the same test data.Thus, the training anomaly examples are the only difference between one-shot and ten-shot scenarios.
- Visual examples: Figure 4 places normal example images on top and anomalous example images below within each dataset group.
B. Implementation Details
This section introduces the implementation details of DRA and its competing methods. The supplied passage provides no further implementation specifications.
- The section describes implementation details for DRA and its competing methods.
- DRA is discussed alongside competing anomaly-detection methods in the implementation section.
- The section is an implementation-details part of the experimental methodology.
B.1. Implementation of DRA
DRA extracts deep image features and routes samples through specialized abnormality and normality heads. During inference, it combines head scores across image scales, while deviation loss provides the default optimization objective.
- Feature extraction: Images are resized to 448x448 or 224x224, then ResNet-18 extracts a 512-dimensional feature map for DRA’s learning heads.The feature extractor is ImageNet-pre-trained.
- Learning heads: DRA uses patch-wise classification for seen and pseudo abnormalities, while a two-layer fully connected head learns normality scores.The normality head reduces each 512-dimensional feature vector to 256 dimensions before scoring.
- Scoring: During training, samples are routed to heads according to their labels; during inference, the model sums abnormality scores and the negated normal score.A two-layer image pyramid averages scores from multiple input scales to produce the final anomaly score.
- Residual learning: The latent residual reference set mixes normal and generated pseudo-anomaly samples to provide more challenging residuals for extreme cases.The authors use this mixed dataset as the final reference set.
- Optimization: DRA uses deviation loss by default because the experiments report it as generally more effective and stable than other popular loss functions.The loss uses a Gaussian-prior anomaly score standardized by its reference mean and standard deviation; y=1 denotes anomaly and y=0 normal.
C.1. Additional Comparison Results
Across general and hard settings, DRA achieves leading AUC performance against competing methods, with additional experiments examining loss functions and cross-domain adaptation. The paper also identifies a failure case linked to limited normal-sample size.
- Hard setting: Under the hard setting, DRA achieves the best dataset-level AUC on five of six datasets and improves 9.2% to 24.4% over the suboptimal method in those five datasets.It performs best on most data subsets.
- Comparison: Results in both settings show DRA outperforming Deep SAD and MINNS.This comparison is reported as evidence of the method’s superiority in the evaluated settings.
- Loss-function analysis: The loss-function study compares deviation loss, binary cross-entropy loss, and focal loss across datasets under the hard setting.Figure 5 reports averaged AUC results over all data subsets per dataset.
- Cross-domain evaluation: DRA shows promising open-domain performance in cross-domain anomaly detection on the five texture datasets in MVTec AD.The reported experiment trains on one source dataset and fine-tunes on a target domain.
- Failure cases: DRA can fail on individual datasets, notably toothbrush, where only 60 normal samples are available and the more complex architecture needs relatively larger normal training sets.The paper recommends a lightweight DRA network for small-scale tasks.