Manuscript Offprint

arXiv:2609.03655

PL-SCEA: Reconfiguring Pretrained Attention for Few-Shot Industrial Anomaly Detection

Xiaoyu Yang, Qixing Wu, Huixian Zhao, Changlong Jin

Abstract

Vision Foundation Models (VFMs) provide transferable patch representations for few-shot industrial anomaly detection, but their attention computation is typically inherited from pretraining objectives centered on semantic aggregation. This creates a potential mismatch: token relations that support semantic recognition may not adequately expose the localized texture and structural deviations required for anomaly localization. We therefore investigate the hypothesis that the attention computation of a frozen VFM can be reconfigured as a task-relevant component of anomaly detection. We instantiate this idea with Power-Law Self-Correlation Enhanced Attention (PL-SCEA), which retains the semantic context of pretrained query-key attention while constructing token-adaptive self-correlations over contextualized value features. Positive-correlation filtering and power-law reweighting then emphasize relations that are salient relative to each token's relational background, without introducing additional trainable attention projections. The resulting features are modeled by a lightweight variational autoencoder that provides a fixed-size reconstruction-based representation of category-specific normality. The two stages serve complementary roles: attention reconfiguration shapes how local relational deviations are represented, while reconstruction-based modeling converts deviations from learned normality into anomaly scores. Across MVTec AD and VisA, the complete framework achieves competitive image-level detection and consistently strong pixel-level localization across the evaluated few-shot settings. Ablations further show that PL-SCEA improves localization with either the VAE or a memory bank under the tested setting. These results support the view that task-aligned attention reconfiguration can improve the anomaly-localization capability of frozen pretrained representations.

Introduction

Industrial anomaly detection typically trains on normal images to identify defective samples and localize anomalous regions. Feature-matching (Defard et al. 2021; Roth et al. 2022), knowledge-distillation (Deng and Li 2022; Salehi et al. 2021), and reconstruction (Zavrtanik, Kristan, and Skočaj 2021) methods perform well on MVTec AD (Bergmann et al. 2019) and VisA (Zou et al. 2022), but generally require category-specific normal data that cover texture, pose, and structural variation. Rebuilding such datasets for new product categories is costly. Few-shot industrial anomaly detection must therefore establish category-specific normality from only K normal reference images while remaining sensitive to local defects.

In few-shot settings, the limited normal references make the quality and organization of pretrained patch representations particularly important. RADIO (Ranzinger et al. 2024b) distills complementary capabilities from DINO (Caron et al. 2021), CLIP (Radford et al. 2021), and SAM (Kirillov et al. 2023), while RADIOv3 (Ranzinger et al. 2024a) further improves the spatial detail of dense representations. Nevertheless, these models inherit attention computations optimized primarily for general-purpose semantic representation. Their pretrained features therefore provide a strong starting point, but the way token information is aggregated may remain mismatched with the localized texture and structural deviations that characterize industrial anomalies.

Attention computation determines how each output patch aggregates evidence from the remaining tokens. In the example shown in Figure 2, the original QK attention preserves semantic context but produces relatively fragmented responses around boundaries and high-contrast regions. Direct QQ, KK, and VV correlations form more spatially continuous patterns, but some also merge locally distinct regions and reduce defect contrast. This observation suggests complementary roles for semantic conditioning and same-type token relations. It further raises a broader question: can the attention computation of a frozen VFM be reconfigured for anomaly localization without discarding the semantic structure learned during pretraining?

Motivated by this question, we argue that the attention computation of a frozen VFM should be treated as a task-relevant design variable rather than an immutable part of the feature extractor. Importantly, modifying attention is not beneficial by default: directly replacing QK attention with QQ, KK, or VV correlations may discard useful semantic conditioning or over-smooth local structures. An anomaly-oriented reconfiguration should instead retain pretrained QK context while selectively reshaping token relations according to their relative relational salience.

We instantiate this design principle with Power-Law Self-Correlation Enhanced Attention (PL-SCEA). PL-SCEA first contextualizes value features through the original QK attention and then computes pairwise self-correlations over

∗^{*}Corresponding author.

the contextualized tokens. Token-wise standardization and power-law reweighting emphasize relations that are salient relative to each token's relational background, and the resulting weights are used to reaggregate the original value tokens. This design preserves pretrained semantic conditioning while altering how local relational evidence is represented, without introducing additional trainable attention projections.

Attention reconfiguration alone does not define how category-specific normality should be represented from a few reference images. We therefore pair PL-SCEA with a lightweight variational autoencoder (Kingma and Welling 2013) that reconstructs relation-enhanced normal patch features. The two stages address different parts of the detection pipeline: PL-SCEA shapes how local relational deviations are exposed in the feature space, whereas the reconstruction model summarizes normality and converts deviations from that normality into patch-level anomaly scores. The resulting parametric normality model has a fixed storage footprint and avoids nearest-neighbor retrieval over an explicit feature memory bank.

We evaluate the complete framework on MVTec AD and VisA across 1–8-shot settings. It maintains competitive image-level detection performance and improves pixel-level F1-max on MVTec AD by 4.1–4.8 percentage points over AnomalyDINO-S. Controlled comparisons further show that replacing QK attention with PL-SCEA improves localization with either the VAE or a memory bank in the MVTec AD 1-shot setting. Meanwhile, the PL-SCEA–VAE combination obtains the strongest pixel-level results in the component comparison. These findings suggest that attention reconfiguration and reconstruction-based normality modeling provide complementary benefits rather than attributing the complete improvement to either component alone. Figure 1 summarizes the training and inference pipeline. Our contributions are summarized as follows:

• We formulate and empirically examine the hypothesis that the attention computation of a frozen vision foundation model can be reconfigured to improve few-shot industrial anomaly localization, rather than treating pretrained token interactions as fixed.

• We instantiate this design principle with PL-SCEA, which retains pretrained QK semantic conditioning while constructing token-adaptive, power-law-reweighted self-correlations without introducing additional trainable attention projections.

• We combine relation-aware feature construction with reconstruction-based latent normality modeling. Experiments on MVTec AD and VisA show strong localization performance across 1–8-shot settings, while controlled comparisons with both a VAE and a memory bank indicate that the effect of PL-SCEA is not restricted to a single normality model.

References (29)