Unsupervised Visual Anomaly Detection with Score-Based Generative Model

Yapeng Teng, HaoYang Li, Fuzhen Cai, Ming Shao, Siyu XiaOpenReview 2022

TL;DR

This paper introduces Score-AD, a novel unsupervised method for detecting and localizing visual anomalies in images. It leverages score-based generative models, specifically diffusion models, to identify deviations from normal data distributions. A key innovation is the "T scales" approach, which significantly speeds up inference by sampling information at multiple time steps rather than performing a full reconstruction.

What Problem Does This Paper Address?

Visual anomaly detection (AD) is crucial in many industries, from manufacturing to medical imaging. However, a significant challenge is the rarity of abnormal samples, making it difficult to train supervised models. While unsupervised methods using generative models like Autoencoders and GANs exist, they often struggle with high-dimensional data like images, producing blurry reconstructions or requiring complex architectures. Existing methods also face issues with precisely identifying defects when reconstructed normal images don't perfectly match the originals. This paper aims to address these limitations by proposing a more robust and efficient unsupervised AD method based on score-based generative models.

Methods

The core of Score-AD lies in score-based generative models, particularly diffusion models. The authors draw inspiration from the idea that injecting noise into an image and then reversing this process (denoising) can reveal defects.

  • Score-Based Metric: Instead of relying on direct pixel-wise comparisons between original and reconstructed images (which can be unreliable due to reconstruction imperfections), Score-AD uses the "score" function of the generative model. This score represents the gradient of the log-probability density of the normal data distribution. Anomalous data, by definition, lies in low-probability regions. The model computes two types of scores:
  • Whole-score: This measures the gradient towards the high-density region of the training data.
  • Self-score: This measures the gradient towards the original data point. The divergence between these scores is used to pinpoint anomalies.

  • T Scales Approach: A major bottleneck in diffusion models is the slow inference time, which requires many steps to reconstruct an image. To overcome this, the authors propose the "T scales" approach. Instead of performing a full reverse diffusion process, they sample information from the score model at a set of T different time steps. This allows them to capture essential semantic information without the computational cost of a complete reconstruction. The feature maps from these different time steps are then combined to generate the final anomaly map. This approach leverages the fact that feature maps at adjacent time steps often contain redundant information.

Datasets

The proposed method was evaluated on the following datasets:

  • MVTec AD: A widely used benchmark for unsupervised anomaly detection, containing 5354 high-resolution images of 10 object and 5 texture categories.
  • BeanTech AD: An industrial dataset with 2540 high-resolution images of three products.
  • MNIST: A dataset of 60,000 training and 10,000 test handwritten digit images (28x28 pixels).

Key Insights and Ideas

  • Score as a Defect Indicator: The paper highlights that the score function of a generative model, which points towards high-density regions of normal data, is a more robust metric for anomaly detection than simple pixel-wise reconstruction differences. Anomalies, being in low-density regions, will exhibit a larger deviation when guided by this score.
  • T Scales for Efficiency: The "T scales" approach is a significant contribution for practical deployment. By strategically sampling at multiple time points instead of a full reconstruction, the method achieves a substantial speedup in inference without sacrificing performance. This is based on the observation that feature maps from score models at different diffusion times contain complementary information.
  • Unsupervised Generalization: The method is designed to work in a purely unsupervised manner, trained only on normal data. This makes it applicable to scenarios where anomalies are rare and difficult to obtain for training.

Key Results

Score-AD achieved state-of-the-art (SOTA) results on the MVTec AD dataset, reaching 98.24% image-level AUC and 97.78% pixel-level AUC. It also demonstrated strong performance on the BeanTech AD dataset, achieving 93.4% image-level AUC and 97.1% pixel-level AUC. On the MNIST dataset, it achieved 95.44% image-level AUC. The T scales technique significantly improved inference speed, making it more efficient than other diffusion-based methods.

Limitations and Future Work

The authors acknowledge that the current method's performance can be sensitive to the selection of time steps in the T scales approach. They suggest that an adaptive feature map selection strategy could further improve results and address this limitation. They also mention that while their approach is unsupervised and doesn't rely on pre-trained models, extending it to leverage pre-trained networks or incorporating self-supervised/semi-supervised techniques could be a promising future direction, especially for very large and diverse datasets like MNIST.

Summary updated

BibTeX
@misc{teng2022unsupervised,
  author = {Yapeng Teng and HaoYang LI and Fuzhen Cai and Ming Shao and Siyu Xia},
  title = {{Unsupervised Visual Anomaly Detection with Score-Based Generative Model}},
  year = {2022},
  url = {https://openreview.net/forum?id=j6sAOkvn4GI},
  howpublished = {OpenReview},
}
Figure