Source-linked AI summary

Explainable Deep Few-shot Anomaly Detection with Deviation Networks

Guansong Pang, Choubo Ding, Chunhua Shen, Anton van den Hengel

arXiv:2108.00462v1cs.CVcs.AIcs.LG

TL;DR

Anomaly detectors trained on normal or mostly normal unlabeled data have limited knowledge of anomalies, motivating few-shot detection from a small set of labeled examples. The paper introduces prior-driven end-to-end anomaly-score learning with feature-subspace MIL. Across nine real-world image benchmarks, DevNet is reported to be more sample-efficient and robust, to outperform competing methods in closed- and open-set settings, and to support anomaly explanation.

  • Problem

    Many anomaly detectors train on normal or mostly normal unlabeled samples, with limited knowledge of anomalies; few-shot anomaly detection asks how to use a few labeled anomalies.

    Source: §1 · p. 1, §3.1 · p. 4
  • Method

    DevNet uses a prior and labeled anomalies for end-to-end differentiable anomaly-score learning, with top-K multiple-instance feature-subspace deviation learning.

    Source: §4.3 · p. 6, §7 · p. 14
  • Results

    On nine real-world image datasets, DevNet is reported to outperform competing methods in sample efficiency, robustness, and generalization to unseen anomalies, with better AUC-ROC in detection and explanation.

    Source: §1 · p. 3, §7 · p. 14
  • Takeaways & Limitations

    Prior-driven anomaly-score learning also supports accurate localization and explanation of detected anomalies.

    Source: §1 · p. 2

    The best performance is difficult to achieve on every specific dataset; the authors identify automated architecture and module selection and further risk reduction as future work.

    Source: §7 · p. 14

Abstract

from arXiv · show

Existing anomaly detection paradigms overwhelmingly focus on training detection models using exclusively normal data or unlabeled data (mostly normal samples). One notorious issue with these approaches is that they are weak in discriminating anomalies from normal samples due to the lack of the knowledge about the anomalies. Here, we study the problem of few-shot anomaly detection, in which we aim at using a few labeled anomaly examples to train sample-efficient discriminative detection models. To address this problem, we introduce a novel weakly-supervised anomaly detection framework to train detection models without assuming the examples illustrating all possible classes of anomaly. Specifically, the proposed approach learns discriminative normality (regularity) by leveraging the labeled anomalies and a prior probability to enforce expressive representations of normality and unbounded deviated representations of abnormality. This is achieved by an end-to-end optimization of anomaly scores with a neural deviation learning, in which the anomaly scores of normal samples are imposed to approximate scalar scores drawn from the prior while that of anomaly examples is enforced to have statistically significant deviations from these sampled scores in the upper tail. Furthermore, our model is optimized to learn fine-grained normality and abnormality by top-K multiple-instance-learning-based feature subspace deviation learning, allowing more generalized representations. Comprehensive experiments on nine real-world image anomaly detection benchmarks show that our model is substantially more sample-efficient and robust, and performs significantly better than state-of-the-art competing methods in both closed-set and open-set settings. Our model can also offer explanation capability as a result of its prior-driven anomaly score learning. Code and datasets are available at: https://git.io/DevNet.

1 INTRODUCTION

Most anomaly detectors learn from normal or unlabeled data, while few-shot anomaly detection uses a small number of labeled anomalies to improve discrimination without assuming all anomaly classes are known. The paper proposes prior-driven, end-to-end anomaly-score learning and reports strong performance across nine real-world image datasets, including open-set detection and explanation.

