Papers › AdaCLIP: Adapting CLIP with Hybrid Learnable Prompts for Zero-Shot Anomaly Detection

AdaCLIP: Adapting CLIP with Hybrid Learnable Prompts for Zero-Shot Anomaly Detection

22 Jul 2024arXiv:2407.15795archive 2025-07-28

Yunkang Cao, Jiangning Zhang, Luca Frittoli, Yuqi Cheng, Weiming Shen, Giacomo Boracchi

Zero-shot anomaly detection (ZSAD) targets the identification of anomalies within images from arbitrary novel categories. This study introduces AdaCLIP for the ZSAD task, leveraging a pre-trained vision-language model (VLM), CLIP. AdaCLIP incorporates learnable prompts into CLIP and optimizes them through training on auxiliary annotated anomaly detection data. Two types of learnable prompts are proposed: static and dynamic. Static prompts are shared across all images, serving to preliminarily adapt CLIP for ZSAD. In contrast, dynamic prompts are generated for each test image, providing CLIP with dynamic adaptation capabilities. The combination of static and dynamic prompts is referred to as hybrid prompts, and yields enhanced ZSAD performance. Extensive experiments conducted across 14 real-world anomaly detection datasets from industrial and medical domains indicate that AdaCLIP outperforms other ZSAD methods and can generalize better to different categories and even domains. Finally, our analysis highlights the importance of diverse auxiliary data and optimized prompts for enhanced generalization capacity. Code is available at https://github.com/caoyunkang/AdaCLIP.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2407.15795")

Code

Syntology Ran 19 of 28 code samples harvested from 1 repository linked to this paper; 9 have no recorded run. Of those that ran: 1 ran · violated contract; 4 ran · our draft was wrong; 14 ran with no contract checked.

By repository: official repository: 28 samples from 1 repository, 19 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

caoyunkang/adaclip officialmentioned in papermentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

28 samples harvested; 19 ran; 0 honoured the contract we drafted; 9 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · violated contract
4ran · our draft was wrong
14ran
9unverified

Licence: 0 of the 28 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from caoyunkang/AdaCLIP. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

AttentionalPooler caoyunkang/AdaCLIP/method/adaclip.py official repository ran MIT (permissive) · 8933c7b9c7e59316 · report
CLIPTextCfg caoyunkang/AdaCLIP/method/adaclip.py official repository ran MIT (permissive) · d53cfe614e64f0f8 · report
CLIPVisionCfg caoyunkang/AdaCLIP/method/adaclip.py official repository ran MIT (permissive) · 358336605882f8ac · report
HybridSemanticFusion caoyunkang/AdaCLIP/method/adaclip.py official repository ran MIT (permissive) · 7fef9e3e704a163e · report
LayerNorm caoyunkang/AdaCLIP/method/adaclip.py official repository ran fingerprinted MIT (permissive) · 60328965616e6752 · report
LayerNormFp32 caoyunkang/AdaCLIP/method/adaclip.py official repository ran fingerprinted MIT (permissive) · 7a539f31051f66e9 · report
PatchDropout caoyunkang/AdaCLIP/method/adaclip.py official repository ran fingerprinted MIT (permissive) · a47771f643ef84d8 · report
ProjectLayer caoyunkang/AdaCLIP/method/adaclip.py official repository ran MIT (permissive) · 9bb8bb245a3e6712 · report
PromptLayer caoyunkang/AdaCLIP/method/adaclip.py official repository ran MIT (permissive) · baa7068d196ec4c6 · report
ResidualAttentionBlock caoyunkang/AdaCLIP/method/adaclip.py official repository ran MIT (permissive) · 7affcf897896a315 · report
TextTransformer caoyunkang/AdaCLIP/method/adaclip.py official repository ran MIT (permissive) · f60673dd45a8761e · report
basic_clean caoyunkang/adaclip/method/simple_tokenizer.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 98f385d847636a3e · report
convert_to_custom_text_state_dict caoyunkang/adaclip/method/clip_model.py official repository ran · violated contract MIT (permissive) · f19962ebb134b3d7 · report
get_cast_dtype caoyunkang/adaclip/method/clip_model.py official repository ran · our draft was wrong MIT (permissive) · dcd422d66b0581d8 · report
get_pairs caoyunkang/adaclip/method/simple_tokenizer.py official repository ran · our draft was wrong MIT (permissive) · d919ae32e5e4e616 · report
list_pretrained caoyunkang/adaclip/method/custom_clip.py official repository ran MIT (permissive) · c213fb0a0028da05 · report
list_pretrained_models_by_tag caoyunkang/adaclip/method/custom_clip.py official repository ran fingerprinted MIT (permissive) · 63bcf6e40f415106 · report
list_pretrained_tags_by_model caoyunkang/adaclip/method/custom_clip.py official repository ran fingerprinted MIT (permissive) · 1fe3bf9de033fd8f · report
whitespace_clean caoyunkang/adaclip/method/simple_tokenizer.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 9542161e9640b858 · report
AdaCLIP caoyunkang/AdaCLIP/method/adaclip.py official repository unverified MIT (permissive) · ccef093b595414f9 · report
CLIP caoyunkang/AdaCLIP/method/adaclip.py official repository unverified MIT (permissive) · 7dd2e9759231f093 · report
TextEmbebddingLayer caoyunkang/AdaCLIP/method/adaclip.py official repository unverified MIT (permissive) · 6e78fb5e970d4a0b · report
Transformer caoyunkang/AdaCLIP/method/adaclip.py official repository unverified MIT (permissive) · 2480af5fe5844d5b · report
VisionTransformer caoyunkang/AdaCLIP/method/adaclip.py official repository unverified MIT (permissive) · 51acd62f8b9ee4da · report
_build_text_tower caoyunkang/AdaCLIP/method/adaclip.py official repository unverified MIT (permissive) · 432535468a1356fd · report
_build_vision_tower caoyunkang/AdaCLIP/method/adaclip.py official repository unverified MIT (permissive) · 98b01b93d323fa78 · report
build_model_from_openai_state_dict caoyunkang/adaclip/method/clip_model.py official repository unverified MIT (permissive) · 5d5046aaa43f74c7 · report
freeze_batch_norm_2d caoyunkang/adaclip/method/utils.py official repository unverified MIT (permissive) · 9b5765523c6d17fd · report

Tasks

Anomaly DetectionLanguage ModelingLanguage Modellingzero-shot anomaly detection

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Anomaly Detection MPDD AdaCLIP Detection AUROC 82.5 #13 of 16 Archive leaderboard report
Anomaly Detection MPDD AdaCLIP Segmentation AUROC 96.1 #13 of 16 Archive leaderboard report
Anomaly Detection MVTec AD AdaCLIP Detection AUROC 89.2 #113 of 148 Archive leaderboard report
Anomaly Detection MVTec AD AdaCLIP Segmentation AUROC 88.7 #113 of 148 Archive leaderboard report
Anomaly Detection VisA AdaCLIP Detection AUROC 85.8 #34 of 50 Archive leaderboard report
Anomaly Detection VisA AdaCLIP Segmentation AUROC 95.5 #34 of 50 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Methods

CLIP

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections