Template-Based Feature Aggregation Network for Industrial Anomaly Detection

arXiv cs.CV / 3/25/2026

💬 OpinionSignals & Early TrendsIdeas & Deep AnalysisModels & Research

Key Points

  • The paper introduces TFA-Net, a template-based feature reconstruction model designed to improve industrial anomaly detection under the risk of shortcut learning in conventional feature-reconstruction approaches.
  • Instead of reconstructing input features directly, TFA-Net aggregates multi-scale input features onto pre-extracted template features to suppress anomalous features that show low similarity to normal template representations.
  • It refines reconstructed feature details using the fused template features and performs anomaly localization by measuring differences between the input and reconstructed feature maps.
  • A random masking strategy is added to strengthen inspection performance, helping the model maintain robustness in practical industrial settings.
  • Experiments report state-of-the-art results across multiple real-world industrial datasets with claimed real-time suitability, and the authors provide code via the linked GitHub repository.

Abstract

Industrial anomaly detection plays a crucial role in ensuring product quality control. Therefore, proposing an effective anomaly detection model is of great significance. While existing feature-reconstruction methods have demonstrated excellent performance, they face challenges with shortcut learning, which can lead to undesirable reconstruction of anomalous features. To address this concern, we present a novel feature-reconstruction model called the \textbf{T}emplate-based \textbf{F}eature \textbf{A}ggregation \textbf{Net}work (TFA-Net) for anomaly detection via template-based feature aggregation. Specifically, TFA-Net first extracts multiple hierarchical features from a pre-trained convolutional neural network for a fixed template image and an input image. Instead of directly reconstructing input features, TFA-Net aggregates them onto the template features, effectively filtering out anomalous features that exhibit low similarity to normal template features. Next, TFA-Net utilizes the template features that have already fused normal features in the input features to refine feature details and obtain the reconstructed feature map. Finally, the defective regions can be located by comparing the differences between the input and reconstructed features. Additionally, a random masking strategy for input features is employed to enhance the overall inspection performance of the model. Our template-based feature aggregation schema yields a nontrivial and meaningful feature reconstruction task. The simple, yet efficient, TFA-Net exhibits state-of-the-art detection performance on various real-world industrial datasets. Additionally, it fulfills the real-time demands of industrial scenarios, rendering it highly suitable for practical applications in the industry. Code is available at https://github.com/luow23/TFA-Net.