1 INTRODUCTION

  • Few-shot anomaly detection uses a few labeled anomalies as partial knowledge, aiming to detect seen and unseen classes without requiring examples of every anomaly class.Unlike fully supervised detection, the setting does not require large-scale labeled anomaly data and is open-set.Source: §1 · p. 2
  • Limited, diverse anomaly examples make abnormality hard to represent, while normal training data may contain anomalies or noise, challenging robust normality learning.Source: §1 · p. 2
  • The framework learns anomaly scores end-to-end using a prior: normal scores approximate sampled values, while anomaly scores are pushed into the upper tail; top-K feature-subspace MIL supports fine-grained representations.The framework does not assume labeled examples cover all possible anomaly classes.Source: §1 · p. 2
  • Unlike feature-first few-shot methods, the approach directly optimizes anomaly scores, coupling them to inputs for gradient-based anomaly localization and explanation.Earlier approaches optimize representations for shallow scoring measures, indirectly optimizing anomaly scores.Source: §1 · p. 2
  • The paper presents DevNet, theoretical analysis for open-set use, and benchmarks on nine public real-world datasets for evaluating few-shot anomaly detection.The benchmarks span diverse anomaly-detection applications.Source: §1 · pp. 2–3
  • DevNet achieves state-of-the-art performance across nine real-world image datasets, with reported gains in sample efficiency, robustness to anomaly contamination, unseen-anomaly generalization, and localization.The paper also reports significantly better AUC-ROC in detection and explanation than state-of-the-art semi/weakly supervised detectors and fully supervised classifiers.Source: §1 · p. 3

2 RELATED WORK

Prior anomaly-detection work includes deep methods and a small set of few-shot approaches, but many methods optimize representations rather than anomaly scores directly. The related work also distinguishes this paper's setting from anomaly explanation and other limited-label learning tasks.

2.1.1 Deep Learning-based Methods

  • Deep anomaly methods include autoencoders, GANs, and self-supervised approaches, but their objectives may not be designed primarily for anomaly detection, yielding suboptimal or unstable performance.Coupled representation methods improve on earlier methods but still optimize anomaly scoring indirectly; DevNet instead directly learns scores without adversarial learning.Source: §2.1.1 · p. 3

2.1.2 Few-shot Anomaly Detection

  • Few-shot anomaly methods use labeled anomalies in graph propagation, metric learning, or Deep SAD, while DevNet directly learns anomaly scores; prior MIL work addresses video-level labels instead.The paper states that no results had been reported on MIL for few-shot anomaly detection.Source: §2.1.2 · p. 3

2.2 Anomaly Explanation

  • Earlier explanation methods either separate detection from explanation or use post-hoc saliency maps; DevNet uses gradient back-propagation with end-to-end deviation learning for feature localization.Source: §2.2 · pp. 3–4

2.3 Learning with Limited Labeled Data

  • Few-shot classification, PU learning, and imbalanced classification typically assume shared class structure and closed-set evaluation, unlike FSAD's potentially different anomaly manifolds and open-set task.Source: §2.3 · p. 4

3 THE PROPOSED FRAMEWORK

The framework uses a few labeled anomalies alongside normal training data to learn anomaly scores and identify the features driving a detection. It guides scores with prior-generated references and fine-grained deviation learning.

3.1 Problem Statement

  • Few-shot anomaly detection uses a small labeled anomaly set with normal data to rank anomalies, while anomaly explanation identifies the feature subspace used for a decision.The normal training data may itself contain anomalies.Source: §3.1 · p. 4

3.2 Overview of Our Framework

  • DevNet maps image patches to scores, generates a prior-based reference score, and uses an MIL deviation loss to keep normal scores near the reference and anomalous scores in its upper tail.At inference, the score can be back-propagated to pixels to identify contributors to abnormality.Source: §3.2 · p. 4

3.3 Key Intuition

  • Fine-grained MIL deviation learning reduces interference from normal patches in anomalous images and supports generalized normal and abnormal representations.The framework is intended to detect dissimilar, previously unseen anomalies while requiring substantially fewer labeled anomalies.Source: §3.3 · pp. 4–5

4 DEVIATION NETWORKS

Deviation Networks (DevNet) directly learns anomaly scores using a Gaussian prior and a multiple-instance deviation loss. Its patch-level scoring supports anomaly localization, and training optimizes the scoring network end to end.

4 DEVIATION NETWORKS

  • DevNet combines a Gaussian prior with a MIL-driven Z-Score deviation loss for sample-efficient learning of generalized representations.The framework directly learns anomaly scores rather than only optimizing feature representations.Source: §4 · p. 5

4.1 End-to-end Anomaly Scoring Network

  • The scoring network composes a feature learner with a linear anomaly-scoring function to map inputs directly to scalar scores, trained end to end.ResNet-18 is the default feature learner for image data.Source: §4.1 · p. 5

4.2 Gaussian Prior-based Reference Scores

  • The reference score is the mean of scores for randomly selected normal examples, generated from a Gaussian prior chosen for interpretability and efficient sampling.Experiments use µ = 0, σ = 1, and l = 5000.Source: §4.2 · pp. 5–6

