Manuscript Offprint
arXiv:2610.39727Cross-Encoder Anchor Refinement for Zero-Shot Anomaly Detection
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)
These authors contributed equally to this work.

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.
2.1. Vision-Language References for Anomaly Detection
Vision–language methods use normal and anomalous text representations as transferable discriminative references. WinCLIP combines prompt ensembles with window-, patch-, and image-level matching, whereas AnomalyCLIP learns object-agnostic prompts [4, 5]. AdaCLIP combines static and image-conditioned prompts, while VCP-CLIP incorporates global and local visual context into text representations [21, 22]. FiLo couples fine-grained defect descriptions with dedicated localization modules [23]. AA-CLIP strengthens anomaly-aware visual-textual representations, while AdaptCLIP alternately adapts the visual and textual branches [6, 24].
Bayes-PFL, FAPrompt, and PromptMoE improve prompt flexibility through distribution modeling, sample-dependent abnormality prompts, and visually guided expert mixtures, respectively [7, 8, 25]. FE-CLIP, DLVP-CLIP, and FB-CLIP enhance local discrimination through frequency-aware adaptation, regional visual prompting, and foreground-background separation, respectively [11–13]. These developments connect semantic adaptation with spatially localized evidence, motivating consideration of where such evidence enters anomaly reference construction.
2.2. Reference Requirements and Transfer Settings
Anomaly detectors differ in their access to target-domain information during training and inference. MuSc and MuSc-V2 exploit relationships among unlabeled test samples through mutual scoring [26, 27]. RareCLIP estimates patch rarity using an online memory of previously observed images [28]. InCTRL, UniVAD, and MetaUAS use normal reference images at inference [29–31]. Dinomaly and AnomalyMoE instead learn from target-category normal training data [32, 33]. Reference requirements and test-sample interactions are therefore distinct from whether a detector uses language.
For auxiliary-supervised transfer, AnomalyVFM combines anomaly synthesis with feature adaptation and confidence-weighted supervision [17]. CEAR learns from auxiliary anomaly data and processes unseen target categories one image at a time. Its conditioning evidence comes from the current input, without target-domain normal references or interactions among test samples. Zero-shot evaluation here concerns target categories excluded from anomaly adaptation, while auxiliary training uses image labels and pixel masks.
2.3. Dense Representations and Local Evidence
Strong pretrained ViTs support dense prediction, as demonstrated by EoMT [34], while MoonViT supports variable-resolution visual encoding [18]. Register tokens and DVT address spatial artifacts in pretrained ViT features [14, 35]. DI-NOv3 preserves dense feature quality through Gram anchoring [36]. FeatUp and AnyUp recover spatial detail through feature upsampling [15, 37]. ViT-CoMer introduces multiscale CNN–ViT interactions within the backbone for dense prediction [19]. These approaches improve spatial representations through different operations, from feature organization and upsampling to interactions between encoding paths.
Real-IAD and MVTec AD 2 highlight fine-scale defects and challenging industrial imaging conditions [2, 3]. In CEAR, ConvNeXt V2 supplies hierarchical convolutional features [20], with product-recognition pretraining on Real-IAD providing the industrial representation source. These features serve as local conditioning evidence at the output of the frozen ViT, before anomaly prototypes are constructed.
2.4. Visual Prototypes and Conditional Refinement
VisualAD constructs layerwise discriminative references through token-gated aggregation of spatial anchors, with attention and gates recomputed for each image [16]. UniADet learns task- and layer-specific decision weights for classification and segmentation [38]. ReCAP conditions prototypes on globally pooled features from the same visual encoder through bounded residual updates [39]. Layer-specific discrimination and image conditioning therefore provide established foundations for visual anomaly detection.
CEAR investigates how independently encoded local evidence can inform prototype construction. ViT-derived anchors query a shared CNN memory through cross-attention and undergo residual refinement before normal and anomalous queries gate their aggregation into prototypes. Relative to VisualAD and ReCAP, the distinction concerns both the independent source of local evidence and its application to anchors before prototype construction. The interaction operates on outputs of the frozen backbones; layerwise branches share the local memory but retain independent refinement parameters.
3. Method
3.1. Problem Formulation and Framework Overview
CEAR refines spatial anchors to connect ViT representations with local evidence encoded independently from the same image by a CNN. The ViT supplies patch features and contextual representations, while fused and encoded CNN features form a local memory shared across layerwise branches. At each selected ViT layer, spatial evidence readout (SER) first constructs anchors from patch features. CNN-conditioned anchor refinement (CCAR) then retrieves information from the shared memory to update these anchors. Finally, query-gated prototype construction (QGPC) aggregates the refined anchors into normal and anomalous prototypes. This cross-encoder interaction operates on anchors and memory derived from encoder outputs; refined anchors are not propagated between layers. Figure 2 illustrates the overall data flow, the residual structure of anchor refinement, and the construction of the shared local memory.
We consider an auxiliary training set , where image labels and pixel masks indicate anomaly status at their respective granularities. After learning from the auxiliary domain, the model directly predicts an image anomaly score and a pixel-level anomaly map for unseen target categories. The CNN is pretrained using industrial product category supervision independent of both the source and target anomaly domains. Anomaly adaptation and inference operate entirely in the visual feature space, with each target image processed independently.
As shown in Figure 2, the two encoders process the same image to obtain ViT patch features and multiscale CNN features. Global statistics from the deepest selected ViT layer generate image-conditioned queries. Within each layerwise branch, SER, CCAR, and QGPC successively read spatial evidence, refine anchors, and construct prototypes. A parallel patch projection MLP maps patch features into a space where cosine similarities to the two prototypes yield layerwise anomaly responses. These responses are bilinearly upsampled and summed into an anomaly map, whose highest-response pixels are averaged to obtain the image score. The frozen components in the figure denote the two encoder backbones. The trainable components comprise the shared output layer normalization and the anomaly modeling modules.
3.2. Visual Representations and Shared Local Memory
Let I denote the set of selected ViT layers. Shared layer normalization converts their outputs into patch features:

