MSFlow: Multi-Scale Flow-based Framework for Unsupervised Anomaly Detection

Yixuan Zhou, Xing Xu, Jingkuan Song, Fumin Shen, Heng Tao Shen

Abstract

Unsupervised anomaly detection (UAD) is a critical task where only anomaly-free samples are available for training. A significant challenge in UAD is the size variation of unpredictable anomalies, which complicates high-precision detection and localization. We propose MSFlow, a novel Multi-Scale Flow-based framework featuring asymmetrical parallel flows and a fusion flow for multi-scale perception exchange. MSFlow employs distinct aggregation strategies for image-wise detection and pixel-wise anomaly localization. Evaluated on major benchmarks, MSFlow achieves state-of-the-art performance, notably reaching a 99.7% detection AUCROC on the MVTec AD dataset.

Introduction

In industrial quality control, defects are rare and unpredictable, making supervised learning impractical. Unsupervised Anomaly Detection (UAD) addresses this by training models solely on "normal" samples to learn their distribution and flag deviations. However, UAD faces a major hurdle: scale variation. Anomalies can range from microscopic scratches to large-scale structural misplacements. Existing methods often struggle to balance these extremes, failing to either pinpoint exact locations or detect anomalies of varying sizes across different products.

Methods: The MSFlow Architecture

MSFlow (Multi-Scale Flow) leverages Normalizing Flows (NF)—probabilistic models that map complex data distributions to a simple Gaussian distribution. The framework introduces several key innovations to handle multi-scale features effectively.

The MSFlow architecture featuring asymmetrical parallel flows and a fusion mechanism for multi-scale anomaly detection.

Multi-Scale Feature Pyramid

Instead of relying solely on high-level semantic features that lose spatial detail, MSFlow extracts features from the first three stages of a pre-trained backbone (e.g., ResNet-18). These features are downsampled via average pooling to maintain a balance between detail and computational efficiency.

Asymmetrical Parallel and Fusion Flows

The model processes different scales in parallel using an asymmetrical number of flow blocks—allocating more blocks to higher-level features with more channels. The Fusion Flow acts as the connective tissue, allowing different scales to exchange information and providing the model with context across resolutions.

Robust Aggregation Strategies

To determine if an image is anomalous, MSFlow uses Top-$K$ Aggregation, calculating the mean of the $K$ highest anomaly scores in the pixel-wise map. This approach is more robust than using a single maximum value or a global mean. Furthermore, the authors found that adding multi-scale probability maps is optimal for localization, while multiplying them enhances detection by suppressing noise.

Results and Discussion

MSFlow was evaluated on the MVTec AD, Magnetic Tile Defects (MTD), and mini Shanghai Tech Campus (mSTC) datasets. On the industry-standard MVTec AD benchmark, MSFlow set new state-of-the-art records.

Visual examples of anomaly localization across various classes in the MVTec AD dataset, demonstrating MSFlow's ability to handle different scales.
  • Detection Performance: Achieved a record 99.7% AUCROC, surpassing previous leaders like PatchCore.
  • Localization Precision: Reached a 98.8% AUCROC and a 97.1% PRO score, indicating high accuracy across both small and large defects.
  • Efficiency: The "FuseFlow" variant reduced computational costs (GFLOPs) by 93% compared to previous cross-scale flow methods like CSFlow, without compromising accuracy.

Conclusion

MSFlow demonstrates that integrating multi-scale perceptions through asymmetrical parallel flows and a fusion mechanism significantly improves unsupervised anomaly detection. While highly effective, the model faces challenges with extremely minute, consistent defects (e.g., in the "screw" class), where the expanded receptive field of the fusion mechanism can occasionally overshadow tiny anomalies. Future research will focus on adaptive fusion mechanisms to further refine detection across all anomaly scales.

Summary updated

BibTeX
@article{zhou2025msflow,
  author = {Yixuan Zhou and Xing Xu and Jingkuan Song and Fumin Shen and Heng Tao Shen},
  title = {{MSFlow: Multi-Scale Flow-based Framework for Unsupervised Anomaly Detection}},
  journal = {IEEE Trans. Neural Networks Learn. Syst.},
  year = {2025},
  doi = {10.1109/tnnls.2023.3344118},
}
Figure