4.3 MIL-driven Deviation Loss

  • The MIL deviation loss selects each image’s highest-scoring patches and pushes anomaly scores at least a Z-score threshold from the reference while keeping normal scores close.The experiments use a = 5, corresponding to a reported significance level of 5.73303 · 10^-7.Source: §4.3 · p. 6

4.4 Back-propagation-based Anomaly Explanation

  • DevNet uses gradients of the output score with respect to image features to create an anomaly localization map, smoothed with a Gaussian filter.The experiments use a 16x16 sliding Gaussian kernel with σ = 4.Source: §4.4 · p. 6

4.5 The DevNet Algorithm

  • Training samples balanced normal and anomalous minibatches, draws reference scores from the prior, and updates the scoring network by gradient descent; testing ranks examples by score.The output scores can also be used to locate anomaly features.Source: §4.5 · p. 7

5 THEORETICAL ANALYSIS OF DEVNET

The theoretical analysis frames few-shot anomaly detection as open-set one-class classification and explains the role of top-K MIL in limiting open-space risk. It also relates DevNet scores to probabilities under the Gaussian prior.

5.1 Anomaly Score Learning under the FSAD Setting

  • Top-K MIL is argued to reduce open-space risk by scoring likely anomalous patches, avoiding the holistic loss’s treatment of normal patches in anomaly examples as abnormal.The analysis says this reduces suppression of the learned normal space compared with holistic image-based deviation learning.Source: §5.1 · p. 7

5.2 Interpretability of Anomaly Scores

  • A DevNet score outside µ ± z_pσ has probability 2(1 − p) under the Gaussian prior; the upper-tail threshold can set an anomaly confidence level.For p = 0.95 with µ = 0 and σ = 1, the text gives z_0.95 = 1.96 and an upper-tail probability of 0.05.Source: §5.2 · pp. 7–8

6 EXPERIMENTS

The experiments evaluate DevNet across six questions using nine real-world image datasets with real anomalies from industrial, planetary, and medical applications.

6 EXPERIMENTS

  • The evaluation asks about few random labeled anomalies, open-set generalization, anomaly localization, module contributions, sample efficiency, and robustness to contamination.The settings include test anomalies from classes absent from training and varying amounts of labeled anomalies or anomaly contamination.Source: §6 · p. 8

6.1 Datasets

  • Nine publicly available real-anomaly datasets span industrial defects, planetary observations, and medical imaging.The set includes MVTec AD, AITEX, SDD, ELPV, Optical, Mastcam, Hyper-Kvasir, BrainMRI, and HeadCT.Source: §6.1 · p. 8
  • MVTec AD contains 5,354 high-resolution images and 73 texture- or object-level anomaly types across 15 dataset subsets.The first 15 datasets in Table 1 compose MVTec AD.Source: §6.1 · p. 8, Table 1 · p. 9
  • The dataset choice targets real-world complexity: synthetic image protocols may not reflect real anomalies, while video-frame conversion loses temporal information.The cited studies report 90+% AUC-ROC on synthetic benchmarks versus 60%–70% on MVTec AD for some methods.Source: §6.1 · p. 9

6.2 Competing Methods

DevNet is compared with five models spanning semi-supervised and weakly supervised anomaly detection, imbalanced classification, and multiple-instance learning.

6.2 Competing Methods

  • The five contenders are Deep SVDD, KDAD, Deep SAD, FLOS, and MINNS, selected for state-of-the-art performance and public implementations.They represent semi-supervised, weakly supervised, imbalanced-classification, and multiple-instance-learning approaches.Source: §6.2 · p. 9
  • KDAD detects anomalies by aggregating multiresolution feature discrepancies between an ImageNet-pretrained model and the detection model.Source: §6.2 · p. 9
  • Deep SVDD learns a one-class, center-oriented hypersphere from normal samples and scores samples by distance from its center.Deep SAD adds labeled anomalies and normals, using a margin constraint to separate labeled anomalies from the center while keeping normals close.Source: §6.2 · p. 9
  • FLOS uses focal loss and batchwise oversampling for imbalanced binary classification, while MINNS applies multiple-instance pooling to learn bag features.The experiments also use DevNet's oversampling method for MINNS.Source: §6.2 · p. 9

