TL;DR
This paper introduces Pyramid-based Mamba (Pyramid-Mamba), a novel unsupervised anomaly detection and localization method that effectively addresses the challenge of detecting small anomalies. By combining the long-range dependency modeling of Mamba with a multi-scale pyramidal scanning strategy and a context-aware state space module, Pyramid-Mamba achieves state-of-the-art performance on the MVTec-AD dataset.
What Problem Does This Paper Address?
Visual anomaly detection (AD) is crucial for quality control, safety, and security in various industries. The core challenge lies in accurately identifying and pinpointing anomalies, especially small ones, within images. Traditional Convolutional Neural Networks (CNNs) struggle with capturing long-range dependencies, while Transformer-based methods, despite their ability to model global context, suffer from high computational costs, limiting their application to smaller feature maps. Existing methods often fall into categories like reconstruction-based (which can inadvertently reconstruct anomalies), synthesizing-based (struggling with realistic defect generation), or embedding-based (sensitive to domain shifts). This paper aims to bridge this gap by developing an efficient and accurate method for multi-class unsupervised anomaly detection and localization that excels at capturing both fine-grained local details and broad contextual information across multiple scales.
Methods
The proposed Pyramid-Mamba method is built upon a novel architecture that integrates several key components:
- Pre-trained Encoder: A ResNet34 encoder is used to extract multi-scale features from input images.
- Synthetic Anomaly Generator: To address the scarcity of anomalous data during training, synthetic anomalies are generated and added to the normal training images.
- Pyramid-based Mamba Decoder: This is the core of the proposed method. It consists of:
- Context-aware State Space (CSS) Module: This module combines the strengths of both global and local feature extraction. It integrates Mamba for long-range dependency modeling with convolutional layers for capturing local spatial features.
- Pyramidal Scanning Strategy (PSS): This strategy recursively applies a Selective Scan Module (SSM) across multiple scales of the input feature maps. By downscaling the image and processing each sub-region, PSS enables the capture of both coarse and fine-grained spatial dependencies, crucial for detecting anomalies of varying sizes.
- Locality-Enhanced Convolutional (LEC) Blocks: These blocks use depth-wise convolutions with different kernel sizes to extract local features efficiently, complementing the global context captured by PSS.
- Multi-Scale Feature Fusion (MFF): Features from different pyramid levels are fused to create a comprehensive representation.
- Loss Function: The model is trained by minimizing the reconstruction error between the encoder's features and the decoder's reconstructions across multiple scales.
Datasets
The primary dataset used for training and evaluation is the MVTec-AD dataset. This dataset comprises 5354 images across 15 different object classes, including both defect-free training images and test images with various types of anomalies. The dataset is widely used for benchmarking anomaly detection and localization methods.
Key Insights and Ideas
- Multi-scale processing is key for small anomaly localization: The paper strongly emphasizes that capturing anomalies at different granularities is essential for precise localization, especially for small defects. The pyramidal scanning strategy directly addresses this.
- Mamba's efficiency for long-range dependencies is beneficial: By leveraging Mamba, the method achieves efficient modeling of long-range dependencies without the quadratic complexity of Transformers, making it computationally feasible.
- Combining global and local feature extractors is powerful: The CSS module's integration of Mamba (global) and convolutional layers (local) provides a more robust feature representation than either approach alone.
- Synthetic anomalies can effectively augment training data: The use of synthetic anomalies helps overcome the challenge of limited anomalous samples during training, leading to improved generalization.
Key Results
- State-of-the-art performance: Pyramid-Mamba achieves competitive performance on the MVTec-AD dataset, demonstrating superior anomaly detection and localization.
- Improved metrics: The method achieved a +1% improvement in Average Precision (AP) for multi-class anomaly localization and a +1% increase in AU-PRO on the MVTec benchmark compared to previous state-of-the-art methods.
- Robustness across classes: The model shows strong performance across various object classes, with perfect detection scores in several categories.
- Enhanced localization: Significant improvements in localization metrics, particularly for challenging classes like Hazelnut and Metal Nut, highlight the effectiveness of the hierarchical structure.
- Ablation studies confirm component importance: Removing global features (Xg) led to a noticeable drop in performance, while removing local features (Xc,k) also resulted in degradation, confirming the necessity of both.
- Pyramid levels impact performance: Using two pyramid levels consistently enhanced F1max scores across most categories compared to a single level or no pyramid structure.
Limitations and Future Work
- Limitations: The paper acknowledges that while the method is effective, it still relies on a pre-trained encoder and a synthetic anomaly generator. The performance can drop when the pyramid and noise are not jointly considered, indicating potential vulnerabilities in localization tasks without considering perturbations and multiple feature scales.
- Future Work: The paper suggests that the effectiveness of the pyramid levels and the joint consideration of noise and pyramid processing warrant further investigation. Exploring different encoder architectures and more sophisticated synthetic anomaly generation techniques could also be future directions.
Summary updated