TL;DR
This paper introduces MSFlow, a novel multi-scale flow-based framework for unsupervised anomaly detection and localization. It addresses the challenge of varying anomaly sizes by effectively fusing information from different feature map scales, achieving state-of-the-art results on challenging benchmarks.
What Problem Does This Paper Address?
Unsupervised Anomaly Detection (UAD) aims to identify anomalies in data when only normal samples are available for training. A key challenge in UAD, especially for industrial defect detection, is not only detecting anomalies but also precisely locating them. While normalizing flows have shown promise in UAD by modeling the probability distribution of normal data, they struggle with anomalies of varying sizes. This size variation makes it difficult for flow-based models to accurately pinpoint anomalies, especially when they range from tiny defects to large structural deformations. Existing methods often fail to generalize well across this spectrum of anomaly sizes.
Methods
The proposed MSFlow framework tackles the anomaly size variation problem through a multi-scale approach:
- Multi-scale Feature Pyramid Extraction: Instead of relying on traditional image pyramids or high-level, low-resolution features, MSFlow extracts feature maps from the early stages of a pre-trained feature extractor (like ResNet or WideResNet). These lower-level features retain more spatial details, which are crucial for pixel-wise localization. These multi-scale features are then downsampled using average pooling to create a feature pyramid.
- Multi-scale Flow Model: This is the core of MSFlow. It consists of:
- Asymmetrical Parallel Flows: Each feature map in the pyramid is processed by its own dedicated flow network. These parallel flows are designed asymmetrically, meaning higher-level feature maps (with more channels) have more flow blocks. This allows for efficient encoding of intrinsic properties at each scale.
- Fusion Flow: A novel fusion flow module is introduced to exchange information across these different scales. This module effectively bridges the gap between low-level detailed features and high-level semantic features, enabling a more comprehensive understanding of anomalies.
- Multi-scale Outputs Aggregation: Different strategies are employed for image-wise detection and pixel-wise localization. For localization, an additive aggregation of multi-scale likelihood maps is used to preserve details. For image-wise detection, a multiplicative aggregation is used to suppress noise. The final image-wise anomaly score is derived from the mean of the top-K anomaly scores, which is shown to be more robust than simply taking the maximum or mean.
Datasets
The paper evaluates MSFlow on the following datasets:
- MVTec AD Benchmark: A widely-used dataset for industrial defect detection and localization, containing 15 classes of objects and textures with varying defect types and sizes.
- Magnetic Tile Defects (MTD) Dataset: A specialized dataset for tile defect detection.
- mini Shanghai Tech Campus (mSTC) Dataset: A non-image dataset used for video violation detection, treating violations as anomalies.
Key Insights and Ideas
- Low-level features are key for localization: The paper demonstrates that using feature maps from earlier stages of a CNN, which retain more spatial detail, significantly improves pixel-wise anomaly localization compared to using only high-level features.
- Asymmetrical flow architecture balances performance and efficiency: By assigning more flow blocks to feature maps with more channels, the framework achieves better performance without a proportional increase in computational cost.
- Fusion flow is crucial for cross-scale information exchange: The novel fusion flow module effectively integrates information from different scales, leading to improved generalization for anomalies of varying sizes.
- Top-K mean for robust anomaly scoring: Using the mean of the top-K anomaly scores for image-wise detection is more robust to noise and sensitive to small anomalies compared to traditional maximum or mean-based approaches.
- Layer Normalization stabilizes training and improves performance: The inclusion of layer normalization within the flow blocks is shown to enhance both detection and localization accuracy, particularly the PRO score.
Key Results
MSFlow achieves state-of-the-art performance on the MVTec AD benchmark:
- Image-wise Anomaly Detection: Achieved an AUCROC score of 99.7%.
- Pixel-wise Anomaly Localization: Achieved an AUCROC score of 98.8% and a PRO score of 97.1%.
- The method also demonstrates strong performance on the MTD and mSTC datasets, highlighting its generality.
- MSFlow is computationally efficient, costing less than half the training time of previous methods.
Limitations and Future Work
- Sensitivity to very small defects: While MSFlow excels at handling varying anomaly sizes, the paper notes a slight performance degradation on detecting extremely small defects (like those in screw products) when using the fusion flow, potentially due to the large receptive field. This suggests a trade-off between detecting large structural anomalies and minute surface defects.
- Future work could explore: Further optimizing the fusion flow for different types of defects and investigating more advanced feature extraction strategies. The paper also suggests that the framework's flexibility makes it suitable for other anomaly detection tasks beyond industrial defects.
Summary updated