6.3 Implementation Details

DevNet extracts patch features with a ResNet-18 backbone, learns patch anomaly scores, and optimizes them end to end with top-K multiple-instance learning.

6.3 Implementation Details

  • DevNet uses ResNet-18 without its fully connected layer, a 1×1 convolution for patch scores, and top-K multiple-instance optimization with deviation loss.Each patch is treated as an instance, and K defaults to 10% of the patches per image.Source: §6.3 · p. 9
  • The backbone and anomaly-score modules are trained end to end, with Adam for 50 epochs at 20 iterations per epoch.The initial learning rate is 10^-3, weight decay is 10^-2, and batch size is 48.Source: §6.3 · p. 9
  • Deep SAD and MINNS share DevNet's backbone, while FLOS shares its implementation except for the loss; DSVDD and KDAD retain their original architectures.DSVDD, KDAD, and Deep SAD use recommended original settings; FLOS and MINNS use DevNet's optimization setting.Source: §6.3 · pp. 9–10

6.4 Performance Evaluation Metrics

Performance is measured primarily with AUC-ROC, averaged over three random-seed runs, and tested with ten labeled anomalies per dataset. DevNet significantly improves over its competitors, and the reported results attribute its stronger generality to its normality and abnormality representations.

6.4 Performance Evaluation Metrics

  • AUC-ROC summarizes true-positive versus false-positive rates; values near one indicate better ranking, while 0.5 is random ranking.For anomaly explanation, the evaluation focuses mainly on pixel-level AUC-ROC; reported scores are averaged over three runs unless stated otherwise.Source: §6.4 · p. 10

6.5.1 Experimental Setting

  • The main experimental setting adds ten randomly sampled test anomalies to training and evaluates on the remaining test data.The original training data contain exclusively normal samples, and the ten labeled anomalies are used consistently across all nine datasets.Source: §6.5.1 · p. 10

6.5.2 Results

  • DevNet significantly improves over all five contenders at 95% or 99% confidence across nine datasets, and at 90% or 95% across 23 dataset units.The 23-unit test treats each MVTec AD subset separately; the nine-unit test treats MVTec AD as a whole.Source: §6.5.2 · p. 10, Table 2 · p. 10
  • Labeled-anomaly detectors outperform unsupervised KDAD and DSVDD despite limited examples, and DevNet is reported to generalize better across object and texture anomalies.The authors attribute DevNet's advantage over MINNS, FLOS, and Deep SAD to focal fine-grained normality and unbounded deviated abnormality representations.Source: §6.5.2 · p. 10

6.6 Q2. Open-set Anomaly Detection

DevNet is evaluated on open-set anomaly detection, where test anomalies come from classes unseen during training. It outperforms competing methods overall, though generalization varies with the anomaly class used for training.

6.6.1 Experimental Setting

  • The open-set protocol trains on one anomaly class and tests on the remaining anomaly classes plus normal data, across 30 datasets.It covers AITEX, ELPV, Mastcam, Hyper-Kvasir, and the Carpet and Metal nut subsets of MVTec AD; classes with only 1–5 samples in AITEX and Mastcam are excluded.Source: §6.6.1 · pp. 10–11

6.6.2 Results

  • DevNet achieves the best AUC-ROC on four tier-1 and 12 tier-2 datasets and significantly improves over all four contenders across 30 tier-2 datasets.The significance results use a paired Wilcoxon signed rank test at the 95% confidence level.Source: §6.6.2 · p. 11
  • On many tier-2 datasets, DevNet improves AUC-ROC by 5%–18% over supervised detectors, while all models perform poorly on Mastcam.KDAD outperforms the anomaly-informed models on Mastcam.Source: §6.6.2 · p. 11
  • Performance depends on which anomaly class supplies training examples; representations learned from different anomaly classes are not mutually generalizable.The passage illustrates this variation with AUC-ROC results for Mono versus Poly.Source: §6.6.2 · p. 11

6.7 Q3. Anomaly Explanation

The explanation evaluation tests whether DevNet localizes anomalous pixels on MVTec AD. DevNet performs better than the compared methods in localization and in a joint detection-localization evaluation.

6.7.1 Experimental Setting

  • The evaluation uses MVTec AD pixel-level anomaly masks to assess localization and explainability.It also includes qualitative localization visualizations for diverse anomaly types.Source: §6.7.1 · p. 11