Figure 2: CEAR architecture and cross-encoder interaction. Top: frozen ViT and CNN backbones encode the same image. The industrially pretrained CNN constructs a shared local memory for refining ViT-derived spatial anchors before query-gated construction of normal and anomalous prototypes. Projected patch features are compared with these prototypes to produce layerwise anomaly responses for localization and image-level scoring. Middle: the residual CCAR block. Bottom: multiscale CNN memory construction. Layerwise refinement shares the memory but uses independent parameters, without passing refined anchors between layers.
Here, denotes the encoding mapping at layer , N is the number of patches, and d is the channel dimension. The selected layers retain the same spatial grid while providing representations at different depths. For clarity, we omit the batch dimension and training-time dropout. Tokens occupy rows of feature matrices, and linear transformations multiply weight matrices on the right.
To condition discrimination on the input image, we compute spatial means, maxima, and standard deviations from the deepest selected layer . A linear mapping converts these statistics into a global context vector , which then conditions the normal and anomalous queries:
Here, denotes channel concatenation, identifies the deepest selected layer, and indexes the anomalous and normal classes, respectively. Each learnable query seed is combined with image context to form the corresponding image-conditioned query . The three statistics capture average responses, salient activations, and spatial response variability. They allow the queries to combine a discriminative direction shared across images with information specific to the current input. These queries are generated at the output of the encoder.
The CNN branch in Figure 2 extracts multiscale features representing texture variations, edges, and component structure in the input image. Channel projection and spatial alignment map the features onto a common grid. Residual fusion then uses the intermediate scale as its reference:
All aligned features have shape . The convolutional fusion mapping supplies complementary features, whose contribution is controlled by . The residual path preserves the intermediate-scale representation, while the fusion mapping learns complementary information from the other scales.
The “Flatten & project” block in Figure 2 flattens the fused features and matches their channel dimension to that of the ViT. The “Memory encoder” then uses self-attention to model relationships among local structures, producing the shared memory:
The resulting memory has dimensions , with , and MHSA denotes multihead self-attention. Computed from the current image, this memory is shared across all selected ViT layers. Each layer retrieves the information it needs through an independent conditional refinement module.
3.3. Cross-Encoder Anchor Refinement and Discriminative Prototypes
SER compresses the patch sequence into a set of spatial anchors. Each layer has learnable anchor seeds , from which queries, keys, and values are constructed for spatial readout:
The positional embedding is added only to the key branch. Queries and keys are layer-normalized after projection. Spatial readout weights then aggregate the projected patch features into anchors:
The softmax operation normalizes over patches, yielding spatial readout weights and aggregated anchors . These anchors provide intermediate evidence shared by the normal and anomalous branches. Class-specific discriminative prototypes are constructed subsequently through query-gated aggregation.
CCAR takes as input and sequentially applies anchor self-attention, cross-attention to the CNN memory, and a feed-forward update (Figure 2):
(7)
MHCA denotes multihead cross-attention [40], with normalized anchors as queries and the shared memory M as keys and values. Self-attention models relationships among anchors, whereas cross-attention retrieves local features relevant to the current ViT evidence from the independently encoded memory. The feed-forward network then applies a nonlinear transformation to the updated anchors. All three sublayers use residual connections, and each selected layer has independent refinement parameters. The refined anchors combine ViT evidence with CNN conditioning information and directly support prototype construction.
QGPC uses the normal and anomalous queries to select and aggregate evidence from the refined anchors:
(8)
Here, contains independent sigmoid gates, and is a learnable residual coefficient. The matrix product weights and aggregates the refined anchors. Together with the two queries, this aggregation yields image-conditioned normal and anomalous prototypes at each layer. The two class branches share parameters for spatial readout and conditional refinement; their distinction is expressed through the queries and gating weights.
CCAR introduces local evidence from the independent CNN into the ViT-derived anchors. QGPC then combines image-conditioned queries with gated anchor contributions to construct normal and anomalous prototypes. The two encoding paths therefore interact through intermediate anchors before prototype aggregation. The CNN serves as a source of local evidence in this design. Section 4.3.1 compares the CNN-only model, fusion controls, and full model to examine how standalone detection performance relates to its benefit as a conditioning source.
3.4. Patch Comparison and Anomaly Scoring
A patch projection MLP maps each layer's patch features into a space compatible with its discriminative prototypes. It contains two linear layers that preserve the channel dimension, separated by a GELU activation. For the projected features , the difference in cosine similarity to the anomalous and normal prototypes defines the patch anomaly response:
Here, indexes patch positions, and denotes cosine similarity. The response increases as a patch becomes more similar to the anomalous prototype or less similar to the normal prototype.
We reshape each layer’s responses into a spatial grid and bilinearly upsample them. An unweighted sum forms the pixel-level anomaly map, and the image score averages a fraction of its highest-response pixels:
Here, upsamples the patch grid to , and returns the highest-response locations, where . The fraction determines how many pixels contribute to image-level discrimination. This aggregation retains the contribution of localized anomalies while reducing sensitivity to a single extreme response.
3.5. Joint Training Objective
The training objective combines task prediction, discriminative margins, and region completeness. We use binary cross-entropy for image-level prediction and supervise the deeper branches with focal and Dice segmentation losses [41, 42]:
Here, , is the sigmoid function, and is the ground-truth pixel mask. Segmentation losses are computed separately for each layer and summed over the selected deeper branches. A directional margin on the image-conditioned queries maintains separation between the normal and anomalous classes:
We use the positive-part notation , and specifies the query margin. Applied to the queries , this loss penalizes similarity above the prescribed boundary.
We additionally impose region-level margin supervision on the patch grid. Nearest-neighbor downsampling of the ground-truth mask defines anomalous locations and normal locations . For each image, the region loss is defined as
(15)
The margins and correspond to foreground and background, respectively, and w weights the background term. The operator averages the largest fraction r of values in its input set. Hard examples are selected independently for foreground and background, and each term is averaged over images containing a nonempty corresponding region. Images with an empty region are excluded from that term's reduction. Different parameters are used for the deeper branches and the shallower branch set :
(16)
Here, denotes the region loss after the image-wise reduction described above. The deeper-layer constraint promotes overall separation of normal and anomalous regions. The shallower-layer constraint emphasizes difficult local responses to reduce spurious activations caused by normal textures. This assignment distinguishes supervision roles; each layer may still contain both local and global information.
Finally, we use to compute soft true positives, false positives, and false negatives. A Tversky loss encourages region completeness in the fused anomaly map [43]:
The coefficients control the relative costs of false positives and false negatives, respectively, while provides numerical stability. The joint objective is
The coefficients weight the loss terms; their values and the training configuration are given in Section 4.1. Anomaly adaptation updates the queries, projections, memory encoding, and conditional refinement modules, together with the shared layer normalization at the ViT output. The ViT backbone and CNN encoder remain frozen throughout anomaly adaptation.
4. Experiments
We evaluate how CEAR generalizes across industrial categories and medical imaging domains, then examine the contribution of cross-encoder anchor refinement under controlled conditions. The ablations isolate input resolution, industrial pretraining, multiscale memory, conditional interactions, and supervision at different layers. Qualitative analyses complement these comparisons and help characterize the model's range of applicability.
4.1. Experimental Setup
4.1.1. Datasets and Training Protocol
We evaluate anomaly detection and localization on 13 industrial and medical datasets. The industrial benchmarks are MVTec AD [1], VisA [44], BTAD [45], DTD-Synthetic [46], and MPDD [47]. All five support image-level detection and pixel-level localization. MVTec AD and VisA alternate as auxiliary and target domains in the two training directions. DTD-Synthetic denotes the texture benchmark with synthetic anomalies, rather than the original texture classification task.
Table 1: Comparison of zero-shot anomaly detection methods on 13 industrial and medical datasets. Image-level metrics are AUROC, F1-max and AP; pixel-level metrics are AUROC, F1-max, AP and PRO. Best and second-best reported values for each dataset and metric are shown in red and blue.
| Domain | Metric | Dataset | WinCLIP | APRIL-GAN | CLIP-AD | AnomalyCLIP | AdaCLIP | VisualAD (CLIP) | CEAR |
|---|---|---|---|---|---|---|---|---|---|
| ViT-L/14 @336px | ViT-L/14 @336px | ViT-L/14 @336px | ViT-L/14 @336px | ViT-L/14 @336px | ViT-L/14 @336px | MoonViT @672px | |||
| Industrial | Image-level (AUROC, F1-max, AP) | VisA | (75.6, 78.2, 78.8) | (77.4, 78.6, 80.9) | (66.2, 74.3, 71.4) | (81.0, 80.3, 84.4) | (79.7, 79.6, 83.2) | (84.7, 82.5, 87.6) | (84.8, 82.7, 88.5) |
| MVTec-AD | (90.4, 92.7, 95.6) | (86.1, 90.4, 93.6) | (74.1, 86.3, 88.1) | (91.6, 92.7, 96.2) | (92.0, 92.7, 96.4) | (92.2, 93.2, 96.7) | (92.4, 92.7, 96.5) | ||
| BTAD | (68.2, 67.8, 70.9) | (73.7, 68.7, 69.9) | (66.7, 65.9, 67.3) | (88.7, 86.0, 90.6) | (90.0, 87.2, 91.5) | (94.9, 93.9, 97.0) | (94.9, 87.9, 92.6) | ||
| DTD | (95.1, 94.1, 97.7) | (85.5, 89.1, 94.0) | (75.1, 86.3, 88.0) | (93.7, 94.3, 97.4) | (92.1, 92.4, 96.3) | (97.5, 96.6, 99.1) | (97.6, 97.4, 99.3) | ||
| MPDD | (61.4, 77.5, 69.9) | (73.0, 76.0, 79.8) | (74.5, 72.9, 77.9) | (77.0, 75.4, 82.0) | (76.0, 82.5, 77.1) | (71.5, 81.6, 79.5) | (78.2, 85.2, 80.2) | ||
| Pixel-level (AUROC, F1-max, AP, PRO) | VisA | (73.2, 9.0, 5.4,51.1) | (93.8,32.6,26.2,86.5) | (93.0,24.1,17.9,80.2) | (95.4,27.6,20.7,86.4) | (95.1,33.8,29.2,71.3) | (95.8,34.6,28.4,91.0) | (95.9,34.9,28.4,88.5) | |
| MVTec-AD | (82.3,24.8,18.2,62.0) | (87.5,42.3,39.1,43.7) | (77.9,26.3,21.1,55.7) | (91.0,38.9,34.4,81.7) | (88.5,43.9,41.0,47.6) | (90.8,43.9,41.2,87.5) | (91.2,46.3,45.0,87.9) | ||
| BTAD | (72.7,18.5,12.9,27.3) | (91.3,40.1,37.7,21.0) | (80.9,24.1,18.3,41.4) | (93.0,47.1,41.5,71.0) | (87.7,42.3,36.6,17.1) | (91.1,49.8,43.1,80.4) | (96.7,49.3,44.0,84.9) | ||
| DTD | (79.5,16.1, 9.8,51.5) | (94.9,60.4,61.0,33.8) | (86.6,35.8,31.0,63.2) | (97.5,55.8,52.5,87.9) | (95.1,58.4,56.1,34.3) | (98.1,64.3,65.5,94.8) | (98.7,66.6,70.0,95.5) | ||
| MPDD | (71.2,15.4,22.6,48.9) | (95.1,30.6,28.9,83.1) | (95.1,26.3,28.4,41.5) | (96.5,32.1,29.5,88.7) | (96.1,34.9,32.9,82.0) | (97.1,36.0,33.3,91.4) | (97.4,40.8,35.5,92.7) | ||
| Medical | Image-level (AUROC, F1-max, AP) | COVID-19 | (64.4, 42.5, 42.9) | (15.5, 33.7, 40.6) | (62.5, 56.3, 43.2) | (80.1, 53.6, 58.7) | (64.5, 49.2, 50.3) | (43.8, 68.3, 45.9) | (64.8, 68.4, 64.4) |
| Br35H | (80.5, 74.1, 82.2) | (93.1, 85.4, 92.9) | (96.0, 90.8, 95.5) | (97.3, 92.4, 96.1) | (95.7, 89.1, 95.7) | (94.4, 87.9, 91.6) | (96.2, 93.3, 93.2) | ||
| Brain AD | (72.5, 90.7, 91.6) | (58.8, 90.6, 87.8) | (72.1, 91.3, 91.5) | (69.0, 90.6, 90.1) | (80.0, 90.2, 94.1) | (80.8, 91.8, 94.7) | (83.6, 92.6, 95.7) | ||
| Pixel-level (AUROC, F1-max, AP, PRO) | ClinicDB | (70.3,27.3,19.4,32.5) | (82.4,38.2,36.4,53.5) | (76.5,32.1,24.6,52.8) | (84.6,45.5,41.7,69.8) | (84.3,44.4,43.3,63.6) | (85.2,45.6,37.8,70.6) | (88.9,52.2,44.9,76.1) | |
| Endo | (68.2,32.9,23.8,28.3) | (82.7,46.9,47.2,48.3) | (78.1,41.4,36.8,46.4) | (86.5,53.7,50.7,67.1) | (82.9,47.9,47.7,55.8) | (84.9,52.0,46.2,66.3) | (91.1,62.2,60.8,76.7) | ||
| Kvasir | (69.7,35.9,27.8,24.5) | (77.6,43.2,42.5,40.6) | (73.6,38.9,31.1,30.6) | (82.0,50.0,43.2,44.7) | (80.3,47.7,31.0,27.5) | (80.3,47.8,47.6,50.8) | (88.5,60.1,56.2,52.2) | ||
| ISIC | (83.3,53.4,62.4,55.1) | (85.8,59.9,69.8,13.7) | (81.6,63.6,65.5,29.0) | (88.4,62.3,74.4,78.1) | (85.4,61.9,70.6, 5.3) | (84.0,65.1,67.7,73.1) | (89.4,72.1,75.7,80.0) | ||
| TN3K | (67.2,30.0,32.5,39.8) | (75.9,36.4,35.4,37.8) | (66.5,32.8,31.7,35.9) | (76.8,40.5,36.7,50.3) | (77.2,41.3,36.5,17.0) | (65.5,32.7,30.4,41.1) | (79.1,42.0,36.9,51.4) | ||
| Brain AD | (87.6,21.7,13.3,59.7) | (83.6,38.7,35.0,45.4) | (94.1,42.9,40.5,74.2) | (95.1,43.1,42.3,71.5) | (95.2,40.6,37.0,36.4) | (95.2,46.7,43.7,79.5) | (96.8,53.5,53.0,81.9) |
Medical image-level detection is evaluated on COVID-19 Radiography, Br35H, and Brain AD. COVID-19 Radiography is abbreviated as COVID-19 in the tables [48, 49]. Br35H follows Hamada [50], and Brain AD is a two-dimensional evaluation set derived from BraTS [51]. Medical localization uses CVC-ClinicDB [52], Endo (the EndoTect segmentation benchmark [53]), and Kvasir (Kvasir-SEG [54]). It also includes ISIC (ISIC 2016 [55]), TN3K [56], and Brain AD. These names follow the established anomaly detection benchmarks. The original datasets identify the data sources, whereas their anomaly detection subsets define the evaluation protocols. We therefore do not use sample counts from the original three-dimensional segmentation tasks or other dataset versions to describe the evaluated subsets.
For evaluation on VisA, we train on MVTec AD as the auxiliary dataset; all other target datasets are evaluated using the model trained on VisA. Auxiliary training uses normal/anomalous image labels and pixel masks, with one shared model per training direction. Target categories are excluded from anomaly adaptation, and inference requires neither target-domain normal reference images nor parameter updates. The CNN is separately pretrained for product-category recognition on Real-IAD, then frozen throughout anomaly adaptation and testing [2].
4.1.2. Evaluation Metrics
We measure image-level performance using AUROC, maximum F1 score (F1-max), and average precision (AP). Pixel-level evaluation additionally uses the area under the per-region overlap curve (PRO). For datasets with multiple categories, metrics are computed within each category and then macro-averaged. The controlled evaluation protocol uses three random seeds and summarizes the category-macro-averaged results by their mean and standard deviation. Comparisons are made separately for each metric.
4.1.3. Implementation Details
We use MoonViT-SO-400M as the visual backbone, drawing on its multilayer patch representations and resolution flexibility for anomaly modeling at the encoder output [18]. Inputs are resized to pixels. A patch size of 14 yields a grid with 1,152 channels. We extract features from layers of the 27-layer encoder. The shallowest branch receives supervision on difficult local regions; the other three form the deeper branch set for segmentation supervision. During anomaly adaptation, both encoder bodies remain frozen, while the shared final layer normalization of MoonViT and the anomaly modeling modules are updated. MoonViT inputs are normalized with a mean and standard deviation of 0.5; the CNN retains the normalization used during its pretraining.
The local encoder is ConvNeXt V2-Base [20]. We extract features at strides 4, 8, and 16, with 128, 256, and 512 channels, respectively. Each scale is projected to 256 channels using a convolution, group normalization with 32 groups, and GELU. A convolution with stride 2 downsamples the finest scale, while bilinear interpolation upsamples the coarsest scale to a common grid. The fusion mapping uses two convolutions, group normalization, and GELU. Its final layer is zero-initialized, with residual scaling . A bias-free memory projection produces 7,056 tokens of dimension 1,152.
Each selected layer uses four spatial anchors, and both memory encoding and conditional refinement use eight attention heads. The refinement feed-forward network has a hidden width of 4,608. Dropout is disabled in memory self-attention and set to 0.1 in conditional refinement and patch projection. The prototype residual coefficient is initialized to 0.01. Refined anchors pass directly to query-gated aggregation; all three refinement sublayers retain their internal residual connections. No additional pre-normalization is applied to the encoded memory.
The query margin is set to 0.5. For the deep region loss, the foreground margin, background margin, background weight, and hard-example fraction are 0.5, 0.5, 0.25, and 1, respectively. The corresponding shallow-layer values are 0.5, 0.7, 1, and 0.25. The focal loss uses a focusing parameter of 2, and the Dice smoothing constant is 1. The Tversky loss uses , , and . Loss weights for classification, segmentation, query separation, deep regions, shallow regions, and the fused map are 1, 1, 1, 0.5, 0.5, and 0.25, respectively.
Anomaly adaptation uses AdamW [57] for three epochs with a batch size of 4. The base learning rate is , with weight decay of 0.01. The shared final layer normalization uses a learning rate of and no weight decay. An epoch-wise cosine schedule reduces the learning rate to a minimum of 0.1 times its initial value. Gradient norms are clipped at 0.5. The image score is the mean of the highest 1% of anomaly-map responses. Pixel-level evaluation applies Gaussian smoothing with a standard deviation of 4; image scores are computed before smoothing.
Industrial pretraining fine-tunes a generically pretrained ConvNeXt V2-Base to recognize the 30 product categories in Real-IAD. Normal/anomalous labels and pixel masks do not enter this classification objective. Training uses inputs for 10 epochs, with 16 images per step and gradients accumulated over four steps. The AdamW learning rate is scaled by the effective batch size to . Weight decay is 0.05, and the layer-wise learning-rate decay factor is 0.6. Augmentations comprise RandAugment, random erasing, Mixup, and CutMix [58–61]. The random-erasing probability is 0.25; the Beta-distribution parameters for Mixup and CutMix are 0.8 and 1.0, respectively. Label smoothing and stochastic depth are both set to 0.1, with an exponential moving average decay of 0.9999.
4.2. Comparison with State-of-the-Art Methods
4.2.1. Industrial Anomaly Detection and Localization
Table 1 compares CEAR with WinCLIP [4], APRILGAN [62], and CLIP-AD [63]. It also includes AnomalyCLIP [5], AdaCLIP [21], and VisualAD [16]. This comparison evaluates each complete system. Subsequent ablations on VisA use matched backbones to isolate input resolution, industrial pretraining, and the interaction mechanism. Across 68 dataset-metric comparisons on 13 datasets, CEAR achieves 57 best results: 56 outright and one tied. Figure 3 relates these aggregate results to localization behavior through anomaly maps from industrial and medical target domains.
CEAR shows its strongest advantage in pixel-level localization, exceeding every other method in 41 of 44 comparisons and achieving the highest AUROC on all 11 localization datasets. Relative to the strongest competing result for each dataset and metric, mean gains in pixel AUROC, F1-max, AP, and PRO are 2.20, 4.45, 3.79, and 2.39 percentage points. These averages weight all 11 datasets equally and include comparisons in which CEAR does not rank first. CEAR ranks first in 17 of the 20 industrial localization comparisons. Pixel AP reaches 45.0 on MVTec AD, exceeding the strongest baseline by 3.8 percentage points. On MPDD, pixel F1-max reaches 40.8, a gain of 4.8 points; DTD-Synthetic pixel AP reaches 70.0, a gain of 4.5 points. The improvements span diverse industrial appearances and defect types, with complementary gains in pixel ranking, regional detection, and precision–recall performance.
4.2.2. Transfer to Medical Imaging
CEAR achieves the highest scores in all 24 pixel-level comparisons across the six medical localization datasets. On Endo, pixel AP increases from the strongest baseline value of 50.7 to 60.8, while F1-max increases from 53.7 to 62.2. Pixel F1-max rises from 50.0 to 60.1 on Kvasir, and pixel AUROC rises from 77.2 to 79.1 on TN3K. Under the protocol in Section 4.1.1, all medical datasets use the same model trained on VisA, without target-domain parameter updates. The localization gains therefore extend beyond industrial categories to brain, thyroid, skin, and endoscopic images. These results support cross-domain localization with industrial auxiliary supervision; the advantage is most pronounced at the pixel level.
Figure 3 compares localization on eight industrial and medical sample types represented in Table 1. For the illustrated grid, woven-texture, and metal-tube samples, CEAR retains localized responses at the annotated defects. Its high-response regions also show close spatial correspondence with the annotated lesions in brain, thyroid, skin, and polyp images. Other methods exhibit scattered activations, incomplete responses, or responses extending beyond annotated regions in these examples. The comparisons illustrate how CEAR organizes anomaly evidence across different appearances and imaging conditions. Table 1 quantifies aggregate performance, while Figure 3 shows the corresponding response locations and regional coverage. Heatmaps are normalized individually, so qualitative comparisons concern spatial distribution and correspondence with the ground truth.
4.3. Ablation Studies
We conduct ablations on VisA [44], following the MVTec AD-to-VisA protocol in Section 4.1.1. VisA target categories are excluded from anomaly adaptation. All configurations share the training split, optimization settings, and evaluation procedure, except for the factor under study. The default input resolution is . Tables 2–7 report all seven image-level and pixel-level metrics used in Table 1.

