MambaAD: Exploring State Space Models for Multi-class Unsupervised Anomaly Detection

Haoyang He,Yuhu Bai,Jiangning Zhang,Qingdong He,Hongxu Chen,Zhenye Gan,Chengjie Wang,Xiangtai Li,Guanzhong Tian,Lei Xie
2024-04-14
Abstract:Recent advancements in anomaly detection have seen the efficacy of CNN- and transformer-based approaches. However, CNNs struggle with long-range dependencies, while transformers are burdened by quadratic computational complexity. Mamba-based models, with their superior long-range modeling and linear efficiency, have garnered substantial attention. This study pioneers the application of Mamba to multi-class unsupervised anomaly detection, presenting MambaAD, which consists of a pre-trained encoder and a Mamba decoder featuring (Locality-Enhanced State Space) LSS modules at multi-scales. The proposed LSS module, integrating parallel cascaded (Hybrid State Space) HSS blocks and multi-kernel convolutions operations, effectively captures both long-range and local information. The HSS block, utilizing (Hybrid Scanning) HS encoders, encodes feature maps into five scanning methods and eight directions, thereby strengthening global connections through the (State Space Model) SSM. The use of Hilbert scanning and eight directions significantly improves feature sequence modeling. Comprehensive experiments on six diverse anomaly detection datasets and seven metrics demonstrate state-of-the-art performance, substantiating the method's effectiveness.
Computer Vision and Pattern Recognition
What problem does this paper attempt to address?
### What problem does this paper attempt to solve? This paper aims to address several key issues in Multi-class Unsupervised Anomaly Detection (MUAD): 1. **Limitations of existing methods**: - Most current anomaly detection methods primarily use a single-class setup, where a model is trained and tested separately for each class, leading to significant increases in training and memory consumption. - Although some multi-class anomaly detection techniques have been introduced recently, there is still considerable room for improvement in terms of accuracy and efficiency. 2. **Advantages and disadvantages of different methods**: - Embedding-based and Synthesizing-based methods perform well in anomaly detection but are complex in design and inflexible in framework. - Reconstruction-based methods like RD4AD and UniAD offer better performance and scalability, but the former lacks long-range dependency modeling capabilities, and the latter is constrained by high computational complexity. 3. **Advantages of the Mamba model**: - Recently, the Mamba model has shown excellent performance in large-scale language models, with linear complexity significantly lower than Transformer models while maintaining similar effectiveness. - The application of the Mamba model in the visual domain is also increasing, demonstrating strong potential. ### Main Contributions The paper proposes MambaAD, a multi-class unsupervised anomaly detection method based on the Mamba model, with the following specific contributions: 1. **Innovative application of the Mamba framework**: - For the first time, the Mamba framework is applied to the multi-class unsupervised anomaly detection task, achieving multi-scale training and inference while maintaining low model parameters and computational complexity. 2. **Locally Enhanced State Space Module (LSS)**: - A Locally Enhanced State Space Module (LSS) is designed, combining cascaded Mamba blocks and parallel multi-core convolution operations to extract global feature correlations and local information associations, achieving a unified model of global and local patterns. 3. **Hybrid State Space Block (HSS)**: - A Hybrid State Space Block (HSS) is explored, containing five scanning methods and multi-directional scanning in eight directions, enhancing the global modeling capability for complex anomaly detection images. 4. **Experimental results**: - Comprehensive experiments were conducted on six different anomaly detection datasets, with seven evaluation metrics showing current best performance while maintaining low model parameters and computational complexity. Through these contributions, MambaAD demonstrates superior performance and efficiency in multi-class anomaly detection tasks, providing a new solution for industrial visual anomaly detection.