Source-linked AI summary
A Hierarchical Transformation-Discriminating Generative Model for Few Shot Anomaly Detection
Shelly Sheynin, Sagie Benaim, Lior Wolf
TL;DR
Image anomaly detection often assumes many training examples, while this paper studies settings with only a few, including one. It combines hierarchical multi-scale patch modeling with transformation-discriminating patch classifiers. The method outperforms recent baselines across the reported few-shot anomaly-detection and defect-detection settings.
Problem
Method
A hierarchical generative model captures multi-scale patch statistics, while scale-specific discriminators assess patch realism and applied transformations.
Source: §1 · p. 1Results
The method outperforms recent baselines in one-, five-, and ten-shot settings and improves few-shot localization of anomalous patches in defect detection.
Source: §1 · p. 1Takeaways & Limitations
With a small training set, the method demonstrates one-class classification capabilities despite the literature's emphasis on modeling variability between training samples.
Source: §5 · p. 9Training becomes more involved as the number of training images grows, and the method does not scale well to hundreds or thousands without further modifications.
Source: §5 · p. 8
Abstract
from arXiv · showhide
Anomaly detection, the task of identifying unusual samples in data, often relies on a large set of training samples. In this work, we consider the setting of few-shot anomaly detection in images, where only a few images are given at training. We devise a hierarchical generative model that captures the multi-scale patch distribution of each training image. We further enhance the representation of our model by using image transformations and optimize scale-specific patch-discriminators to distinguish between real and fake patches of the image, as well as between different transformations applied to those patches. The anomaly score is obtained by aggregating the patch-based votes of the correct transformation across scales and image regions. We demonstrate the superiority of our method on both the one-shot and few-shot settings, on the datasets of Paris, CIFAR10, MNIST and FashionMNIST as well as in the setting of defect detection on MVTec. In all cases, our method outperforms the recent baseline methods.
1. Introduction
The paper targets image anomaly detection from very few normal training images, including one, by combining multi-scale patch generation with transformation-based discrimination. It reports gains over recent baselines across few-shot anomaly detection and defect localization.
- The task is motivated by the scarcity of training images in visual domains and the ability of people to identify anomalies from few examples.Source: §1 · p. 1
- A hierarchical generative model captures internal patch statistics from one or a few images at multiple scales.Source: §1 · p. 1
- Conditioning the generator on image index extends single-image modeling to multiple training images and enables information sharing between them.Source: §1 · p. 1
- Multi-scale patch modeling covers both global properties such as color or structure and anomalies confined to localized regions.Source: §1 · p. 1
- At each scale, transformed generated patches are judged by a discriminator for both real-versus-fake status and transformation identity.Source: §1 · p. 1
- Across one-, five-, and ten-shot benchmarks, the method outperforms recent baselines, improves with more training samples, and better localizes anomalous patches in few-shot defect detection.Source: §1 · p. 1
2. Related Work
Related work spans reconstruction, classification, and distribution-based anomaly detection. The paper distinguishes its approach by combining multi-scale patch-distribution modeling with a discriminator in the few-shot setting.
- Reconstruction-based methods use low error for normal data and high reconstruction error for anomalies.Source: §2 · pp. 1–2
- Classification-based approaches include self-supervised proxy tasks, while this method places transformation classification within a hierarchical patch-based generative setting.Source: §2 · p. 2
- Generative distribution modeling includes autoencoders, variational autoencoders, and GANs, but a generative model alone may not suffice for out-of-distribution detection.Source: §2 · p. 2
- The approach combines a hierarchical model of multi-scale patch distributions with scale-dependent discrimination of patch realism and transformations.Source: §2 · p. 2
- Prior internal-statistics GANs model one image for generation, whereas this method targets anomaly detection from one or a few normal images.Source: §2 · p. 2
3. Method
The method learns anomaly detection from a small set of normal images, including a single image, by modeling their patch distributions at multiple scales. Transformation-discriminating patch classifiers provide the basis for scoring test images and localized defects.
3. Method
- The task is to learn a normal-versus-anomalous classifier from a small i.i.d. sample of images drawn from the normal class.The setting includes k = 1 as well as other small training-set sizes.Source: §3 · p. 2
3.1. One Shot Anomaly Detection
- At every scale, discriminators classify transformed patches by transformation and distinguish fake patches; low correct-transformation votes across patches indicate anomaly, and the authors report improvement from the hierarchical model.The anomaly score aggregates patch votes across scales and transformations.Source: §3.1 · pp. 3–4
3.2. From one shot to few shot anomaly detection
- For few-shot training, one generator conditioned on the training-image index models each image distribution, avoiding separate models and enabling information sharing between images.The index is concatenated as an additional input channel.Source: §3.2 · p. 4
3.3. Defect Detection
- For defect detection, the method averages the 5% of patches with the lowest anomaly scores rather than averaging all patches.The selected patches are defined separately for each scale and transformation.Source: §3.3 · pp. 4–5
3.4. Architecture and training details
- Generators and discriminators use five convolutional blocks, yielding an 11 × 11 generator receptive field; training uses Adam at 0.0005 with α = 100.The finest scale is set to at most 64 × 64 pixels.Source: §3.4 · p. 5
4. Experiments
The method is reported to outperform baselines in one-shot and few-shot anomaly detection and MVTec defect detection. Ablations identify the generator, transformations, and patch hierarchy as important components, with hierarchy particularly important.
4. Experiments
- Images were resized to 64 × 64 and evaluated by mean AUC over ten random training trials; benchmarks included Paris, CIFAR10, FashionMNIST, MNIST, and MVTec.MVTec includes 10 object and 15 texture categories, with 70 defect types in test images.Source: §4 · p. 5, §4.1 · p. 5, §4.2 · p. 6
4.1. Anomaly detection
- Our method outperforms all baselines across Paris, CIFAR10, FashionMNIST, and MNIST in one-shot anomaly detection.Figure 2 presents average AUC for these one-shot comparisons.Source: §4.1 · p. 5, Figure 2 · p. 6
- In five- and ten-shot detection, our method outperforms baselines on all four datasets; on Paris, five samples raise AUC from 66.6% to 79.8%.On CIFAR10, it also improves with more samples and outperforms baselines at 50 and 80 shots, while its gap from GEOM decreases as k increases.Source: §4.1 · p. 5, Figure 2 · p. 6, Figure 4 · p. 7
4.2. Defect detection
- On MVTec, our method outperforms all baselines in one-, five-, and ten-shot defect detection.Ours1 uses the standard transformations; Ours2 uses only rotations for comparison with DifferNet.Source: §4.2 · p. 7, Figure 5 · p. 8
- For one-shot MVTec localization, our method captures defect regions accurately, whereas DifferNet captures smaller regions.Figure 6 shows original images with anomaly regions delineated in red alongside localization maps from both methods.Source: §4.2 · p. 7, Figure 6 · p. 8
4.3. Ablation analysis
- Ablations show that the generator, transformations, and patch hierarchy are all needed for best performance, with hierarchy particularly important.The table reports average CIFAR10 AUC with or without each component.Source: Table 1 · p. 7, §4.3 · p. 8
- GEOM trained on generated images is less effective than the proposed method but more effective than few-shot GEOM.The paper reports these comparisons alongside the component ablations.Source: §4.3 · p. 8
- Using 5% of patches is best for one-shot detection, while 10% is best for five- and ten-shot settings; results remain stable at low patch fractions.Figure 7 plots average MVTec AUC by percentage of patches used.Source: §4.3 · p. 8, Figure 7 · p. 8
5. Conclusions
The conclusion presents a multi-scale hierarchical generative model that places transformation classification within its discriminators, alongside a conditioning layer for sharing information across training images. It also notes the method’s strong few-shot performance and its limits at much larger training-set sizes.
5. Conclusions
- The model incorporates self-supervised transformation classification within its discriminators and adds image-index conditioning to train across multiple images.The authors describe both the integration and multi-image training as distinctive aspects of their approach.Source: §5 · p. 8
- Without further modifications, the method does not scale well to hundreds or thousands of training images, and training becomes more involved as image count increases.Source: §5 · p. 8
- For the small training sets it targets, the method demonstrates one-class classification capabilities described as surprising given the literature’s emphasis on modeling variability between training samples.Source: §5 · p. 9