Figure 3: Qualitative comparisons assess anomaly localization across diverse industrial and medical target domains. Columns show grid, woven-texture, tube, capsule, brain, thyroid, skin, and polyp examples, with input images, seven methods' anomaly maps, and ground-truth masks arranged vertically. Compared with several competing methods, CEAR shows closer spatial correspondence to annotated defects and lesions, with fewer fragmented responses or activations outside the annotated regions.
4.3.1. Backbone Resolution and the Contribution of Local Evidence
Table 2 compares controlled variants using the same Moon-ViT backbone at input resolutions of , , and . MoonViT-only retains image-conditioned queries, spatial readout, patch projection, and the default supervision, while removing the CNN conditioning branch. The CNN-only controls include a fixed-feature response probe and a learned discriminative head trained with the same auxiliary anomaly supervision. Score-level fusion, feature concatenation, and anchor refinement before prototype construction use the same training split and optimization settings. These controls distinguish the effects of spatial resolution, additional local representations, and the stage at which the two encoding paths interact.
Table 2: Ablation of input resolution and local-evidence integration on VisA, comparing single-encoder models, score fusion, feature concatenation, and CEAR. Bold and underlined values indicate the best and second-best results for each metric, respectively.
| Model | Input | Pixel-level | Image-level | |||||
|---|---|---|---|---|---|---|---|---|
| AUROC | F1-max | AP | PRO | AUROC | F1-max | AP | ||
| MoonViT-only | 448 | 95.2 | 31.5 | 25.9 | 85.0 | 79.5 | 78.5 | 84.1 |
| MoonViT-only | 560 | 95.3 | 31.9 | 26.7 | 85.4 | 81.5 | 80.0 | 85.5 |
| MoonViT-only | 672 | 95.5 | 33.3 | 27.1 | 87.5 | 82.3 | 80.1 | 85.9 |
| CNN-only (energy) | 672 | 80.8 | 13.2 | 8.4 | 60.4 | 64.9 | 73.6 | 68.4 |
| CNN-only (head) | 672 | 90.1 | 24.6 | 18.4 | 85.0 | 83.2 | 81.2 | 86.1 |
| Score fusion | 672 | 95.2 | 32.9 | 25.3 | 87.0 | 80.2 | 79.7 | 84.8 |
| Feature concat. | 672 | 95.2 | 32.8 | 25.7 | 87.5 | 82.9 | 80.6 | 86.4 |
| CEAR | 448 | 95.4 | 31.9 | 26.0 | 86.9 | 82.2 | 80.9 | 85.9 |
| CEAR | 560 | 95.5 | 32.2 | 27.1 | 87.1 | 83.3 | 81.3 | 87.1 |
| CEAR (full) | 672 | 95.9 | 34.9 | 28.4 | 88.5 | 84.8 | 82.7 | 88.5 |

