arXiv:2610.39727cs.CVOct 2026

Manuscript Offprint

arXiv:2610.39727

Cross-Encoder Anchor Refinement for Zero-Shot Anomaly Detection

Kaisong Ji, Ziyang Xu, Chang Bian, Yu Zhou, Wenyu Liu, Xinggang Wang

Abstract

Zero-shot anomaly detection aims to transfer anomaly discrimination from auxiliary training domains to unseen categories while localizing subtle defects. A key challenge is to construct discriminative references that combine contextual representations with complementary local evidence. We present Cross-Encoder Anchor Refinement (CEAR), which connects two visual encoding paths for the same image at the anchor stage, before normal and anomalous prototypes are constructed. An independent convolutional encoder pretrained for industrial product recognition builds an image-specific memory shared across selected vision transformer (ViT) layers. Spatial anchors read from ViT patch features query this memory through cross-attention and undergo residual refinement. Image-conditioned normal and anomalous queries then gate anchor aggregation to construct prototypes for anomaly scoring. Across 13 industrial and medical datasets, CEAR achieves the best performance in 57 of 68 evaluations spanning image-level detection and pixel-level localization. Notably, CEAR surpasses all other state-of-the-art methods in 41 of 44 pixel-level comparisons. Across 11 localization datasets, mean gains in pixel-level maximum F1 score and average precision are 4.45 and 3.79 percentage points, respectively. This study shows how cross-encoder interaction at the anchor stage can integrate complementary visual representations for fine-grained anomaly localization across domains.

Keywords: Zero-shot anomaly detection, Anomaly localization, Spatial anchor refinement, Image-conditioned prototypes, Cross-domain generalization

1. Introduction

Industrial visual anomaly detection identifies defective products and localizes regions that deviate from normal appearance. Defects are rare and diverse, while changing product categories make extensive annotation and category-specific training costly. We study zero-shot anomaly detection (ZSAD) with auxiliary supervision, learning transferable anomaly discrimination for target categories absent from anomaly training. This setting couples cross-category recognition with precise localization, requiring sensitivity to fine cracks, small notches, and low-contrast regions within otherwise normal structures. MVTec AD, Real-IAD, and MVTec AD 2 illustrate these challenges through diverse defects and demanding imaging conditions [1–3].

Vision-language models provide transferable semantic references for ZSAD. WinCLIP combines prompt ensembles with window-, patch-, and image-level features, whereas AnomalyCLIP learns object-agnostic prompts for normality and abnormality [4, 5]. AA-CLIP, Bayes-PFL, and FAPrompt improve semantic separation, model prompt distributions, and adapt fine-grained abnormality prompts to individual images, respectively [6–8]. These advances also highlight the importance of matching semantic references to spatially faithful visual evidence. SCLIP and ClearCLIP improve dense CLIP predictions through attention reformulation and representation decomposition [9, 10]. For anomaly detection, FE-CLIP, DLVP-CLIP, and FB-CLIP exploit frequency cues, local visual prompts, and foreground–background separation [11–13]. Together, these studies motivate a closer examination of how local visual structure contributes to anomaly discrimination.

Recent work on pretrained visual representations highlights the importance of preserving spatial structure and recovering fine-grained detail for dense prediction [14, 15]. In anomaly detection, VisualAD constructs discriminative representations through visual tokens and spatial aggregation [16]. AnomalyVFM combines diverse anomaly synthesis with internal feature adaptation to improve transfer across datasets [17]. These studies motivate our central question: how can contextual representations and complementary local evidence jointly inform transferable anomaly references?

Spatial sampling affects the local detail available for constructing these references. With a fixed patch size, higher input resolution produces a denser patch grid and can preserve evidence of small defects. We therefore use MoonViT, a visual encoder supporting variable input resolutions and pretrained on image–text pairs [18]. Beyond spatial sampling, we focus on how local evidence can guide the construction of anomaly references at the output of this encoder. ViT-CoMer demonstrates that interactions between convolutional features and ViT representations can improve dense prediction [19]. For ZSAD, we therefore examine how features from an independent local encoder can inform discriminative references derived from ViT

∗^{*}Corresponding author.

Email address: xgwang@hust.edu.cn (Xinggang Wang)

1^{1}These authors contributed equally to this work.

Figure

Figure 1: Qualitative comparisons examine the contribution of cross-encoder conditioning to anomaly localization in industrial and medical images. CEAR concentrates responses more closely on annotated anomalies while reducing activations on some normal structures and background regions.

representations. Spatial anchors provide the interaction interface: they retrieve local evidence and undergo refinement before query-gated aggregation constructs normal and anomalous prototypes. Section 4.3 compares this mechanism with score-level late fusion and direct feature concatenation under controlled conditions. Figure 1 compares anomaly responses from MoonViT-only and CEAR on industrial and medical samples, illustrating spatial differences associated with cross-encoder conditioning. In the examples shown, CEAR responds more selectively to annotated anomalies while reducing activations in some regions of normal texture and background.

We therefore present Cross-Encoder Anchor Refinement (CEAR), which connects two separate visual encoding paths through spatial anchors. Here, cross-encoder refers to refining anchors derived from ViT features using local evidence encoded independently from the same image. A ConvNeXt V2 CNN pretrained for industrial product recognition supplies hierarchical features [20]. These features form a local memory shared across selected MoonViT layers. Spatial anchors read from each selected layer query this memory through cross-attention and undergo residual refinement. The interaction operates on encoder outputs, before normal and anomalous prototypes are constructed. The anchors are shared by the normal and anomalous branches. Queries combining learned normal and anomalous seeds with image-level context then gate anchor aggregation to construct image-conditioned prototypes. The layerwise branches use independent refinement parameters and access the same memory; refined anchors are not passed between layers. Anomaly adaptation and inference use image features without text prompts or a language branch.

We evaluate CEAR on 13 industrial and medical datasets through cross-category and cross-dataset comparisons. Among the methods and protocols summarized in Table 1, CEAR achieves 57 best results across 68 dataset–metric comparisons. For pixel-level localization, CEAR scores higher than all other state-of-the-art methods in 41 of 44 comparisons. Across 11 localization datasets, mean gains in pixel-level maximum F1 score (F1-max) and average precision (AP) are 4.45 and 3.79 percentage points, respectively. Mean gains in area under the receiver operating characteristic curve (AUROC) and area under the per-region overlap curve (PRO) are 2.20 and 2.39 percentage points. Beyond these performance comparisons, ablations vary industrial pretraining, memory features, interaction stage, and multilayer supervision. Component ablations and visualizations examine how local conditioning influences predictions.

Our main contributions are as follows.

• We introduce CEAR for zero-shot anomaly detection, integrating contextual representations and complementary local evidence through cross-encoder interaction before normal and anomalous prototypes are constructed.

• We propose cross-encoder anchor refinement, allowing ViT-derived spatial anchors to retrieve evidence from a shared local memory built by an independent encoder. Layer-specific residual updates incorporate this evidence before query-gated construction of image-conditioned normal and anomalous prototypes.

• We evaluate CEAR across 13 industrial and medical datasets. Matched-backbone and matched-resolution comparisons, component ablations, and qualitative analyses examine transfer performance and the role of local conditioning.

References (57)