[Paper Review] AnomalyCLIP: Object-agnostic Prompt Learning for Zero-shot Anomaly Detection
AnomalyCLIP adapts CLIP by learning object-agnostic text prompts that capture generic normality and abnormality, enabling improved zero-shot anomaly detection and segmentation across diverse industrial and medical domains.
Zero-shot anomaly detection (ZSAD) requires detection models trained using auxiliary data to detect anomalies without any training sample in a target dataset. It is a crucial task when training data is not accessible due to various concerns, eg, data privacy, yet it is challenging since the models need to generalize to anomalies across different domains where the appearance of foreground objects, abnormal regions, and background features, such as defects/tumors on different products/organs, can vary significantly. Recently large pre-trained vision-language models (VLMs), such as CLIP, have demonstrated strong zero-shot recognition ability in various vision tasks, including anomaly detection. However, their ZSAD performance is weak since the VLMs focus more on modeling the class semantics of the foreground objects rather than the abnormality/normality in the images. In this paper we introduce a novel approach, namely AnomalyCLIP, to adapt CLIP for accurate ZSAD across different domains. The key insight of AnomalyCLIP is to learn object-agnostic text prompts that capture generic normality and abnormality in an image regardless of its foreground objects. This allows our model to focus on the abnormal image regions rather than the object semantics, enabling generalized normality and abnormality recognition on diverse types of objects. Large-scale experiments on 17 real-world anomaly detection datasets show that AnomalyCLIP achieves superior zero-shot performance of detecting and segmenting anomalies in datasets of highly diverse class semantics from various defect inspection and medical imaging domains. Code will be made available at https://github.com/zqhang/AnomalyCLIP.
Motivation & Objective
- Motivate zero-shot anomaly detection (ZSAD) when target-domain training data are unavailable due to privacy or novelty.
- Develop a CLIP-based method that focuses on abnormality/normality rather than object semantics.
- Learn generic normality and abnormality prompts that transfer across diverse object classes and domains.
- Combine global and local context to capture both coarse and fine-grained anomaly cues.
Proposed method
- Introduce object-agnostic text prompt templates for normality and abnormality, replacing specific object names with generic tokens.
- Use a glocal context optimization that jointly minimizes global (image-level) and local (pixel-level) losses to learn prompts from auxiliary data.
- Apply text prompt tuning by inserting learnable tokens into the CLIP text encoder to refine the textual space.
- Incorporate Diagonally Prominent Attention Maps (DPAM) to refine local visual features via alternative self-attention schemes in the visual encoder.
- Fuse global and local visual-semantic alignments to produce image-level anomaly scores and pixel-level anomaly maps for zero-shot inference.
Experimental results
Research questions
- RQ1Can object-agnostic prompts learn generic abnormality/normality patterns that transfer across diverse object semantics?
- RQ2Does combining global and local context during prompt learning improve zero-shot anomaly detection and segmentation?
- RQ3How do prompt refinement (text and visual spaces) impact cross-domain ZSAD performance?
- RQ4Is the proposed approach robust across industrial and medical imaging domains without target-domain fine-tuning?
Key findings
- AnomalyCLIP achieves superior zero-shot anomaly detection and segmentation across 17 real-world datasets from industrial and medical domains.
- Object-agnostic prompts better generalize to unseen objects and anomalies than object-aware prompts.
- Global and local context optimization, along with textual space refinement and DPAM, consistently improve performance.
- A medical-domain generalization is observed when prompts learned on industrial data are applied to medical datasets, with further improvements when medical auxiliary data are used for prompting.
- Compared to several baselines, AnomalyCLIP demonstrates strong cross-domain ZSAD capabilities, highlighting the benefit of object-agnostic prompt learning for anomaly patterns.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.