Figure 4: Qualitative ablations distinguish the effects of increased input resolution and cross-encoder conditioning on anomaly localization. At matched resolution, CEAR reduces responses on normal ring structures and covers more of the annotated skin lesion.
CEAR improves all four pixel-level metrics over MoonViT-only at each of the three input resolutions. At , gains in pixel AUROC, F1-max, AP, and PRO are 0.4, 1.6, 1.3, and 1.0 percentage points, respectively. Image AUROC, F1-max, and AP improve by 2.5, 2.6, and 2.6 points. The full model also outperforms score-level late fusion and direct feature concatenation. Thus, performance depends on how local evidence enters prototype construction, beyond the addition of a local encoding path. The learned CNN-only head is competitive on some image-level metrics, but its localization remains weaker than that of MoonViT-only. Using CNN features as conditioning memory for anchor refinement yields the best result on every metric in Table 2. This comparison supports the joint use of local evidence and contextual representations.
Figure 4 complements Table 2 by comparing MoonViT-only at resolutions of 448 and 672 with CEAR at 672 on the same images. For the MVTec AD metal-nut sample, increasing the MoonViT-only resolution leaves broad responses on the normal ring structure. At the same 672 resolution, CEAR concentrates high responses on the annotated defect to the right and suppresses some activations on normal structures. For the ISIC sample, CEAR covers more of the annotated lesion, whereas both single-backbone configurations concentrate on its center. These examples show distinct changes in response distribution from denser spatial sampling and conditional interaction. The controlled comparisons in Table 2 provide the quantitative evidence for the contribution of the interaction mechanism.
Table 3: Ablation of CNN pretraining. Real-IAD pretraining uses product-category supervision; all CNN variants remain frozen during anomaly adaptation. Boldface and underlining follow the convention used in Table 2.
| Configuration | Pixel-level(AUROC, F1-max, AP, PRO) | Image-level(AUROC, F1-max, AP) | |||||
|---|---|---|---|---|---|---|---|
| (95.4, | 33.5, | 27.5, | 88.1) | (84.2, | 82.0, | 87.7) | |
| Generic pretraining | (95.6, | 34.0, | 26.9, | 87.8) | (84.0, | 82.2, | 87.5) |
| Real-IAD pretraining | (95.9, | 34.9, | 28.4, | 88.5) | (84.8, | 82.7, | 88.5) |
Table 4: Ablation of multiscale local memory. C4, C8, and C16 denote CNN features at strides 4, 8, and 16, respectively. Boldface and underlining follow the convention used in Table 2.
| Configuration | Pixel-level(AUROC, F1-max, AP, PRO) | Image-level(AUROC, F1-max, AP) | |||||
|---|---|---|---|---|---|---|---|
| (95.2, | 33.7, | 26.7, | 87.9) | (83.8, | 82.4, | 87.3) | |
| C8 | (95.5, | 34.5, | 27.5, | 88.2) | (84.4, | 82.4, | 87.8) |
| C16 | (95.4, | 34.3, | 27.0, | 87.3) | (84.0, | 82.3, | 87.6) |
| C4 + C8 | (95.5, | 34.1, | 27.0, | 87.4) | (84.1, | 82.1, | 87.4) |
| C8 + C16 | (95.5, | 34.4, | 27.2, | 87.5) | (84.1, | 81.9, | 87.7) |
| C4 + C8 + C16 | (95.9, | 34.9, | 28.4, | 88.5) | (84.8, | 82.7, | 88.5) |
4.3.2. Industrial Pretraining and Multiscale Memory
Table 3 varies the initialization of the frozen CNN: random initialization, generic image pretraining, or Real-IAD product-recognition pretraining. Memory construction and subsequent interactions remain unchanged. Table 4 compares single-scale features, pairs of scales, and the full feature pyramid. All variants are aligned to the same memory grid to control the token count.
Industrial pretraining improves every localization metric over both random initialization and generic pretraining. The source of learned local representations therefore affects the usefulness of the conditioning memory. The finest scale preserves detail relevant to small defects but can also respond to normal texture; the coarsest scale provides broader component context. Combining these receptive fields in the full pyramid yields the strongest localization performance in Table 4, consistent with complementary contributions to defect coverage and background suppression.
4.3.3. Refinement Architecture and Interaction Stage
Table 5 removes anchor self-attention, CNN cross-attention, and the feed-forward update individually, and examines parameter sharing across layers and memory compression. Table 6 compares direct use of the refinement output with fixed residual mixing, learned gated mixing, and direct interactions at the patch level.
Removing CNN cross-attention reduces localization performance, while anchor self-attention and the feed-forward update provide further improvements in evidence organization and transformation. Independent refinement parameters at each layer outperform full parameter sharing, supporting depth-specific mappings between ViT representations and local conditioning evidence. Table 6 assesses anchor refinement against direct patch interactions using all four localization metrics and three detection metrics. Fixed residual mixing and learned
(a) Textures and small anomalies
(b) Industrial structural defects
(c) Medical localization
(d) Local boundary differences
Sample
DTD /
Woven
DTD /
Perforated
MPDD /
Tubes
VisA /
Capsules
Brain AD /
MRI
TN3K /
Thyroid
MVTec /
Grid (ROI)
Brain AD /
MRI (ROI)
Original
GT
WinCLIP
APRIL-GAN
CLIP-AD (SDP)
AnomalyCLIP
AdaCLIP
VisualAD
CEAR


