Abstract
Anomaly detection is commonly pursued as a one-class classification problem, where models can only learn from normal training samples, while being evaluated on both normal and abnormal test samples. Among the successful approaches for anomaly detection, a distinguished category of methods relies on predicting masked information (e.g. patches, future frames, etc.) and leveraging the reconstruction error with respect to the masked information as an abnormality score. Different from related methods, we propose to integrate the reconstruction-based functionality into a novel self-supervised predictive architectural building block. The proposed self-supervised block is generic and can easily be incorporated into various state-of-the-art anomaly detection methods. Our block starts with a convolutional layer with dilated filters, where the center area of the receptive field is masked. The resulting activation maps are passed through a channel attention module. Our block is equipped with a loss that minimizes the reconstruction error with respect to the masked area in the receptive field. We demonstrate the generality of our block by integrating it into several state-of-the-art frameworks for anomaly detection on image and video, providing empirical evidence that shows considerable performance improvements on MVTec AD, Avenue, and ShanghaiTech.
Introduction
Anomaly detection presents a unique challenge in machine learning: identifying "abnormal" data when only "normal" examples are available for training. A standard approach is reconstruction-based detection, which assumes that a model trained on normal data will fail to accurately reconstruct anomalous features. However, deep neural networks often generalize too well, sometimes reconstructing anomalies with high fidelity and thus obscuring them.
To address this, we introduce the Self-Supervised Predictive Convolutional Attentive Block (SSPCAB). Unlike traditional methods that apply reconstruction tasks at the input level, SSPCAB is a "plug-and-play" architectural component that can be integrated into any stage of a neural network. It forces the model to learn the structural rules of normality by reconstructing masked-out local information using only the surrounding context.
The SSPCAB Framework
The SSPCAB architecture is designed to perform a "cloze test" (fill-in-the-blank) at the feature level. It consists of three primary components:
- Masked Dilated Convolution: The block utilizes a custom convolutional kernel where the center area is masked (set to zero). This "donut" kernel ensures the model cannot simply copy the center pixel; it must rely on the surrounding neighborhood to predict the missing information. Dilation allows the model to adjust the spatial extent of the context it considers.
- Channel Attention Module: Following the convolution, activation maps pass through a Squeeze-and-Excitation module. This prevents simple linear interpolation and forces the network to selectively emphasize feature maps based on global context, leading to more sophisticated reconstructions.
- Self-Supervised Loss: The block incorporates its own Mean Squared Error (MSE) loss ($\\mathcal{L}_{SSPCAB}$), comparing the predicted center to the actual ground truth. This objective guides the network to internalize the structural patterns of normal data during training.
Experimental Results
We evaluated the SSPCAB by integrating it into several state-of-the-art frameworks across major benchmarks, including MVTec AD (industrial inspection), Avenue (video surveillance), and ShanghaiTech (complex video scenes).
Image-Based Anomaly Detection
On the MVTec AD dataset, adding SSPCAB to the DRAEM model improved the Average Precision (AP) for localization from 68.4% to 69.9%. The block proved particularly effective at identifying fine-grained defects across diverse object and texture categories, as shown in the table below.
Video-Based Anomaly Detection
The performance gains were even more pronounced in video datasets. On the Avenue dataset, integrating SSPCAB boosted the Region-Based Detection Criterion (RBDC) from 41% to 62%. The block's efficiency is a key advantage; it adds only 0.2 to 0.3 milliseconds to inference time, making it suitable for real-time surveillance applications.
Conclusion
SSPCAB offers a versatile and efficient way to enhance anomaly detection by embedding self-supervised reconstruction tasks directly into the network architecture. By moving reconstruction from the pixel level to the feature level, the model learns high-level structural relationships that are more robust for identifying anomalies. Future work will explore extending this concept to 3D masked convolutions for better temporal modeling in video and adapting the block for other domains like audio or sensor data.
Summary updated