Papers › AnomalyCLIP: Object-agnostic Prompt Learning for Zero-shot Anomaly Detection

AnomalyCLIP: Object-agnostic Prompt Learning for Zero-shot Anomaly Detection

29 Oct 2023arXiv:2310.18961archive 2025-07-28

Qihang Zhou, Guansong Pang, Yu Tian, Shibo He, Jiming Chen

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.

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="2310.18961")

Code

Syntology Ran 14 of 32 code samples harvested from 2 repositories linked to this paper; 18 have no recorded run. Of those that ran: 1 ran · honoured contract; 1 ran · violated contract; 4 ran · our draft was wrong; 1 ran · fixture could not drive it; 7 ran with no contract checked.

By repository: official repository: 18 samples from 1 repository, 12 ran; community (archive-listed): 14 samples from 1 repository, 2 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

zqhang/anomalyclip officialmentioned in papermentioned on GitHubpytorchMIT report
zqhang/Accurate-WinCLIP-pytorch mentioned on GitHubpytorch report
zqhang/WinCLIP-pytorch mentioned 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

32 samples harvested; 14 ran; 1 honoured the contract we drafted; 18 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 · honoured contract
1ran · violated contract
4ran · our draft was wrong
1ran · fixture could not drive it
7ran
18unverified

Licence: 0 of the 32 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 2 repositories linked to this paper, official or community; each sample names its own and says which. “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.

basic_clean zqhang/AnomalyCLIP/AnomalyCLIP_lib/simple_tokenizer.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 98f385d847636a3e · report
cal_pro_score zqhang/AnomalyCLIP/metrics.py official repository ran MIT (permissive) · 178a0488f0c59db0 · report
generate_class_info zqhang/AnomalyCLIP/dataset.py official repository ran MIT (permissive) · bbbfccbf329e9fdd · report
get_logger zqhang/AnomalyCLIP/logger.py official repository ran MIT (permissive) · 01e8c2f30dcaa3d3 · report
get_pairs zqhang/AnomalyCLIP/AnomalyCLIP_lib/simple_tokenizer.py official repository ran · our draft was wrong MIT (permissive) · d919ae32e5e4e616 · report
image_level_metrics zqhang/AnomalyCLIP/metrics.py official repository ran MIT (permissive) · eb13a678b5dba664 · report
load_state_dict zqhang/AnomalyCLIP/AnomalyCLIP_lib/model_load.py official repository ran MIT (permissive) · 4b3a4d17e1df3140 · report
normalize zqhang/AnomalyCLIP/utils.py official repository ran · honoured contract fingerprinted MIT (permissive) · 0c3f9d9b0ac9f33d · report
pixel_level_metrics zqhang/AnomalyCLIP/metrics.py official repository ran MIT (permissive) · cc90ad1a3ffd0e88 · report
smooth zqhang/AnomalyCLIP/loss.py official repository ran · fixture could not drive it fingerprinted MIT (permissive) · abedbe9b904a9780 · report
sparsity zqhang/AnomalyCLIP/loss.py official repository ran MIT (permissive) · 208456d9417303f4 · report
whitespace_clean zqhang/AnomalyCLIP/AnomalyCLIP_lib/simple_tokenizer.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 9542161e9640b858 · report
AnomalyCLIP zqhang/anomalyclip/AnomalyCLIP_lib/AnomalyCLIP.py official repository unverified MIT (permissive) · f8d43518b10ab859 · report
VisionTransformer zqhang/anomalyclip/AnomalyCLIP_lib/AnomalyCLIP.py official repository unverified MIT (permissive) · 175f83b44a42759d · report
build_model zqhang/AnomalyCLIP/AnomalyCLIP_lib/build_model.py official repository unverified MIT (permissive) · ed57101d91ad0e4e · report
image_transform zqhang/AnomalyCLIP/AnomalyCLIP_lib/transform.py official repository unverified MIT (permissive) · 2c38b8a1a6553df1 · report
load zqhang/AnomalyCLIP/AnomalyCLIP_lib/model_load.py official repository unverified MIT (permissive) · 45e1ef91f571e2f5 · report
load_checkpoint zqhang/AnomalyCLIP/AnomalyCLIP_lib/model_load.py official repository unverified MIT (permissive) · d53108edea9d2b46 · report
convert_to_custom_text_state_dict zqhang/WinCLIP-pytorch/src/open_clip/model.py community (archive-listed) ran · violated contract MIT (permissive) · f19962ebb134b3d7 · report
get_cast_dtype zqhang/WinCLIP-pytorch/src/open_clip/model.py community (archive-listed) ran · our draft was wrong MIT (permissive) · dcd422d66b0581d8 · report
apply_ad_scoremap zqhang/WinCLIP-pytorch/reproduce_WinCLIP.py community (archive-listed) unverified MIT (permissive) · f09367dd0e4c9c94 · report
build_model_from_openai_state_dict zqhang/WinCLIP-pytorch/src/open_clip/model.py community (archive-listed) unverified MIT (permissive) · e332828701fffe70 · report
build_model_from_openai_state_dict zqhang/WinCLIP-pytorch/src/open_clip/model_revise.py community (archive-listed) unverified MIT (permissive) · e0b318791c717866 · report
cal_pro_score zqhang/WinCLIP-pytorch/reproduce_WinCLIP.py community (archive-listed) unverified MIT (permissive) · e6a423edd53e011c · report
gather_features zqhang/WinCLIP-pytorch/src/open_clip/loss.py community (archive-listed) unverified MIT (permissive) · ddcbd45e940484ee · report
get_model_config zqhang/WinCLIP-pytorch/src/open_clip/factory.py community (archive-listed) unverified MIT (permissive) · 5c7cf820e99443ff · report
get_tokenizer zqhang/WinCLIP-pytorch/src/open_clip/factory.py community (archive-listed) unverified MIT (permissive) · f34d8f34635af394 · report
initialize_memory zqhang/WinCLIP-pytorch/few_shot.py community (archive-listed) unverified MIT (permissive) · 8019976ff0ac258f · report
load_openai_model zqhang/WinCLIP-pytorch/src/open_clip/openai.py community (archive-listed) unverified MIT (permissive) · a1693b09a14a516f · report
memory zqhang/WinCLIP-pytorch/few_shot.py community (archive-listed) unverified MIT (permissive) · db75b22fe2d18129 · report
prepare_inputs_for_generation zqhang/WinCLIP-pytorch/src/open_clip/coca_model.py community (archive-listed) unverified MIT (permissive) · fb651d0a97fd4d3f · report
register_pooler zqhang/WinCLIP-pytorch/src/open_clip/hf_model.py community (archive-listed) unverified MIT (permissive) · 2a377da4a76a2d44 · report

Tasks

Anomaly DetectionPrompt LearningZero-Shot Learningzero-shot anomaly detection

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Anomaly Detection MVTec AD AnomalyCLIP Detection AUROC 91.5 #109 of 148 Archive leaderboard report
Anomaly Detection MVTec AD AnomalyCLIP Segmentation AUPRO 81.4 #109 of 148 Archive leaderboard report
Anomaly Detection MVTec AD AnomalyCLIP Segmentation AUROC 91.1 #109 of 148 Archive leaderboard report
Anomaly Detection VisA AnomalyCLIP Detection AUROC 82.1 #39 of 50 Archive leaderboard report
Anomaly Detection VisA AnomalyCLIP Segmentation AUPRO 87.0 #39 of 50 Archive leaderboard report
Anomaly Detection VisA AnomalyCLIP Segmentation AUROC 95.5 #39 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

CLIPFocus

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