Figure 5: Qualitative comparisons for normal textures with small anomalies, industrial structural defects, medical anomaly localization, and local boundary differences. Each group contains two examples. Green and magenta contours denote the ground-truth and predicted boundaries respectively.
gated mixing further expose the trade-offs between image-level detection and pixel-level localization. Direct use of the refined anchors yields the highest scores on six metrics, although additional memory pre-normalization gives a slightly higher PRO.
4.3.4. Supervision across Layers
Table 7 compares individual layers, the three deeper layers, and all four layers. It also removes the query margin, deep region margin, shallow hard-region constraint, and fused-map supervision in turn. Applying the full segmentation loss uni-
Table 5: Ablation of memory encoding and anchor refinement. SA, CA, and FFN denote self-attention, cross-attention, and feed-forward network, respectively. Boldface and underlining follow the convention used in Table 2.
| Configuration | Pixel-level | Image-level | |||||||
|---|---|---|---|---|---|---|---|---|---|
| (AUROC, F1-max, AP, PRO) | (AUROC, F1-max, AP) | ||||||||
| Full refinement | ( | 95.9, | 34.9, | 28.4, | 88.5) | ( | 84.8, | 82.7, | 88.5) |
| w/o anchor SA | ( | 95.6, | 34.0, | 26.9, | 87.9) | ( | 84.2, | 82.2, | 87.6) |
| w/o CNN CA | ( | 95.5, | 33.9, | 27.3, | 87.5) | ( | 83.7, | 82.0, | 87.7) |
| w/o FFN | ( | 95.5, | 34.1, | 26.9, | 88.3) | ( | 84.2, | 82.3, | 87.9) |
| Shared refinement | ( | 95.6, | 34.5, | 27.3, | 88.3) | ( | 84.3, | 82.6, | 88.0) |
| w/o memory SA | ( | 95.4, | 33.7, | 27.1, | 88.1) | ( | 84.2, | 82.2, | 87.7) |
| Memory 42 × 42 | ( | 95.7, | 34.0, | 27.0, | 88.0) | ( | 84.1, | 82.2, | 87.7) |
| Memory 21 × 21 | ( | 95.6, | 33.8, | 26.8, | 87.6) | ( | 83.9, | 82.0, | 87.4) |
Table 6: Ablation of refinement-output integration and interaction stage. Direct use passes refined anchors to prototype construction while retaining internal residual connections. Patch CA (C4) applies patch-level cross-attention using stride-4 CNN features. Boldface and underlining follow the convention used in Table 2.
| Configuration | Pixel-level | Image-level | |||||||
|---|---|---|---|---|---|---|---|---|---|
| (AUROC, F1-max, AP, PRO) | (AUROC, F1-max, AP) | ||||||||
| Direct use (default) | ( | 95.9, | 34.9, | 28.4, | 88.5) | ( | 84.8, | 82.7, | 88.5) |
| Fixed mix () | ( | 95.6, | 33.9, | 26.8, | 88.2) | ( | 84.0, | 82.3, | 87.5) |
| Gated mix | ( | 95.7, | 34.2, | 27.1, | 88.5) | ( | 84.2, | 82.3, | 87.6) |
| Memory pre-norm | ( | 95.6, | 34.2, | 27.1, | 88.6) | ( | 84.3, | 82.4, | 87.7) |
| Patch CA (C4) | ( | 95.3, | 34.0, | 27.0, | 88.4) | ( | 83.3, | 81.5, | 87.1) |
Table 7: Ablation of layer selection and supervision. “All layers” denotes layers 7, 14, 21, and 27; “All-layer ” applies segmentation supervision to all four. , , , and denote query-separation, deep-region, shallow hard-region, and fused-map losses, respectively. Boldface and underlining follow the convention used in Table 2.
| Configuration | Pixel-level | Image-level | |||||||
|---|---|---|---|---|---|---|---|---|---|
| (AUROC, F1-max, AP, PRO) | (AUROC, F1-max, AP) | ||||||||
| All layers (default) | ( | 95.9, | 34.9, | 28.4, | 88.5) | ( | 84.8, | 82.7, | 88.5) |
| Layer 7 only | ( | 92.0, | 18.9, | 13.5, | 77.1) | ( | 67.9, | 76.1, | 73.8) |
| Layer 27 only | ( | 93.7, | 27.2, | 19.3, | 83.8) | ( | 84.6, | 81.8, | 87.7) |
| Layers 14/21/27 | ( | 95.4, | 34.1, | 26.9, | 88.3) | ( | 84.5, | 82.5, | 87.9) |
| All-layer | ( | 95.5, | 34.6, | 27.7, | 88.2) | ( | 84.0, | 82.2, | 87.5) |
| w/o | ( | 95.5, | 33.3, | 25.4, | 88.7) | ( | 84.7, | 82.4, | 88.4) |
| w/o | ( | 95.6, | 34.8, | 28.2, | 88.4) | ( | 84.6, | 82.2, | 87.7) |
| w/o | ( | 95.6, | 34.1, | 26.9, | 88.4) | ( | 84.4, | 82.3, | 87.9) |
| w/o | ( | 95.5, | 33.6, | 26.4, | 88.5) | ( | 84.5, | 82.5, | 88.2) |
formly to every layer provides a further control for the role of differentiated supervision.
Using the deeper branches preserves overall discrimination, but their small-defect recall remains below that of the full model. The shallow-only branch is more susceptible to responses on normal texture. The shallow hard-region constraint helps suppress local false activations, the deep region margin promotes foreground-background separation, and fused-map supervision supports regional completeness. These contributions do not improve every metric uniformly: removing the shallow region loss slightly increases PRO while reducing the other localization metrics. Taken together, the results support combining complementary layer representations with supervi- sion suited to their respective roles.

