VisualAD: Language-Free Zero-Shot Anomaly Detection via Vision Transformer

Yanning Hou, Peiyuan Li, Zirui Liu, Yitong Wang, Yanran Ruan, Jianfeng Qiu, Ke Xu

TL;DR

VisualAD challenges the status quo of zero-shot anomaly detection by ditching the text branch of vision-language models entirely. By directly injecting learnable "normal" and "abnormal" visual tokens into a frozen Vision Transformer, it achieves state-of-the-art performance across 13 industrial and medical benchmarks while slashing trainable parameters by 99% and stabilizing training.

What Problem Does This Paper Address?

Zero-shot anomaly detection (ZSAD) aims to identify and localize defects in images without having seen any anomaly samples from that specific category during training. Current state-of-the-art methods rely heavily on Vision-Language Models (VLMs) like CLIP. They use text prompts (e.g., "a photo of a normal object" vs. "a photo of a damaged object") to create text embeddings that act as reference prototypes for comparison.

However, the authors ask a fundamental question: Is language actually necessary for a purely visual task like anomaly detection? Relying on text encoders introduces massive parameter redundancy, training instability (oscillating evaluation curves), and cross-modal alignment difficulties. VisualAD aims to solve this by proving that discriminative anomaly features can be learned purely within the visual domain.

Methods

VisualAD introduces a purely visual, Vision Transformer (ViT)-only framework. Instead of relying on text prompts, it injects two learnable global tokens—an anomaly token ($t_a$) and a normal token ($t_n$)—directly into the input sequence of a frozen ViT backbone (such as CLIP's image encoder or DINOv2).

To make these global tokens aware of local details and spatial structures, the architecture incorporates two key components at intermediate layers:

  1. Spatial-Aware Cross-Attention (SCA): Global tokens naturally lack spatial grounding. SCA uses a small set of learnable anchor queries to aggregate localized spatial evidence from patch features and dynamically updates the tokens based on the local structure of the test image.
  2. Self-Alignment Function (SAF): A lightweight, one-hidden-layer MLP that nonlinearly recalibrates patch features before they are compared to the tokens.

Anomaly maps are generated by computing the cosine similarity difference between the enhanced tokens and the recalibrated patches across multiple intermediate layers. These maps are then upsampled and fused to produce the final anomaly map.

Overview of the VisualAD architecture showing the token injection and the SCA/SAF modules.

Datasets

The model is evaluated across 13 real-world datasets spanning two major domains:

  • Industrial: MVTec-AD, VisA, BTAD, KSDD2, DAGM, and DTD-Synthetic.
  • Medical: OCT17 (retinal scans), BrainMRI, BrainAD, HIS (histopathology), CVC-ClinicDB, Endo, and Kvasir (colonoscopy polyp segmentation).

To enforce the zero-shot protocol, the model is trained on an auxiliary dataset (typically VisA or MVTec-AD) and directly evaluated on completely unseen categories and domains (such as the medical datasets) without any category-specific fine-tuning.

Key Insights and Ideas

  • Text as an Unnecessary Middleman: The authors' pilot study showed that removing CLIP's text encoder and directly optimizing visual prototype vectors resulted in virtually no performance degradation. Text prompts in ZSAD primarily serve as an indirect way to shape visual prototypes rather than providing essential semantic grounding.
  • Smoother Optimization: Purely visual optimization eliminates the training oscillations common in VLM-based methods. VisualAD exhibits a steady, smooth upward trend in performance across training epochs compared to the erratic fluctuations seen in text-aligned models.
  • Multi-Layer Synergy: Mid-level layers in the ViT excel at capturing fine-grained defect boundaries, while deeper layers capture broader, normal regional context. Fusing these layers provides a highly robust anomaly map.

Key Results

  • Massive Parameter Savings: By removing the text branch, VisualAD reduces the number of trainable prototype parameters by 99% (from 5.7M down to just a pair of 768-dimensional vectors), while maintaining or exceeding state-of-the-art accuracy.
  • State-of-the-Art Performance: VisualAD achieves top-tier results across all 13 benchmarks. When paired with a CLIP ViT-L backbone, it dominates image-level classification metrics, while pairing it with DINOv2 yields superior pixel-level segmentation precision.
  • Cross-Domain Generalization: Despite being trained only on industrial data, VisualAD generalizes remarkably well to complex medical imaging modalities (like MRI and OCT scans), producing cleaner boundaries and fewer false positives than VLM-based competitors.
Figure 3. Qualitative comparison of anomaly segmentation results for different ZSAD methods. The first five columns show images from industrial datasets, while the last three columns correspond to medical datasets.

Limitations and Future Work

While VisualAD is highly efficient, the authors note a few areas for future improvement:

  • Fixed Layer Selection: The current framework extracts features from a predetermined set of intermediate layers. Implementing an adaptive layer selection mechanism could optimize performance for specific target domains.
  • Token Granularity: Future iterations could explore richer, structured tokens to capture finer sub-categories of anomalies.
  • Uncertainty Estimation: Incorporating lightweight uncertainty estimation would help the model better handle extreme domain shifts and improve safety-critical deployment.

Summary updated

BibTeX
@inproceedings{hou2026visualad,
  author = {Yanning Hou and Peiyuan Li and Zirui Liu and Yitong Wang and Yanran Ruan and Jianfeng Qiu and Ke Xu},
  title = {{VisualAD: Language-Free Zero-Shot Anomaly Detection via Vision Transformer}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2026},
  url = {https://openreview.net/forum?id=jzLurQdLXw},
}
Figure