Dual-Constraint Autoencoder and Adaptive Weighted Similarity Spatial Attention for Unsupervised Anomaly Detection
Ruifan Zhang, Hao Wang, M.Q. Feng, Yikun Liu, Gongping Yang
Abstract
Image reconstruction-based methods with autoencoder have been widely used for unsupervised anomaly detection. By training the reconstruction on normal samples, autoencoder is supposed to produce higher reconstruction error for anomalous samples, which is used as an indicator for detecting anomalies. However, since autoencoder adopts the bottleneck layer to reconstruct data, it is hard to control its generalization capability. When the generalization capability is high, anomalous features can be confused with normal features, resulting in accurate reconstruction of anomalous regions as well. In this article, we propose a dual-constraint autoencoder to alleviate the problem of feature confusion through the dual constraint of adversarial learning and global memory bank. Given a sample pair consisting of a normal sample and a synthetic anomaly sample generated from it as input, the proposed autoencoder first forces the encoding of the synthetic anomaly image to be close to the normal encoding by adversarial learning. Then, the synthetic anomaly encoding is rerepresented with items in memory bank, which records normal features that facilitate image restoration, and the new feature is fed to the decoder for image inpainting. Under such constraints, the generalization capability of the autoencoder is suppressed and will not reconstruct the anomaly region well. After that, we feed the synthetic anomaly image together with the repaired image into the proposed adaptive weighted similarity spatial attention-based U-Net and produce an accurate anomaly map with the help of our proposed adaptive weighted similarity spatial attention. Results on the a comprehensive real-world dataset for unsupervised anomaly detection (MVTec AD) dataset and the beanTech anomaly detection dataset dataset show that our framework achieves state-of-the-art performance.