Source-linked AI summary
Iterative energy-based projection on a normal data manifold for anomaly localization
David Dehaene, Oriel Frigo, Sébastien Combrexelle, Pierre Eline
TL;DR
Unsupervised anomaly localization must identify rare or unseen defects from normal samples, yet local defects can globally corrupt autoencoder reconstructions. The paper iteratively updates the input by gradient descent on an autoencoder-derived energy, achieving improved localization across datasets and retaining higher-frequency structure.
Problem
Local defects can deteriorate an entire autoencoder reconstruction, making pixel-level anomaly localization difficult when training uses only normal data.
Method
The method iteratively updates the input using gradient descent on an autoencoder reconstruction-loss energy, with regularization terms for desired projections and pixel-wise error modulation.
Results
The method improves anomaly-localization AUC values for almost all tested autoencoder variants, with a mean improvement rate of 9.52% across datasets and baselines.
Takeaways & Limitations
Input-space optimization produces higher-quality projections that preserve normal high-frequency structures and supports anomaly localization and CelebA inpainting.
Takeaways & Limitations
The projection assumes anomalies alter one or more pixel regions while leaving the remaining pixels untouched, approximating an L0 objective with L1 regularization.
Abstract
from arXiv · showhide
Autoencoder reconstructions are widely used for the task of unsupervised anomaly localization. Indeed, an autoencoder trained on normal data is expected to only be able to reconstruct normal features of the data, allowing the segmentation of anomalous pixels in an image via a simple comparison between the image and its autoencoder reconstruction. In practice however, local defects added to a normal image can deteriorate the whole reconstruction, making this segmentation challenging. To tackle the issue, we propose in this paper a new approach for projecting anomalous data on a autoencoder-learned normal data manifold, by using gradient descent on an energy derived from the autoencoder's loss function. This energy can be augmented with regularization terms that model priors on what constitutes the user-defined optimal projection. By iteratively updating the input of the autoencoder, we bypass the loss of high-frequency information caused by the autoencoder bottleneck. This allows to produce images of higher quality than classic reconstructions. Our method achieves state-of-the-art results on various anomaly localization datasets. It also shows promising results at an inpainting task on the CelebA dataset.
1 INTRODUCTION
Unsupervised anomaly localization uses only non-defective data to segment previously unseen defects, but autoencoder or VAE reconstructions can become globally poor from local perturbations. The paper therefore projects inputs onto a learned normal manifold by optimizing an autoencoder-derived energy.
- Motivation: Unsupervised anomaly detection segments defects using prior knowledge of non-defective samples rather than predefined defect categories.This addresses rare defects and previously unseen defect types on production lines.
- Background: Generative models such as VAEs are attractive because they can infer possible sampling mechanisms for a dataset.The autoencoder compresses inputs into a low-dimensional space and reconstructs them through a decoder.
- Problem: Autoencoder-based localization relies on comparing an input with its reconstruction, but model behavior outside the normal manifold is not guaranteed to remain useful.A local perturbation can produce a globally poor reconstruction, making anomaly segmentation challenging.
- Approach: The proposed method optimizes an autoencoder-defined energy from the input sample to find a nearby projection on the normal manifold.Regularization terms can incorporate priors about the desired projection.
2 BACKGROUND
Generative models provide reconstruction-based tools for anomaly detection and localization, but their objectives and reconstruction behavior impose important trade-offs. The background introduces VAEs, reconstruction losses, pixel-wise anomaly scoring, and latent-space projection methods such as AnoGAN.
- Generative models: Generative models estimate the distribution of normal data so new samples can be generated near the dataset.GANs use generators driven by low-dimensional noise, while VAEs use latent variables and conditional decoder distributions.
- Generative models: GANs are difficult to train and may suffer mode collapse, generating only a subset of the original dataset.This is problematic when omitted normal modes could be treated as anomalous.
- VAE: A VAE uses an encoder distribution q(z|x) and decoder distribution p(x|z) with a latent prior p(z) to approximate the dataset distribution.Its training objective is obtained through importance sampling and Jensen’s inequality, yielding a variational lower bound.
- VAE: The deterministic VAE reconstruction encodes an input, decodes the mean latent representation, and takes the mean decoded output.The paper denotes the training loss by L(x).
- Reconstruction trade-offs: VAEs are known to produce blurry reconstructions, whereas modeling decoded variance can improve image quality at the cost of poorer prior-sampled generation quality.The described enhancement uses a second VAE trained on samples from the encoder’s latent distribution.
- Localization methods: Pixel-wise reconstruction error supports anomaly localization, while AnoGAN searches for an input-nearest generated image by gradient descent on its latent code.AnoGAN combines input-image distance with discriminator-feature distance to keep generated images near the dataset distribution.
- Paper method: The paper illustrates its approach as gradient descent on E(x_t) to iteratively correct x_t.This contrasts with latent-code optimization in AnoGAN.
3 PROPOSED METHOD
The method iteratively updates anomalous inputs using loss gradients to project them onto a learned normal manifold while preserving proximity and enabling anomaly-specific regularization. Pixel-wise reconstruction errors further focus updates on poorly reconstructed regions and preserve already-correct details.
- The method uses loss gradients to iteratively improve an observed input rather than relying solely on standard autoencoder reconstruction.
- Starting from an anomalous sample, gradient descent minimizes an energy balancing normal-manifold membership against proximity to the original input.The energy uses reconstruction loss and an L1 regularizer weighted by λ.
- The optimization assumes anomalies alter limited pixel regions and therefore seeks the closest normal-manifold image under a sparsity-inspired regularization.The ideal regularizer is L0 distance, approximated because L0 is nondifferentiable.
- Unlike latent-space optimization in AnoGAN, the method optimizes directly in input space to retain image details that autoencoder reconstructions may discard.The authors cite limitations of the latent prior and loss of original-image detail as reasons for avoiding latent-space iteration.
- For unknown anomaly masks, pixel-wise reconstruction error estimates where updates should occur, accelerating convergence and protecting well-reconstructed pixels.This modification reaches the same performance with fewer iterations than the unweighted gradient update.
- The method can stop when the energy converges or when reconstruction loss reaches a threshold, such as a training-loss quantile.
4 EXPERIMENTS
The experiments evaluate iterative reconstruction for anomaly segmentation on MVTec and inpainting on CelebA. Across autoencoder baselines, the method improves segmentation overall and produces more convincing inpaintings in the reported visual comparison.
- The evaluation covers anomaly segmentation and image inpainting, both requiring reconstruction of corrupted images while preserving uncorrupted regions.
- 4.1 UNSUPERVISED ANOMALY SEGMENTATION: MVTec experiments train on normal samples and test on normal and anomalous samples across 15 object and texture categories.
- 4.1 UNSUPERVISED ANOMALY SEGMENTATION: The study compares four autoencoder baselines—L2AE, DSAE, VAE, and γ-VAE—and computes segmentation using DSSIM between original and reconstructed images.The gradient-descent setup uses α := 0.5, λ := 0.05, and stops below the minimum training reconstruction loss.
- 4.1 UNSUPERVISED ANOMALY SEGMENTATION: 9.52% mean improvement rate and 4.33% median improvement rate are reported across MVTec datasets and autoencoder baselines.The 25th and 75th percentiles are 1.86% and 15.86%, respectively.
- 4.1 UNSUPERVISED ANOMALY SEGMENTATION: The proposed reconstruction visually refines anomaly localization compared with the L2 autoencoder, using a common DSSIM anomaly-map threshold of 0.2.
- 4.2 INPAINTING: On CelebA inpainting, gradient-based VAE reconstruction is reported as more convincing than baseline VAE reconstruction under uniform-noise masking.Regular inpainting multiplies gradients by the known mask, whereas blind inpainting uses an unknown mask.
5 RELATED WORK
Prior work uses reconstruction distances, structural similarity, perceptual metrics, or loss gradients for anomaly localization. The proposed method differs from AnoGAN by updating the input image directly, preserving higher-frequency structures and converging faster than latent-code optimization.
- Reconstruction- and metric-based methods: Autoencoder anomaly localization has used per-pixel distances, perceptual metrics, and structural similarity between images and reconstructions.The SSIM autoencoder is trained directly with the structural similarity metric.
- Gradient-based methods: Loss-gradient amplitude can indicate abnormal pixels, but the proposed method integrates the gradient along the path from the input to the normal manifold.The paper compares its results with score-based anomaly localization in appendix A.
- AnoGAN: Unlike AnoGAN, the proposed method updates the input image directly rather than searching for an optimal latent code.The authors state that this enables faster convergence and better preservation of high-frequency input structures.
- AnoGAN: AnoGAN searches for a latent code using gradient descent and uses a discriminator-learned reconstruction loss, which remains prone to mode collapse.The related approach is described as similar to standard VAE reconstruction methods despite its learned reconstruction loss.
6 CONCLUSION
The paper concludes that iterative input-space gradient descent on an autoencoder reconstruction-loss energy supports unsupervised anomaly localization. The method incorporates priors, preserves normal high-frequency structures, and achieves strong results across datasets.
- Method and implications: The method iteratively updates a test sample using gradient descent on an energy defined by autoencoder reconstruction loss.Pixel-wise reconstruction error modulates the updates, producing strong localization results in only a few iterations.
- Method and implications: Input-space optimization incorporates human priors into the desired projection of an out-of-distribution sample onto the normal data manifold.The approach can be added to previously trained autoencoder architectures.
- Method and implications: Input-space updates preserve normal high-frequency structures and reduce pixels wrongly classified as defects when autoencoders produce blurry reconstructions.The conclusion attributes this benefit to overcoming the autoencoder tendency toward blurry reconstructions.
- Results: The method achieves state-of-the-art results across varied unsupervised anomaly localization datasets and produces qualitative reconstructions for an additional task.The supplied conclusion ends before naming that additional task.
A COMPARISON WITH ZIMMERER ET AL. (2019)
This comparison evaluates pixel-wise AUROC scores derived from a baseline VAE against the proposed method and reports that single-gradient VAE approaches are consistently outperformed.
- Compared scores: Table 2 compares pixel-wise anomaly-detection AUROC for reconstruction error, loss gradients, combined scores, KL-divergence gradients, and KL-gradient/error combinations.The comparison uses scores derived from a baseline VAE on MVTec datasets.
- Comparison outcome: The proposed method consistently outperforms other VAE-based methods that evaluate the gradient only once.The comparison uses the same vanilla VAE for all experiments.
B CONVERGENCE SPEED
The convergence-speed experiment tracks mean pixel-wise anomaly-detection AUROC across iterations for standard and tuned gradient-descent updates. The tuned update reaches the standard method’s performance in far fewer iterations.
- Experimental setup: Figure 5 tracks mean pixel-wise anomaly-detection AUROC after each iteration for standard and tuned gradient-descent updates.The experiment uses a learned-variance VAE trained on the Grid dataset.
- Convergence result: The tuned update converges to the standard update’s performance with far fewer iterations.The tuned update uses a gradient mask computed from the VAE reconstruction error.
C ADDITIONAL ANOMALY SEGMENTATION RESULTS
The proposed gradient-based iterative reconstruction improves anomaly segmentation compared with baseline autoencoder reconstructions across multiple autoencoder variants.
- Gradient-based iterative reconstruction improves anomaly segmentation over an L2 autoencoder baseline in the illustrated comparison.
- Augmenting four autoencoder baselines with gradient descent overall improves anomaly segmentation.
D INPAINTING COMPARISON
The paper applies energy optimization to project defective inputs toward the normal manifold while retaining proximity to the original image, and compares the resulting inpainting quality with VAEAC.
- The inpainting comparison reports reconstruction quality for masked inputs using VAEAC, the proposed method, and ground truth.
- Energy optimization starts from a defective input and iteratively moves the sample and reconstruction closer to the normal data manifold.
- A regularization term keeps the optimized sample close to the original defective input.
F DISTRIBUTION OF THE IMPROVEMENT RATE ON MVTEC AD
Across MVTec AD baselines and datasets, the gradient-based projection improves AUC in most cases, with a positive and right-skewed improvement distribution.
- Figure 10 summarizes the AUC improvement-rate distribution across all presented baselines and datasets in MVTec AD.
- 91.7% of data points show increased AUC with the gradient-based projection, while 8.3% show decreased AUC.
- The median AUC improvement rate is 4.33%, with the 25th and 75th percentiles at 1.86% and 15.86%.