Table of Contents
Fetching ...

CostFilter-AD: Enhancing Anomaly Detection through Matching Cost Filtering

Zhe Zhang, Mingxiu Cai, Hanxiao Wang, Gaochang Wu, Tianyou Chai, Xiatian Zhu

TL;DR

CostFilter-AD addresses the persistent issue of matching noise in unsupervised anomaly detection by reframing UAD as a matching cost filtering problem. It builds a global anomaly cost volume by cross-correlating input and template features across multiple layers and templates, then refines this volume with a 3D U-Net guided by dual-stream attention that preserves edges and concentrates on anomalies. The method integrates as a plug-in with reconstruction- or embedding-based UAD systems, using a targeted loss with a class-aware adaptor and a weighted fusion with baseline maps. Empirical results on MVTec-AD and VisA show consistent, substantial improvements in both detection and localization across multi-class and single-class settings, with modest computational overhead, indicating strong practical impact for industrial inspection scenarios.

Abstract

Unsupervised anomaly detection (UAD) seeks to localize the anomaly mask of an input image with respect to normal samples. Either by reconstructing normal counterparts (reconstruction-based) or by learning an image feature embedding space (embedding-based), existing approaches fundamentally rely on image-level or feature-level matching to derive anomaly scores. Often, such a matching process is inaccurate yet overlooked, leading to sub-optimal detection. To address this issue, we introduce the concept of cost filtering, borrowed from classical matching tasks, such as depth and flow estimation, into the UAD problem. We call this approach {\em CostFilter-AD}. Specifically, we first construct a matching cost volume between the input and normal samples, comprising two spatial dimensions and one matching dimension that encodes potential matches. To refine this, we propose a cost volume filtering network, guided by the input observation as an attention query across multiple feature layers, which effectively suppresses matching noise while preserving edge structures and capturing subtle anomalies. Designed as a generic post-processing plug-in, CostFilter-AD can be integrated with either reconstruction-based or embedding-based methods. Extensive experiments on MVTec-AD and VisA benchmarks validate the generic benefits of CostFilter-AD for both single- and multi-class UAD tasks. Code and models will be released at https://github.com/ZHE-SAPI/CostFilter-AD.

CostFilter-AD: Enhancing Anomaly Detection through Matching Cost Filtering

TL;DR

CostFilter-AD addresses the persistent issue of matching noise in unsupervised anomaly detection by reframing UAD as a matching cost filtering problem. It builds a global anomaly cost volume by cross-correlating input and template features across multiple layers and templates, then refines this volume with a 3D U-Net guided by dual-stream attention that preserves edges and concentrates on anomalies. The method integrates as a plug-in with reconstruction- or embedding-based UAD systems, using a targeted loss with a class-aware adaptor and a weighted fusion with baseline maps. Empirical results on MVTec-AD and VisA show consistent, substantial improvements in both detection and localization across multi-class and single-class settings, with modest computational overhead, indicating strong practical impact for industrial inspection scenarios.

Abstract

Unsupervised anomaly detection (UAD) seeks to localize the anomaly mask of an input image with respect to normal samples. Either by reconstructing normal counterparts (reconstruction-based) or by learning an image feature embedding space (embedding-based), existing approaches fundamentally rely on image-level or feature-level matching to derive anomaly scores. Often, such a matching process is inaccurate yet overlooked, leading to sub-optimal detection. To address this issue, we introduce the concept of cost filtering, borrowed from classical matching tasks, such as depth and flow estimation, into the UAD problem. We call this approach {\em CostFilter-AD}. Specifically, we first construct a matching cost volume between the input and normal samples, comprising two spatial dimensions and one matching dimension that encodes potential matches. To refine this, we propose a cost volume filtering network, guided by the input observation as an attention query across multiple feature layers, which effectively suppresses matching noise while preserving edge structures and capturing subtle anomalies. Designed as a generic post-processing plug-in, CostFilter-AD can be integrated with either reconstruction-based or embedding-based methods. Extensive experiments on MVTec-AD and VisA benchmarks validate the generic benefits of CostFilter-AD for both single- and multi-class UAD tasks. Code and models will be released at https://github.com/ZHE-SAPI/CostFilter-AD.
Paper Structure (27 sections, 7 equations, 12 figures, 20 tables)

This paper contains 27 sections, 7 equations, 12 figures, 20 tables.

Figures (12)

  • Figure 1: Comparison of multi-class UAD results. We present the visualization results and kernel density estimation curves kde of image- and pixel-level logits. Baseline results are highlighted in yellow, while ours are shown in green. Our model achieves superior performance by detecting anomalies with less noise and providing a clearer distinction between normal and abnormal logits.
  • Figure 2: Overview of our CostFilter-AD. We reformulate UAD as a matching cost filtering process. (i) First, we employ a pre-trained encoder to extract features from both the input image and the templates (reconstructed normal images or randomly selected normal samples). (ii) Second, we construct an anomaly cost volume based on global similarity matching. (iii) Lastly, we learn a cost volume filtering network, guided by attention queries derived from the input features and an initial anomaly map, to refine the volume and generate the final detection results. (iv) Further, we integrate a class-aware adaptor to tackle class imbalance and enhance the ability to deal with multiple anomaly classes simultaneously.
  • Figure 3: Qualitative comparison of multi-class anomaly localization between our method and GLAD (G), HVQ-Trans (H), and AnomalDF (A) on MVTec-AD (top 3 rows) and VisA (bottom 3 rows). By integrating with existing methods, our approach effectively mitigates matching noise (e.g., false negatives in PCB2, false positives in Pill, and blurred boundaries in Carpet), enhancing anomaly detection.
  • Figure 4: Failure cases on MVTec-AD and VisA. Some subtle anomalies may lead to inaccurate or missed localization, potentially due to limited representation in the constructed cost volume.
  • Figure 5: Design of the Residual Channel-Spatial Attention (RCSA) module for dual-stream feature guidance.
  • ...and 7 more figures