Co-Evolutionary Prompt Optimization with Cross-Category Transfer for Zero-Shot Anomaly Detection
Organizations: Institute of Information Science, Beijing Jiaotong University, Beijing, China · Institute of Automation, Chinese Academy of Sciences, Beijing, China
Abstract
Zero-shot anomaly detection (ZSAD) has gained significant attention for its practical value in industrial inspection. Recently, CLIP-based approaches have been widely adopted in ZSAD due to their strong vision-language generalization capabilities. However, existing methods commonly employ continuous prompt embeddings for prompt optimization and encode semantics in latent vectors, which lack interpretability and scalability. To this end, we propose CoEvoAD, a co-evolutionary framework for discrete prompt selection. CoEvoAD performs prompt search in the discrete natural-language space using an evolutionary algorithm. Candidate prompts are iteratively generated, evaluated, and selected throughout population evolution, thus preserving the interpretability and composability of natural language. Furthermore, we introduce a Cross-Category Transfer Objective (CCTO), which treats held-out source categories as proxies for unseen categories and scores prompt rules based on their estimated cross-category transferability, effectively improving cross-category generalization. Extensive experiments are conducted to validate the effectiveness of CoEvoAD, and the results show that it achieves state-of-the-art performance across multiple anomaly detection datasets. The code is available at https://github.com/rstao-bjtu/CoEvoAD.
Figures & tables
| Method Dataset | WinCLIP (CVPR’23) | AnomalyCLIP (ICLR’24) | AdaCLIP (ECCV’24) | Bayes-PFL (CVPR’25) | MRAD (ICLR’26) | CoEvoAD (Ours) | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AUROC | AP | AUROC | AP | AUROC | AP | AUROC | AP | AUROC | AP | AUROC | AP | |
| MVTec-AD | 91.8 | 95.1 | 91.5 | 96.2 | 92.0 | 96.4 | 92.3 | 96.7 | 94.0 | 97.4 | 93.4 | 96.8 |
| VisA | 78.1 | 77.5 | 82.1 | 85.4 | 83.0 | 84.9 | 87.0 | 89.2 | 85.7 | 88.3 | 87.4 | 89.7 |
| BTAD | 83.3 | 84.1 | 89.1 | 91.1 | 91.6 | 92.4 | 93.2 | 96.5 | 92.4 | 94.2 | 94.4 | 96.1 |
| KSDD2 | 93.5 | 77.9 | 92.1 | 77.8 | 95.9 | 95.9 | 97.3 | 97.9 | 95.1 | 88.9 | 97.4 | 97.9 |
| DAGM | 89.6 | 90.4 | 95.6 | 94.6 | 96.5 | 95.7 | 97.7 | 97.0 | 98.4 | 98.6 | 98.2 | 97.6 |
| Method Dataset | WinCLIP (CVPR’23) | AnomalyCLIP (ICLR’24) | AdaCLIP (ECCV’24) | Bayes-PFL (CVPR’25) | MRAD (ICLR’26) | CoEvoAD (Ours) | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AUROC | PRO | AUROC | PRO | AUROC | PRO | AUROC | PRO | AUROC | PRO | AUROC | PRO | |
| MVTec-AD | 85.1 | 64.6 | 91.1 | 81.4 | 86.8 | 33.8 | 91.8 | 87.4 | 93.0 | 86.8 | 92.2 | 87.9 |
| VisA | 79.6 | 56.8 | 95.5 | 87.0 | 95.1 | 71.3 | 95.6 | 88.9 | 95.9 | 88.0 | 95.8 | 89.4 |
| BTAD | 71.4 | 32.8 | 93.3 | 69.3 | 87.7 | 17.1 | 93.9 | 76.6 | 95.4 | 72.8 | 94.7 | 81.9 |
| KSDD2 | 97.9 | 91.2 | 99.1 | 85.6 | 99.4 | 92.7 | 96.1 | 70.8 | 98.9 | 95.6 | 99.6 | 98.5 |
| DAGM | 83.2 | 55.4 | 99.1 | 93.6 | 97.0 | 40.9 | 99.3 | 98.0 | 97.4 | 90.3 | 99.5 | 98.3 |
| Target | Metric | Control | CoEvoAD | |
|---|---|---|---|---|
| MVTec-AD | Image AUROC | 93.01 | 93.39 | +0.38 |
| Pixel AP | 47.48 | 47.72 | +0.24 | |
| Pixel F1 | 47.69 | 47.96 | +0.27 | |
| VisA | Image AUROC | 87.05 | 87.43 | +0.38 |
| Pixel AP | 30.51 | 31.11 | +0.60 | |
| Pixel F1 | 36.21 | 36.72 | +0.51 |
| Dir. | Metric | Mean | Bot- | Worst |
|---|---|---|---|---|
| MVTec | Pixel AP | +0.24 | +0.51 | 0.48 |
| Pixel F1 | +0.27 | +0.45 | 0.41 | |
| VisA | Pixel AP | +0.60 | +0.78 | 3.27 |
| Pixel F1 | +0.51 | +0.77 | 3.37 |
| Category | Normal rule | Abnormal rule |
|---|---|---|
| screw | clean surface screw | broken shape with missing parts |
| bottle | normal bottle | irregular visible surface bottle |
| grid | regular standard grid | faulty flawed abnormal grid |
| toothbrush | a photo of a healthy toothbrush | faulty toothbrush |
| pcb2 | flawless fine pcb2 | structural defect like a hole or cut |
| cashew | a photo of healthy cashew | faulty flawed cashew |
| Target | Metric | Baseline | CoEvo | CoEvo +CCTO |
|---|---|---|---|---|
| MVTec-AD | Image AUROC | 93.01 | 93.06 | 93.39 |
| Pixel AP | 47.48 | 47.52 | 47.72 | |
| Pixel F1 | 47.69 | 47.67 | 47.96 | |
| VisA | Image AUROC | 87.05 | 87.02 | 87.43 |
| Pixel AP | 30.51 | 30.98 | 31.11 | |
| Pixel F1 | 36.21 | 36.33 | 36.72 |
| Method | Backbone / res. | ms/img |
|---|---|---|
| Bayes-PFL (reproduced) | ViT-L/14@336px / 518 | 221.0 |
| AdaCLIP (released ckpt) | ViT-L/14@336px / 518 | 114.56 |
| MRAD (released ckpt) | ViT-L/14@336px / 518 | 103.55 |
| AnomalyCLIP (reproduced) | ViT-L/14@336px / 518 | 75.97 |
| WinCLIP † (training-free) | ViT-B/16+240 / 240 | 56.08 |
| Class-name control | ViT-L/14@336px / 518 | 55.00 |
Appendix figures & tables45 assets
Supplementary material from the paper’s appendix.
Appendix
| Dataset | Classes | Normal | Anomalous |
|---|---|---|---|
| MVTec-AD Bergmann et al. (2019) | 15 | 467 | 1,258 |
| VisA Zou et al. (2022) | 12 | 962 | 1,200 |
| BTAD Mishra et al. (2021) | 3 | 451 | 290 |
| KSDD2 Božič et al. (2021) | 1 | 356 | 356 |
| RSDD Niu et al. (2021) | 1 | 387 | 387 |
| DAGM (7-class subset) Wieler et al. (2007) | 7 | 1,350 | 1,350 |
| Component | Setting |
|---|---|
| Backbone | CLIP ViT-L/14@336px |
| Input resolution | |
| Stage 1 epochs / optimiser | 30 / AdamW, cosine annealing |
| Stage 1 learning rates | prompt , other |
| Prompt groups / context / state | 3 / 5 / 5 |
| Search population | 16 |
| Variant | AUROC | AP px |
|---|---|---|
| Full training setup (control) | 93.01 | 47.48 |
| mask-guided crop | 92.94 ( 0.07) | 46.35 ( 1.13) |
| inter-role margin | 92.83 ( 0.18) | 47.04 ( 0.44) |
| agnostic reg. | 93.01 ( 0.00) | 47.09 ( 0.39) |
| Dir. | Evals/role | Wall-clock | ||||
|---|---|---|---|---|---|---|
| MVTec (src VisA) | 12 | 16 | 5 | 3 | 960 | 3 h 47 m |
| VisA (src MVTec-AD) | 15 | 16 | 5 | 3 | 1200 | 5 h 34 m |
| Evals/role | Wall-clock (h) | s/eval | |
|---|---|---|---|
| 3 | 240 | 0.34 | 5.1 |
| 6 | 480 | 1.12 | 8.4 |
| 9 | 720 | 2.38 | 11.9 |
| 12 | 960 | 3.71 | 13.9 |
| MVTec-AD | VisA | |||||
| Method | Role-sep. | CCTO | AUROC img | AP px | AUROC img | AP px |
| Class-name control (R0) | ✗ | ✗ | 93.01 | 47.48 | 87.05 | 30.51 |
| Random prompt-pair search | ✗ | ✗ | 93.09 | 47.47 | 86.10 | 31.03 |
| Random prompt-pair search CCTO | ✗ | ✓ | 93.23 | 47.45 | 86.90 | 30.80 |
| Single-population evolutionary algorithm | ✗ | ✗ | 93.15 | 47.43 | 86.81 | 30.58 |
| Single-population evolutionary algorithm CCTO | ✗ | ✓ | 93.24 | 47.54 | 86.90 | 30.62 |
| AUROC img | AP px | F1 px | |||||||
|---|---|---|---|---|---|---|---|---|---|
| Category | C | E | C | E | C | E | |||
| bottle | 94.76 | 94.84 | +0.08 | 67.19 | 66.97 | 0.22 | 63.09 | 62.92 | 0.17 |
| cable | 82.27 | 83.36 | +1.09 | 12.49 | 12.01 | 0.48 | 20.09 | 19.98 | 0.11 |
| capsule | 94.50 | 94.30 | 0.20 | 36.72 | 36.67 | 0.05 | 39.85 | 39.44 | 0.41 |
| carpet | 100.00 | 100.00 | +0.00 | 82.69 | 82.98 | +0.29 | 74.93 | 75.22 | +0.29 |
| grid | 100.00 | 100.00 | +0.00 | 41.38 | 40.97 | 0.41 | 42.70 | 42.75 | +0.05 |
| AUROC img | AP px | F1 px | |||||||
|---|---|---|---|---|---|---|---|---|---|
| Category | C | E | C | E | C | E | |||
| candle | 90.02 | 90.67 | +0.65 | 33.69 | 33.53 | 0.16 | 44.08 | 43.55 | 0.53 |
| capsules | 92.95 | 91.95 | 1.00 | 49.56 | 52.27 | +2.71 | 54.92 | 55.78 | +0.86 |
| cashew | 93.84 | 93.36 | 0.48 | 36.35 | 37.40 | +1.05 | 42.16 | 42.68 | +0.52 |
| chewinggum | 97.38 | 97.00 | 0.38 | 83.18 | 83.12 | 0.06 | 75.45 | 75.53 | +0.08 |
| fryum | 90.68 | 90.92 | +0.24 | 27.95 | 27.60 | 0.35 | 33.19 | 32.92 | 0.27 |
| VisA MVTec-AD | MVTec-AD VisA | |||
| AUROC img | AP px | AUROC img | AP px | |
| Seed 111 | 93.39 | 47.72 | 87.43 | 31.11 |
| Seed 222 | 93.13 | 47.37 | 87.05 | 30.79 |
| Seed 333 | 93.26 | 47.45 | 87.46 | 31.19 |
| Mean std | 93.26 0.13 | 47.51 0.18 | 87.31 0.23 | 31.03 0.21 |
| Category | AUROC img | AP px |
|---|---|---|
| VisA MVTec-AD | ||
| bottle | 94.84 0.00 | 67.03 0.20 |
| cable | 83.55 0.32 | 12.09 0.20 |
| capsule | 94.31 0.02 | 36.60 0.06 |
| carpet | 100.00 0.00 | 82.77 0.19 |
| grid | 100.00 0.00 | 41.16 0.17 |
| Source | Target | AUROC img C E | AUROC px | AUPRO | AP px | F1 px |
|---|---|---|---|---|---|---|
| MVTec | BTAD | 92.81 92.68 | +0.45 | +0.47 | +0.61 | +1.56 |
| MVTec | DAGM | 93.82 93.56 | 0.12 | 0.46 | +0.81 | +0.35 |
| MVTec | DTD | 93.77 93.99 | +0.12 | +0.25 | +0.04 | +0.32 |
| MVTec | KSDD2 | 96.04 95.94 | +0.01 | +0.09 | +0.14 | +0.21 |
| MVTec | RSDD | 97.69 97.62 | +0.02 | +0.10 | +2.91 | +0.99 |
| MVTec | Mean | 94.83 94.76 | +0.10 | +0.09 | +0.90 | +0.69 |
| Method | DAGM | DTD-Synthetic |
|---|---|---|
| Same 7-class DAGM subset | ||
| AnomalyCLIP † | 96.3 | 94.3 |
| Bayes-PFL † | 97.35 | |
| CoEvoAD | 94.25 | |
| Original publication reports | ||
| WinCLIP | 87.6 | 83.9 |
| Category | C (Bayes-PFL) | E (CoEvoAD) | |
|---|---|---|---|
| blotchy | 94.06 | 75.75 | |
| matted1 | 88.10 | 80.95 | |
| marbled2 | 99.00 | 96.50 | |
| fibrous | 99.94 | 98.69 | |
| mesh | 91.15 | 92.64 | |
| perforated | 93.00 | 96.44 |
| Dir. | Metric | Mean | 95% CI | #Up | #Down | #Tie |
|---|---|---|---|---|---|---|
| MVTec | AUROC img | +0.38 | [+0.10, +0.66] | 8 | 2 | 5 |
| AP px | +0.24 | [ 0.03, +0.51] | 9 | 6 | 0 | |
| F1 px | +0.27 | [+0.06, +0.47] | 11 | 4 | 0 | |
| VisA | AUROC img | +0.37 | [ 0.19, +0.93] | 7 | 5 | 0 |
| AP px | +0.60 | [ 0.38, +1.58] | 7 | 5 | 0 | |
| F1 px | +0.51 | [ 0.47, +1.49] | 8 | 4 | 0 |
| MVTec-AD | VisA | |||||
|---|---|---|---|---|---|---|
| Route | Sem | Tmpl | AUROC img | AP px | AUROC img | AP px |
| R0 (control) | ✗ | ✗ | 93.01 | 47.48 | 87.05 | 30.51 |
| R1 (sem-only) | ✓ | ✗ | 93.39 | 47.72 | 87.21 | 30.85 |
| R2 (tmpl-only) | ✗ | ✓ | 93.13 | 47.49 | 87.11 | 31.51 |
| R3 (both) | ✓ | ✓ | 93.39 | 47.72 | 87.21 | 30.85 |
| Category | Donor | Sim | AUROC img | AP px | F1 px |
|---|---|---|---|---|---|
| bottle | candle | 0.810 | +0.08 | 0.16 | 0.09 |
| cable | macaroni1 | 0.758 | +1.28 | 0.40 | +0.01 |
| capsule | capsules | 0.903 | 0.19 | 0.12 | 0.34 |
| carpet | fryum | 0.799 | +0.00 | +0.08 | +0.07 |
| grid | fryum | 0.803 | +0.00 | 0.22 | +0.11 |
| hazelnut | cashew | 0.848 | +0.02 | +0.90 | +0.56 |
| Category | Donor | Sim | AUROC img | AP px | F1 px |
|---|---|---|---|---|---|
| candle | bottle | 0.810 | +0.83 | +0.75 | 0.06 |
| capsules | capsule | 0.903 | 0.65 | +2.95 | +1.66 |
| cashew | hazelnut | 0.848 | 0.34 | +0.04 | 0.15 |
| chewinggum | toothbrush | 0.716 | 0.23 | +0.03 | +0.12 |
| fryum | pill | 0.819 | +0.21 | +0.71 | +0.39 |
| macaroni1 | pill | 0.826 | 0.39 | +0.07 | +0.88 |
| MVTec | VisA | |
| Forced route | AUROC img / AP px / F1 px | |
| Actual route (anchor, absolute) | 93.39 / 47.72 / 47.96 | 87.43 / 31.11 / 36.72 |
| Random donor (expectation) | 0.21 / 0.25 / 0.28 | 0.25 / 0.11 / 0.02 |
| Worst donor (adversarial) | 0.54 / 0.95 / 0.88 | 2.26 / 2.47 / 2.35 |
| Oracle donor (not zero-shot) | +0.14 / +0.48 / +0.35 | +1.47 / +2.29 / +2.29 |
| AUROC img | AP px | F1 px | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Category | Act. | Rand. | Worst | Orac. | Act. | Rand. | Worst | Orac. | Act. | Rand. | Worst | Orac. |
| bottle | 94.84 | 94.92 | 94.76 | 95.16 | 66.97 | 67.88 | 66.79 | 68.46 | 62.92 | 63.62 | 62.78 | 64.09 |
| cable | 83.36 | 83.09 | 82.38 | 83.85 | 12.01 | 12.61 | 12.01 | 13.19 | 19.98 | 20.36 | 19.98 | 20.99 |
| capsule | 94.30 | 94.46 | 94.14 | 94.81 | 36.67 | 36.89 | 36.36 | 37.36 | 39.44 | 39.84 | 39.34 | 40.40 |
| carpet | 100.00 | 100.00 | 100.00 | 100.00 | 82.98 | 82.76 | 82.50 | 83.03 | 75.22 | 74.98 | 74.76 | 75.22 |
| grid | 100.00 | 99.99 | 99.92 | 100.00 | 40.97 | 41.22 | 40.80 | 41.63 | 42.75 | 42.70 | 42.11 | 43.04 |
| AUROC img | AP px | F1 px | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Category | Act. | Rand. | Worst | Orac. | Act. | Rand. | Worst | Orac. | Act. | Rand. | Worst | Orac. |
| candle | 90.67 | 90.63 | 89.79 | 91.75 | 33.53 | 33.96 | 31.99 | 36.12 | 43.55 | 43.94 | 42.61 | 45.79 |
| capsules | 91.95 | 92.81 | 91.60 | 94.03 | 52.27 | 51.45 | 44.31 | 55.32 | 55.78 | 56.38 | 49.35 | 59.93 |
| cashew | 93.36 | 93.33 | 92.46 | 94.20 | 37.40 | 37.41 | 35.47 | 40.90 | 42.68 | 43.01 | 41.50 | 45.55 |
| chewinggum | 97.00 | 97.15 | 96.88 | 97.48 | 83.12 | 82.99 | 81.19 | 83.82 | 75.53 | 75.43 | 74.35 | 76.00 |
| fryum | 90.92 | 91.01 | 90.48 | 92.36 | 27.60 | 28.45 | 27.06 | 30.50 | 32.92 | 33.64 | 32.47 | 35.17 |
| Src cat. | Evolved normal rule | Evolved abnormal rule |
|---|---|---|
| candle | X clean intact candle | X visible anomaly on object |
| capsules | X a photo of a capsules | X plain damaged capsules |
| cashew | X a photo of healthy cashew | X faulty flawed cashew |
| chewinggum | X typical intact with chewinggum | X anomalous abnormal textural chewinggum |
| fryum | X a view of pristine good fryum | X item: defect in fryum |
| macaroni1 | X a picture of macaroni1 | X defective visible textural macaroni1 |
| Src cat. | Evolved normal rule | Evolved abnormal rule |
|---|---|---|
| bottle | X normal bottle | X irregular visible surface bottle |
| cable | X typical cable | X an anomalous cable sample |
| capsule | X a standard capsule product | X a deformed structure capsule sample |
| carpet | X pristine surface carpet | X faulty blemished carpet |
| grid | X regular standard grid | X faulty flawed abnormal grid |
| hazelnut | X hazelnut | X abnormal faulty flawed hazelnut |
| Target | Nearest source | Sim | Route tag |
|---|---|---|---|
| bottle | candle | 0.810 | semantic (abn. fallback) |
| cable | macaroni1 | 0.758 | semantic transfer |
| capsule | capsules | 0.903 | semantic transfer |
| carpet | fryum | 0.799 | semantic transfer |
| grid | fryum | 0.804 | semantic transfer |
| hazelnut | cashew | 0.848 | semantic transfer |
| Target | Nearest source | Sim | Route tag |
|---|---|---|---|
| candle | bottle | 0.810 | semantic transfer |
| capsules | capsule | 0.903 | semantic transfer |
| cashew | hazelnut | 0.848 | semantic transfer |
| chewinggum | toothbrush | 0.716 | semantic transfer |
| fryum | pill | 0.819 | semantic transfer |
| macaroni1 | pill | 0.826 | semantic transfer |
Zero-Shot Anomaly Detection
Zero-shot anomaly detection finds unusual patterns in unseen domains without task-specific labeled examples.
See all 85 papers