Figure 6: Layerwise visualizations examine how responses from different feature depths contribute to CEAR's fused anomaly map. Prediction columns show layers 7, 14, 21, and 27 from the same trained checkpoint, followed by the pointwise sum of their original score maps.
4.4. Qualitative Analysis
Figure 5 examines localization in four groups of examples: normal textures with small anomalies, industrial structural defects, medical anomalies, and local boundary differences. The comparisons illustrate where CEAR better distinguishes defects from normal appearance and more closely follows annotated regions than the other methods shown.
Figure 6 provides a complementary view of the layerwise behavior discussed in Section 4.3.4. It compares the branches at layers 7, 14, 21, and 27 with the sum of their scores, all from the same trained checkpoint. Two industrial and two medical examples were selected from existing inference results on domains excluded from anomaly adaptation. They illustrate spatial differences among the individual responses and the fused maps.
5. Conclusion
We presented CEAR, which integrates contextual representations and complementary local evidence through cross-encoder anchor refinement before prototype construction. Spatial anchors read from each selected ViT layer retrieve evidence from a shared local memory built by an independent encoder of the same image. Residual refinement incorporates this evidence before normal and anomalous queries gate anchor aggregation into image-conditioned prototypes. Across the comparisons on 13 industrial and medical datasets, CEAR achieves 57 best results among 68 dataset–metric evaluations, including 41 outright wins in 44 pixel-level comparisons. Across 11 localization datasets, pixel F1-max and AP improve by averages of 4.45 and 3.79 percentage points over the strongest competing result for each dataset. These findings support anchor-stage cross-encoder interaction as a means of integrating complementary visual representations for fine-grained anomaly localization across domains. The shared memory introduces additional computation, motivating future work on memory efficiency and stability under domain shifts.
References
[1] P. Bergmann, M. Fauser, D. Sattlegger, C. Steger, Mvtec ad—a comprehensive real-world dataset for unsupervised anomaly detection, in: 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), IEEE, 2019, pp. 9584–9592.
[2] C. Wang, W. Zhu, B.-B. Gao, Z. Gan, J. Zhang, Z. Gu, S. Qian, M. Chen, L. Ma, Real-iad: A real-world multi-view dataset for benchmarking versatile industrial anomaly detection, in: 2024 IEEE/CVF conference on computer vision and pattern recognition (CVPR), IEEE, 2024, pp. 22883–22892.
[3] L. Heckler-Kram, J.-H. Neudeck, U. Scheler, R. König, C. Steger, The mvtec ad 2 dataset: Advanced scenarios for unsupervised anomaly detection, International Journal of Computer Vision 134 (2026) 175.
[4] J. Jeong, Y. Zou, T. Kim, D. Zhang, A. Ravichandran, O. Dabeer, Winclip: Zero-/few-shot anomaly classification and segmentation, in: 2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), IEEE, 2023, pp. 19606–19616.
[5] Q. Zhou, G. Pang, Y. Tian, S. He, J. Chen, AnomalyCLIP: Object-agnostic prompt learning for zero-shot anomaly detection, in: The Twelfth International Conference on Learning Representations, 2024. URL: https://openreview.net/forum?id=buC4E91xZE.
[6] W. Ma, X. Zhang, Q. Yao, F. Tang, C. Wu, Y. Li, R. Yan, Z. Jiang, S. K. Zhou, Aa-clip: Enhancing zero-shot anomaly detection via anomaly-aware clip, in: 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), IEEE, 2025, pp. 4744–4754.
[7] Z. Qu, X. Tao, X. Gong, S. Qu, Q. Chen, Z. Zhang, X. Wang, G. Ding, Bayesian prompt flow learning for zero-shot anomaly detection, in: 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), IEEE, 2025, pp. 30398–30408.
[8] J. Zhu, Y.-S. Ong, C. Shen, G. Pang, Fine-grained abnormality prompt learning for zero-shot anomaly detection, in: Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2025, pp. 22241–22251.
[9] F. Wang, J. Mei, A. Yuille, Sclip: Rethinking self-attention for dense vision-language inference, in: European conference on computer vision, Springer, 2024, pp. 315–332.
[10] M. Lan, C. Chen, Y. Ke, X. Wang, L. Feng, W. Zhang, Clearclip: Decomposing clip representations for dense vision-language inference, in: European Conference on Computer Vision, Springer, 2024, pp. 143–160.
[11] T. Gong, Q. Chu, B. Liu, W. Zhou, N. Yu, Fe-clip: Frequency enhanced clip model for zero-shot anomaly detection and segmentation, in: 2025 IEEE/CVF International Conference on Computer Vision (ICCV), IEEE, 2025, pp. 21220–21230.
[12] G. Zhang, L. Zhang, Dlvp-clip: Enhancing fine-grained zero-shot anomaly detection via dynamic local visual prompting, in: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 2026, pp. 35524–35533.
[13] M. Hu, Y. Huo, M. Dou, J. Yin, P. Zhao, Y. Wang, C. Hu, B. Hu, Q. Wang, Fb-clip: Fine-grained zero-shot anomaly detection with foreground-background disentanglement, arXiv preprint arXiv:2603.19608 (2026).
[14] T. Darcet, M. Oquab, J. Mairal, P. Bojanowski, Vision transformers need registers, in: International conference on learning representations, volume 2024, 2024, pp. 2632–2652.
[15] S. Fu, M. Hamilton, L. E. Brandt, A. Feldmann, Z. Zhang, W. Freeman, Featup: A model-agnostic framework for features at any resolution, in: International Conference on Learning Representations, volume 2024, 2024, pp. 45324–45350.
[16] Y. Hou, P. Li, Z. Liu, Y. Wang, Y. Ruan, J. Qiu, K. Xu, Visualad: Language-free zero-shot anomaly detection via vision transformer, arXiv preprint arXiv:2603.07952 (2026).
[17] M. Fučka, V. Zavrtanik, D. Skočaj, Anomalyvfm-transforming vision foundation models into zero-shot anomaly detectors, arXiv preprint arXiv:2601.20524 (2026).
[18] K. Team, A. Du, B. Yin, B. Xing, B. Qu, B. Wang, C. Chen, C. Zhang, C. Du, C. Wei, et al., Kimi-vl technical report, arXiv preprint arXiv:2504.07491 (2025).
[19] C. Xia, X. Wang, F. Lv, X. Hao, Y. Shi, Vit-comer: Vision transformer with convolutional multi-scale feature interaction for dense predictions, in: 2024 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), IEEE, 2024, pp. 5493–5502.
[20] S. Woo, S. Debnath, R. Hu, X. Chen, Z. Liu, I. S. Kweon, S. Xie, Convnext v2: Co-designing and scaling convnets with masked autoencoders, in: 2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Ieee, 2023, pp. 16133–16142.
[21] Y. Cao, J. Zhang, L. Frittoli, Y. Cheng, W. Shen, G. Boracchi, Adaclip: Adapting clip with hybrid learnable prompts for zero-shot anomaly detection, in: European conference on computer vision, Springer, 2024, pp. 55–72.
[22] Z. Qu, X. Tao, M. Prasad, F. Shen, Z. Zhang, X. Gong, G. Ding, Vcp-clip: A visual context prompting model for zero-shot anomaly segmentation, in: European Conference on Computer Vision, Springer, 2024, pp. 301–317.
[23] Z. Gu, B. Zhu, G. Zhu, Y. Chen, H. Li, M. Tang, J. Wang, Filo: Zero-shot anomaly detection by fine-grained description and high-quality localization, in: Proceedings of the 32nd ACM International Conference on Multimedia, 2024, pp. 2041–2049.
[24] B.-B. Gao, Y. Zhou, J. Yan, Y. Cai, W. Zhang, M. Wang, J. Liu, Y. Liu, L. Wang, C. Wang, Adaptclip: Adapting clip for universal visual anomaly detection, in: Proceedings of the AAAI Conference on Artificial Intelligence, volume 40, 2026, pp. 4095–4103.
[25] Y. Shao, L. Wang, C. Li, P. Chen, Q. Liu, Promptmoe: Generalizable zero-shot anomaly detection via visually-guided prompt mixtures, in: Proceedings of the AAAI Conference on Artificial Intelligence, volume 40, 2026, pp. 8878–8886.
[26] X. Li, Z. Huang, F. Xue, Y. Zhou, Musc: Zero-shot industrial anomaly classification and segmentation with mutual scoring of the unlabeled images, in: International Conference on Learning Representations, volume 2024, 2024, pp. 2172–2197.
[27] X. Li, F. Xue, Y. Zhou, Musc-v2: Zero-shot multimodal industrial anomaly classification and segmentation with mutual scoring of unlabeled samples, IEEE Transactions on Pattern Analysis and Machine Intelligence (2026).
[28] J. He, M. Cao, S. Peng, Q. Xie, Rareclip: Rarity-aware online zero-shot industrial anomaly detection, in: 2025 IEEE/CVF International Conference on Computer Vision (ICCV), IEEE, 2025, pp. 24478–24487.
[29] J. Zhu, G. Pang, Toward generalist anomaly detection via in-context residual learning with few-shot sample prompts, in: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2024, pp. 17826–17836. URL: https://openaccess.thecvf.com/content/CVPR2024/html/Zhu_Toward_Generalist_Anomaly_Detection_via_In-context_Residual_Learning_with_Few-shot_CVPR_2024_paper.html.
[30] Z. Gu, B. Zhu, G. Zhu, Y. Chen, M. Tang, J. Wang, Univad: A training-free unified model for few-shot visual anomaly detection, in: 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), IEEE, 2025, pp. 15194–15203.
[31] B.-B. Gao, Metauas: Universal anomaly segmentation with one-prompt meta-learning, Advances in Neural Information Processing Systems 37 (2024) 39812–39836.
[32] J. Guo, S. Lu, W. Zhang, F. Chen, H. Li, H. Liao, Dinomaly: The less is more philosophy in multi-class unsupervised anomaly detection, in: 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), IEEE, 2025, pp. 20405–20415.
[33] Z. Gu, B. Zhu, G. Zhu, Y. Chen, W. Ge, M. Tang, J. Wang, Anomalymoe: Towards a language-free generalist model for unified visual anomaly detection, in: Proceedings of the AAAI Conference on Artificial Intelligence, volume 40, 2026, pp. 4348–4356.
[34] T. Kerssies, N. Cavagnero, A. Hermans, N. Norouzi, G. Averta, B. Leibe, G. Dubbelman, D. De Geus, Your vit is secretly an image segmentation model, in: 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), IEEE, 2025, pp. 25303–25313.
[35] J. Yang, K. Z. Luo, J. Li, C. Deng, L. Guibas, D. Krishnan, K. Q. Weinberger, Y. Tian, Y. Wang, Denoising vision transformers, in: European Conference on Computer Vision, Springer, 2024, pp. 453–469.
[36] O. Siméoni, H. V. Vo, M. Seitzer, F. Baldassarre, M. Oquab, C. Jose, V. Khalidov, M. Szafraniec, S. Yi, M. Ramamonjisoa, et al., Dinov3, arXiv preprint arXiv:2508.10104 (2025).
[37] T. Wimmer, P. Truong, M.-J. Rakotosaona, M. Oechsle, F. Tombari, B. Schiele, J. E. Lenssen, Anyup: Universal feature upsampling, in: International Conference on Learning Representations, volume 2026, 2026, pp. 140700–140720.
[38] B.-B. Gao, C. Wang, One language-free foundation model is enough for universal vision anomaly detection, arXiv preprint arXiv:2601.05552 (2026).
[39] Y. Wan, J. Cai, et al., Beyond static anchors: Bounded prototype conditioning for language-free medical anomaly detection, arXiv preprint arXiv:2608.00442 (2026).
[40] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, Ł. Kaiser, I. Polosukhin, Attention is all you need, Advances in neural information processing systems 30 (2017).
[41] T.-Y. Lin, P. Goyal, R. Girshick, K. He, P. Dollár, Focal loss for dense object detection, in: Proceedings of the IEEE international conference on computer vision, 2017, pp. 2980–2988.
[42] F. Milletari, N. Navab, S.-A. Ahmadi, V-net: Fully convolutional neural networks for volumetric medical image segmentation, in: 2016 fourth international conference on 3D vision (3DV), Ieee, 2016, pp. 565–571.
[43] S. S. M. Salehi, D. Erdogmus, A. Gholipour, Tversky loss function for image segmentation using 3d fully convolutional deep networks, in: International workshop on machine learning in medical imaging, Springer, 2017, pp. 379–387.
[44] Y. Zou, J. Jeong, L. Pemula, D. Zhang, O. Dabeer, SPot-the-Difference self-supervised pre-training for anomaly detection and segmentation, in: Computer Vision – ECCV 2022, volume 13690 of Lecture Notes in Computer Science, Springer, Cham, 2022, pp. 392–408. URL: https://doi.org/10.1007/978-3-031-20056-4_23. doi:10.1007/978-3-031-20056-4_23.
[45] P. Mishra, R. Verk, D. Fornasier, C. Piciarelli, G. L. Foresti, Vt-adl: A vision transformer network for image anomaly detection and localization, in: 2021 IEEE 30th international symposium on industrial electronics (ISIE), IEEE, 2021, pp. 01–06.
[46] T. Aota, L. T. T. Tong, T. Okatani, Zero-shot versus many-shot: Unsupervised texture anomaly detection, in: 2023 IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), IEEE, 2023, pp. 5553–5561.
[47] S. Jezek, M. Jonak, R. Burget, P. Dvorak, M. Skotak, Deep learning-based defect detection of metal parts: evaluating current methods in complex conditions, in: 2021 13th International congress on ultra modern telecommunications and control systems and workshops (ICUMT), IEEE, 2021, pp. 66–71.
[48] M. E. Chowdhury, T. Rahman, A. Khandakar, R. Mazhar, M. A. Kadir, Z. B. Mahbub, K. R. Islam, M. S. Khan, A. Iqbal, N. Al Emadi, et al., Can ai help in screening viral and covid-19 pneumonia?, Ieee Access 8 (2020) 132665–132676.
[49] T. Rahman, A. Khandakar, Y. Qiblawey, A. Tahir, S. Kiranyaz, S. B. A. Kashem, M. T. Islam, S. Al Maadeed, S. M. Zughaier, M. S. Khan, et al., Exploring the effect of image enhancement techniques on covid-19 detection using chest x-ray images, Computers in biology and medicine 132 (2021) 104319.
[50] A. Hamada, Br35H: Brain tumor detection 2020, https://www.kaggle.com/datasets/ahmedhamada0/brain-tumor-detection, 2020. Online.
[51] U. Baid, S. Ghodasara, S. Mohan, M. Bilello, E. Calabrese, E. Colak, K. Farahani, J. Kalpathy-Cramer, F. C. Kitamura, S. Pati, et al., The rsna-asnr-miccai brats 2021 benchmark on brain tumor segmentation and radiogenomic classification, arXiv preprint arXiv:2107.02314 (2021).
[52] J. Bernal, F. J. Sánchez, G. Fernández-Esparrach, D. Gil, C. Rodríguez, F. Vilariño, Wm-dova maps for accurate polyp highlighting in colonoscopy: Validation vs. saliency maps from physicians, Computerized medical imaging and graphics 43 (2015) 99–111.
[53] S. A. Hicks, D. Jha, V. Thambawita, P. Halvorsen, H. L. Hammer, M. A. Riegler, The endotect 2020 challenge: evaluation and comparison of classification, segmentation and inference time for endoscopy, in: International Conference on Pattern Recognition, Springer, 2021, pp. 263–274.
[54] D. Jha, P. H. Smedsrud, M. A. Riegler, P. Halvorsen, T. De Lange, D. Johansen, H. D. Johansen, Kvasir-seg: A segmented polyp dataset, in: International conference on multimedia modeling, Springer, 2019, pp. 451–462.
[55] D. Gutman, N. C. Codella, E. Celebi, B. Helba, M. Marchetti, N. Mishra, A. Halpern, Skin lesion analysis toward melanoma detection: A challenge at the international symposium on biomedical imaging (isbi) 2016, hosted by the international skin imaging collaboration (isic), arXiv preprint arXiv:1605.01397 (2016).
[56] H. Gong, G. Chen, R. Wang, X. Xie, M. Mao, Y. Yu, F. Chen, G. Li, Multi-task learning for thyroid nodule segmentation with thyroid region prior, in: 2021 IEEE 18th international symposium on biomedical imaging (ISBI), IEEE, 2021, pp. 257–261.
[57] I. Loshchilov, F. Hutter, Decoupled weight decay regularization, arXiv preprint arXiv:1711.05101 (2017).
[58] E. D. Cubuk, B. Zoph, J. Shlens, Q. Le, Randaugment: Practical automated data augmentation with a reduced search space, Advances in neural information processing systems 33 (2020) 18613–18624.
[59] Z. Zhong, L. Zheng, G. Kang, S. Li, Y. Yang, Random erasing data augmentation, in: Proceedings of the AAAI conference on artificial intelligence, volume 34, 2020, pp. 13001–13008.
[60] H. Zhang, M. Cisse, Y. N. Dauphin, D. Lopez-Paz, mixup: Beyond empirical risk minimization, arXiv preprint arXiv:1710.09412 (2017).
[61] S. Yun, D. Han, S. J. Oh, S. Chun, J. Choe, Y. Yoo, Cutmix: Regularization strategy to train strong classifiers with localizable features, in: Proceedings of the IEEE/CVF international conference on computer vision, 2019, pp. 6023–6032.
[62] X. Chen, Y. Han, J. Zhang, April-gan: A zero-/few-shot anomaly classification and segmentation method for cvpr 2023 vand workshop challenge tracks 1&2: 1st place on zero-shot ad and 4th place on few-shot ad, arXiv preprint arXiv:2305.17382 (2023).
[63] X. Chen, J. Zhang, G. Tian, H. He, W. Zhang, Y. Wang, C. Wang, Y. Liu, Clip-ad: A language-guided staged dual-path model for zero-shot anomaly detection, in: International Joint Conference on Artificial Intelligence, Springer, 2024, pp. 17–33.