Source-linked AI summary
DRAEM -- A discriminatively trained reconstruction embedding for surface anomaly detection
Vitjan Zavrtanik, Matej Kristan, Danijel Skočaj
TL;DR
Surface anomaly detection requires localizing often subtle defects despite scarce anomalous training images and limitations of reconstruction-based methods. DRAEM jointly learns an anomaly-free reconstruction and a discriminative embedding from synthetic anomalies, directly producing anomaly maps. It outperforms unsupervised state-of-the-art methods on MVTec and approaches supervised detection performance on DAGM while achieving stronger localization accuracy.
Problem
Surface anomaly detection lacks abundant labeled anomalies, while reconstructive methods can over-generalize to subtle anomalies and are not explicitly optimized for discriminative detection.
Method
DRAEM uses an end-to-end reconstructive sub-network and discriminative sub-network that learn jointly from synthetic anomalies and the original–reconstructed image representation.
Results
DRAEM improves over current state-of-the-art on MVTec by 2.5 AUROC points for detection and 13.5 AP points for localization, while on DAGM its detection approaches fully supervised methods and localization surpasses them.
Takeaways & Limitations
The method directly localizes anomalies without complicated post-processing and does not require synthetic anomaly appearances to closely match test anomalies.
Takeaways & Limitations
Some detection errors arise from inaccurate ground-truth labels for ambiguous anomalies, such as masks covering non-anomalous regions.
Abstract
from arXiv · showhide
Visual surface anomaly detection aims to detect local image regions that significantly deviate from normal appearance. Recent surface anomaly detection methods rely on generative models to accurately reconstruct the normal areas and to fail on anomalies. These methods are trained only on anomaly-free images, and often require hand-crafted post-processing steps to localize the anomalies, which prohibits optimizing the feature extraction for maximal detection capability. In addition to reconstructive approach, we cast surface anomaly detection primarily as a discriminative problem and propose a discriminatively trained reconstruction anomaly embedding model (DRAEM). The proposed method learns a joint representation of an anomalous image and its anomaly-free reconstruction, while simultaneously learning a decision boundary between normal and anomalous examples. The method enables direct anomaly localization without the need for additional complicated post-processing of the network output and can be trained using simple and general anomaly simulations. On the challenging MVTec anomaly detection dataset, DRAEM outperforms the current state-of-the-art unsupervised methods by a large margin and even delivers detection performance close to the fully-supervised methods on the widely used DAGM surface-defect detection dataset, while substantially outperforming them in localization accuracy.
1. Introduction
Surface anomaly detection must localize small, often subtle deviations using mostly anomaly-free training data. DRAEM addresses this by jointly learning reconstruction and discrimination from synthetic anomalies, producing anomaly maps that generalize to real defects.
- Problem: Surface anomaly detection localizes image regions that deviate from normal appearance, often occupying few pixels and lying close to the training distribution.The task is common in quality control and surface-defect localization applications.
- Problem: Anomaly appearances vary widely, while anomalous images are rare and manual annotation can be time-consuming, leaving training sets highly imbalanced.Such training sets often contain only anomaly-free images.
- Prior limitations: Reconstructive methods learn from anomaly-free images but can reconstruct subtle anomalies well, making reconstruction-error detection difficult.Their anomaly maps are commonly obtained by thresholding input–reconstruction differences.
- Method: DRAEM jointly learns an anomaly-free reconstruction subspace and a decision boundary over the joint original and reconstructed appearance using synthetic anomalies.This combines a reconstructive sub-network with a discriminative sub-network trained end-to-end.
- Method: Synthetic anomalies need not faithfully match test anomalies because the model learns a local-appearance-conditioned distance function between original and reconstructed anomaly appearances.The approach is designed to avoid overfitting to synthetic appearance while generalizing across real anomalies.
- Result: DRAEM outperforms recent state-of-the-art methods by a large margin while remaining discriminatively trained and directly producing per-pixel anomaly maps.The discriminative sub-network produces a high-fidelity per-pixel detection map without relying on the related approaches’ surrogate generative tasks.
2. Related work
Related work includes image- and feature-space reconstruction, distributional one-class modeling, and patch-based one-class classification. These approaches generally model anomaly-free data, often under assumptions that are problematic for diverse or subtle surface anomalies.
- Reconstruction methods: Image-space methods use autoencoders or GANs trained on anomaly-free images, then score anomalies using reconstruction quality, reconstruction error, or discriminator output.These methods model images that fit the training distribution and infer anomalies from deviations during testing.
- Feature-space methods: Feature-space reconstruction methods assume pretrained-network features of anomalies will not be faithfully reconstructed by networks trained only on anomaly-free images.Other methods fit a Gaussian to anomaly-free features and detect significant deviations.
- Distributional assumptions: Gaussian feature models require a unimodal anomaly-free feature distribution, an assumption described as problematic on diverse datasets.A one-class variational autoencoder is also reported as sensitive to subtle anomalies near the normal sample distribution.
- One-class classification: Patch-based one-class classification methods estimate a boundary around anomaly-free data, but their unimodal-distribution assumption is often violated in surface anomaly data.The boundary is intended to separate anomaly-free patches from anomalous samples.
3. DRÆM
DRÆM combines anomaly-free reconstruction with a discriminative network that learns from simulated anomalies to localize defects directly. Its joint use of original and reconstructed appearances supports learned anomaly scoring without hand-crafted similarity measures.
- 3. DRÆM: DRÆM uses reconstructive and discriminative sub-networks to learn a joint reconstruction-anomaly embedding and produce anomaly segmentation maps.The reconstructive network restores anomalous regions with plausible normal content, while the discriminative network analyzes the original and reconstructed images together.
- 3.1. Reconstructive sub-network: The reconstructive encoder-decoder learns to recover the original image from an artificially corrupted image while preserving non-anomalous regions.Its reconstruction objective combines patch-based SSIM with l2 loss, weighted by λ.
- 3.2. Discriminative sub-network: The discriminative network concatenates the input and reconstruction, learns an anomaly-specific distance measure, and outputs an anomaly score map using Focal Loss.This avoids hand-crafted similarity functions such as SSIM for anomaly-map construction and improves robustness on hard segmentation examples.
- 3.3. Simulated anomaly generation: DRÆM simulations generate just-out-of-distribution training anomalies rather than reproducing target-domain anomaly appearances realistically.Perlin noise creates binary masks, unrelated texture sources are augmented and blended, and the simulator produces original images, simulated anomalies, and pixel-perfect masks.
- 3.4. Surface anomaly localization and detection: The model produces pixel-level anomaly masks, smooths them with a mean filter, and estimates the image-level anomaly score from the maximum smoothed response.A preliminary classification network did not improve over this direct score-estimation method.
4. Experiments
Experiments evaluate DRÆM on MVTec for image-level detection and pixel-level localization, then analyze its components and compare it with supervised methods on DAGM. DRÆM achieves state-of-the-art performance across MVTec classes, with especially strong localization and competitive supervised comparisons.
- MVTec evaluation: DRÆM achieves state-of-the-art quantitative results across all MVTec classes for surface anomaly detection and localization.Qualitative masks are described as detailed and closely resembling the ground-truth labels.
- Surface anomaly detection: DRÆM achieves the highest AUROC in 9 of 15 MVTec classes and surpasses the previous best approach by 2.5 percentage points.Performance is comparable in the remaining classes; particularly difficult anomalies include missing object parts.
- Anomaly localization: DRÆM surpasses the MVTec localization state of the art by 13.4 percentage points in AP and improves AP in 11 of 15 classes.Its AUROC is comparable to previous best-performing methods, while qualitative comparisons show improved anomaly segmentation accuracy.
- Ablation study: Removing the reconstructive sub-network reduces performance because the discriminative sub-network overfits simulated anomalies that do not faithfully represent real anomalies.Replacing the DRÆM backbone with a recent supervised discriminative network also causes a substantial performance drop.
- Ablation study: DRÆMcolor achieves state-of-the-art results using homogeneous randomly colored regions, suggesting simulations need not closely match real anomalies.The ablation study also evaluates architecture, anomaly appearance patterns, and low-perturbation example generation.
- Comparison with supervised methods: On DAGM, DRÆM significantly outperforms unsupervised and weakly supervised methods, approaches fully supervised classification performance, and exceeds all supervised methods in localization accuracy.Coarse elliptical labels containing background impair supervised localization, whereas DRÆM does not use those labels.
5. Conclusion
DRÆM is an end-to-end discriminative method for surface anomaly detection and localization. It improves over state-of-the-art performance on MVTec and approaches or exceeds supervised methods on DAGM, despite training without real anomalies.
- DRÆM improves over the MVTec state of the art by 2.5 AUROC points for detection and 13.5 AP points for localization.
- On DAGM, DRÆM achieves anomalous-image classification accuracy close to fully supervised methods while outperforming them in localization accuracy.
- DRÆM performs strongly without training on real anomalies.Its results are obtained using a joint reconstruction-anomaly embedding and simple simulations rather than learning normality or real anomaly appearance.