6.7.2 Results

  • DevNet outperforms KDAD, FLOS, and MINNS in pixel-level AUC-ROC localization for both texture and object anomalies.Table 4 evaluates localization over anomaly samples without including the anomaly detection step.Source: Table 4 · p. 11, §6.7.2 · p. 11
  • KDAD and MINNS often localize anomalous regions but also mark large normal regions as anomalous, producing more false negative errors than DevNet.Source: §6.7.2 · p. 12
  • In the joint evaluation, DevNet reaches close to 90% F1-score while maintaining about 95% AUC-ROC and consistently outperforms its three counterparts.The curve averages results over all 15 MVTec AD anomaly classes; localization AUC-ROC uses true anomalies detected by each model.Source: §6.7.2 · p. 11, Figure 4 · p. 12
  • DevNet localizes anomalous pixels across different anomaly classes, surfaces, and region sizes and shapes.These localization maps offer a direct explanation of detected anomalies.Source: §6.7.2 · p. 12

6.8 Further Empirical Analysis of DevNet

Further experiments examine DevNet’s module contributions, sample efficiency, and robustness to contamination in normal training data. Results highlight the value of top-K multiple-instance learning and show favorable comparisons across these settings.

6.8 Further Empirical Analysis of DevNet

  • The analysis assesses DevNet’s backbone, deviation-based score learning, and MIL-based fine-grained feature learning through comparisons with five variants.The default model uses ResNet-18; shallower AlexNet and deeper ResNet-50 backbones are also compared.Source: §6.8 · p. 12, §6.8.1 · p. 12

6.8.1 Q4. Ablation Study

  • Enforcing differentiable anomaly-score learning with DS significantly improves Rep across datasets.Rep removes the score-learning output layer and uses a multivariate Gaussian reference, while DS retains a scalar output without top-K learning.Source: §6.8.1 · p. 12
  • MIL-DS with top-K multiple-instance learning outperforms DS and Patch-DS by large margins on most datasets, while maintaining good performance on several exceptions.Patch-DS improves on some datasets but degrades performance on most, as irrelevant patches can bias learning; Table 5 reports the ablation results.Source: §6.8.1 · p. 12, Table 5 · p. 12
  • K = 10% generally gives nearly the best performance across the evaluated datasets, while performance may decline at K = 15% or 20%.Source: §6.8.1 · p. 12, Figure 6 · p. 13

6.8.2 Q5. Sample Efficiency

  • With 50%–75% less labeled data, DevNet outperforms MINNS by a large margin on many datasets; across different numbers of labeled anomalies, DevNet is best on most datasets and comparable to the best otherwise.Source: §6.8.2 · p. 13

6.8.3 Q6. Robustness w.r.t. Anomaly Contamination

  • As contamination rises from 0% to 20%, all four detectors decline, but DevNet declines more slowly and its advantage is clearer at 10% or 20%.The comparison fixes labeled anomalies at 10 and evaluates ELPV, BrainMRI, HeadCT, and Hyper-Kvasir.Source: §6.8.3 · p. 13

7 CONCLUSIONS AND FUTURE WORK

DevNet uses a few labeled anomalies and a Gaussian prior for fine-grained anomaly-score learning, with improved sample efficiency, robustness, and generalized representations. It performs significantly better than competing methods on nine image datasets and in open-set evaluation.

7 CONCLUSIONS AND FUTURE WORK

  • The framework uses a few labeled anomalies with a Gaussian prior for end-to-end differentiable learning of fine-grained anomaly scores.The conclusion also reports greater robustness to anomaly contamination, sample efficiency, and substantially improved generalized feature representations.Source: §7 · p. 14
  • DevNet achieves significantly better AUC-ROC performance in anomaly detection and explanation than competing semi/weakly supervised detectors and fully supervised classifiers on nine image datasets.The conclusion reports this comparison across the benchmark set.Source: §7 · p. 14
  • DevNet generalizes to the open-set setting and significantly outperforms the aforementioned counterparts, according to theoretical and empirical analyses.Source: §7 · p. 14
  • The authors identify dataset-specific best performance as difficult and propose automated architecture and module selection, alongside techniques to reduce empirical and open-space risk, as future work.Source: §7 · p. 14
Loading 2108.00462v1…