Abstract
Anomaly detection (AD) identifies outliers for applications like defect and lesion detection. While CLIP shows promise for zero-shot AD tasks due to its strong generalization capabilities, its inherent Anomaly-Unawareness leads to limited discrimination between normal and abnormal features. To address this problem, we propose Anomaly-Aware CLIP (AA-CLIP), which enhances CLIP's anomaly discrimination ability in both text and visual spaces while preserving its generalization capability. AA-CLIP is achieved through a straightforward yet effective two-stage approach: it first creates anomaly-aware text anchors to differentiate normal and abnormal semantics clearly, then aligns patch-level visual features with these anchors for precise anomaly localization. This two-stage strategy, with the help of residual adapters, gradually adapts CLIP in a controlled manner, achieving effective AD while maintaining CLIP's class knowledge. Extensive experiments validate AA-CLIP as a resource-efficient solution for zero-shot AD tasks, achieving state-of-the-art results in industrial and medical applications.
Introduction
Anomaly Detection (AD) is a critical task in computer vision, essential for identifying manufacturing defects or medical lesions. While Large Vision-Language Models like CLIP have demonstrated remarkable "zero-shot" capabilities, they often suffer from Anomaly-Unawareness. Because CLIP is trained on general-purpose datasets, its internal representation of an anomaly is frequently entangled with the object's identity. For instance, the text embeddings for "a normal carpet" and "a broken carpet" may be nearly indistinguishable in CLIP's feature space, hindering the model's ability to precisely locate defects.
Methodology
AA-CLIP addresses the anomaly-unawareness problem through a controlled, two-stage adaptation strategy that injects anomaly awareness into CLIP without compromising its pre-trained knowledge.
Stage 1: Disentangling Anomaly-Aware Text Anchors
In the first stage, the vision encoder is frozen while the text encoder is adapted. The researchers introduce a Disentangle Loss designed to encourage orthogonality between normal and abnormal text embeddings. This process creates distinct semantic "anchors" in the feature space, clearly separating the concepts of "normal" and "abnormal."
Stage 2: Aligning Patch Features
With the text anchors established, the vision encoder is then adapted. The goal is to align patch-level visual features with these new semantic anchors. This alignment allows the model to perform precise anomaly localization (segmentation) by mapping visual patches directly to the disentangled "normal" or "abnormal" semantic regions.
Technical Innovation: Residual Adapters
To avoid "catastrophic forgetting" of CLIP's general knowledge, AA-CLIP employs lightweight Residual Adapters in the shallow layers of both encoders. A hyperparameter ($\lambda$) controls the influence of the new anomaly-specific features relative to the original pre-trained features, ensuring the model remains generalizable to unseen classes.
Experimental Results
AA-CLIP was evaluated on 11 benchmarks across industrial (e.g., MVTec AD, VisA) and medical (e.g., BMAD, colon polyp detection) domains.
- State-of-the-Art Performance: The model set new benchmarks for zero-shot AD, achieving an average Pixel-level AUROC of 93.4% across all datasets.
- Data Efficiency: In few-shot scenarios, AA-CLIP with only 2 samples per class outperformed many existing models trained on full datasets.
- Cross-Domain Robustness: The model demonstrated significant generalization capability; for example, a model trained on industrial defects could effectively identify medical lesions in MRI scans.
Conclusion
AA-CLIP provides a resource-efficient solution for zero-shot anomaly detection by addressing the semantic bottleneck of Anomaly-Unawareness. By disentangling text anchors and aligning visual features through a two-stage approach with residual adapters, AA-CLIP achieves state-of-the-art performance while maintaining the broad generalization capabilities of the original CLIP model.
Summary updated