GenCLIP: Generalizing CLIP Prompts for Zero-shot Anomaly Detection
Donghyeong Kim, Chaewon Park, Suhwan Cho, Hyeonjeong Lim, Minseok Kang, Jungho Lee, Sangyoun Lee
TL;DR
GenCLIP tackles zero-shot anomaly detection by learning stable, general text prompts augmented with multi-layer CLIP visual features through MVPs, coupled with a dual-branch inference that balances generalization and category-specific cues. The framework introduces General Query Prompt tokens (GQPs), Multi-layer Vision Prompt tokens (MVPs), and Class Name Filtering (CNF) to enhance vision-language alignment across unseen object classes, training with focal and Dice losses on layer-wise anomaly maps. Inference combines a vision-enhanced branch and a query-only branch to produce robust pixel-level segmentation and image-level detection, achieving state-of-the-art performance on six industrial datasets. This approach offers strong generalization and precise localization, enabling practical zero-shot anomaly detection in varied manufacturing contexts.
Abstract
Zero-shot anomaly detection (ZSAD) aims to identify anomalies in unseen categories by leveraging CLIP's zero-shot capabilities to match text prompts with visual features. A key challenge in ZSAD is learning general prompts stably and utilizing them effectively, while maintaining both generalizability and category specificity. Although general prompts have been explored in prior works, achieving their stable optimization and effective deployment remains a significant challenge. In this work, we propose GenCLIP, a novel framework that learns and leverages general prompts more effectively through multi-layer prompting and dual-branch inference. Multi-layer prompting integrates category-specific visual cues from different CLIP layers, enriching general prompts with more comprehensive and robust feature representations. By combining general prompts with multi-layer visual features, our method further enhances its generalization capability. To balance specificity and generalization, we introduce a dual-branch inference strategy, where a vision-enhanced branch captures fine-grained category-specific features, while a query-only branch prioritizes generalization. The complementary outputs from both branches improve the stability and reliability of anomaly detection across unseen categories. Additionally, we propose an adaptive text prompt filtering mechanism, which removes irrelevant or atypical class names not encountered during CLIP's training, ensuring that only meaningful textual inputs contribute to the final vision-language alignment.
