Abstract
Traditional unsupervised anomaly detection models require thousands of normal samples to learn the distribution of a specific product, creating a significant bottleneck when introducing new production lines. This paper proposes a few-shot anomaly detection framework using a Multi-Level Variational Autoencoder (MLVAE). By disentangling domain-wide "content" from sample-specific "style," the model can adapt to new product types using as few as 1–10 samples without retraining. Experimental results on industrial datasets demonstrate superior accuracy and localization compared to standard generative models.
Introduction
In industrial manufacturing, identifying defective products is critical for quality assurance. However, the high variability between different product types often causes standard anomaly detection models to fail when applied to a new domain; the model frequently flags the novel design itself as an anomaly rather than actual defects. To overcome this, we address the challenge of few-shot anomaly detection, where a model pre-trained on various "source" domains can be quickly specialized to a "target" domain using a minimal reference set.
Methodology: Multi-Level Variational Autoencoders
The core of the proposed approach is the Multi-Level Variational Autoencoder (MLVAE). Unlike standard VAEs that compress images into a single latent vector, the MLVAE architecture splits the latent space into two distinct components:
- Content ($c_G$): Captures features common to a group of samples, representing the "domain" or "product type."
- Style ($s_i$): Captures features unique to an individual sample, representing specific details and potential deviations.
Workflow
- Training: The model is trained across multiple source domains to learn how to extract domain-wide essence into the content variable and individual variations into the style variable.
- Inference and Adaptation: Upon encountering a new product type, a small group of target samples (e.g., 10 images) is encoded to estimate a shared content variable. This "re-centers" the model's understanding of "normal" for the new domain without updating any weights.
- Detection: Anomaly scores are calculated based on reconstruction error. If a sample cannot be accurately reconstructed using the estimated domain content and its own style, it is flagged as an anomaly.
Experimental Evaluation
The framework was evaluated on three datasets: SVHN, CIFAR-10, and a real-world Factory Roof Dataset. The latter contains high-resolution aerial images of chemical factories where the objective is to detect rust. Each factory serves as a distinct domain due to varying roof textures and structures.
Key Results and Discussion
The MLVAE approach demonstrated significant improvements over baseline Autoencoders (AE) and Variational Autoencoders (VAE):
- Accuracy: On the Factory Roof dataset, MLVAE achieved a ROC-AUC of 0.972, outperforming VAE (0.948) and AE (0.901).
- Localization: Qualitative analysis shows that MLVAE provides much cleaner anomaly maps. While standard models often produce false positives due to unfamiliar textures in a new domain, MLVAE accurately isolates specific defects like rust.
- Robustness: The method remains effective even if the small reference set contains a few anomalous samples. Tests showed that with 1 or 2 defective samples in a group of 10, the model still outperformed standard VAEs.
- Statistical Separation: Using the Wasserstein distance to measure the gap between "normal" and "anomalous" score distributions, the MLVAE consistently showed wider gaps than traditional models, indicating a much clearer "line in the sand" for detection.
- Threshold Portability: MLVAE exhibits a smaller performance gap when applying thresholds derived from source data to target data, enhancing its reliability for deployment.
Conclusion
By leveraging disentangled representations, the MLVAE-based few-shot anomaly detection framework successfully adapts to new industrial domains with minimal data. This approach effectively mitigates the data-hungry nature of traditional quality control systems. Future work will explore the limits of domain similarity and the scalability of the approach to even smaller group sizes.
Summary updated