One-to-More: High-Fidelity Training-Free Anomaly Generation with Attention Control
Organizations: Nanjing University · China Mobile Zijin Innovation Institute · Shandong University of Science and Technology
Abstract
Industrial anomaly detection (AD) is characterized by an abundance of normal images but a scarcity of anomalous ones. Although numerous few-shot anomaly synthesis methods have been proposed to augment anomalous data for downstream AD tasks, most existing approaches require time-consuming training and struggle to learn distributions that are faithful to real anomalies, thereby restricting the efficacy of AD models trained on such data. To address these limitations, we propose a training-free few-shot anomaly generation method, namely O2MAG, which leverages the self-attention in One reference anomalous image to synthesize More realistic anomalies, supporting effective downstream anomaly detection. Specifically, O2MAG manipulates three parallel diffusion processes via self-attention grafting and incorporates the anomaly mask to mitigate foreground-background query confusion, synthesizing text-guided anomalies that closely adhere to real anomalous distributions. To bridge the semantic gap between the encoded anomaly text prompts and the true anomaly semantics, Anomaly-Guided Optimization is further introduced to align the synthesis process with the target anomalous distribution, steering the generation toward realistic and text-consistent anomalies. Moreover, to mitigate faint anomaly synthesis inside anomaly masks, Dual-Attention Enhancement is adopted during generation to reinforce both self- and cross-attention on masked regions. Extensive experiments validate the effectiveness of O2MAG, demonstrating its superior performance over prior state-of-the-art methods on downstream AD tasks.
Figures & tables
| Category | DFMGAN [ 9 ] | AnomalyDiffusion [ 18 ] | DualAnoDiff [ 20 ] | SeaS [ 8 ] | Ours | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AP-I | AUC-P | AP-P | F1-P | AP-I | AUC-P | AP-P | F1-P | AP-I | AUC-P | AP-P | F1-P | AP-I | AUC-P | AP-P | F1-P | AP-I | AUC-P | AP-P | F1-P | |
| bottle | 99.8 | 98.9 | 90.2 | 83.9 | 99.9 | 99.4 | 94.1 | 87.3 | 100 | 99.5 | 93.4 | 85.7 | 99.9 | 99.7 | 95.9 | 88.8 | 100 | 99.7 | 95.4 | 88.4 |
| cable | 97.8 | 97.2 | 81.0 | 75.4 | 100 | 99.2 | 90.8 | 83.5 | 98.3 | 98.5 | 82.6 | 76.9 | 98.8 | 96.0 | 83.1 | 77.7 | 100 | 99.4 | 91.2 | 85.0 |
| capsule | 98.5 | 79.2 | 26.0 | 35.0 | 99.9 | 98.8 | 57.2 | 59.8 | 99.2 | 99.5 | 73.2 | 67.0 | 99.2 | 93.7 | 41.9 | 47.3 | 99.8 | 97.0 | 60.6 | 59.0 |
| carpet | 98.5 | 90.6 | 33.4 | 38.1 | 98.8 | 98.6 | 81.2 | 74.6 | 99.9 | 99.4 | 89.1 | 80.2 | 99.0 | 99.3 | 86.4 | 78.1 | 100 | 99.5 | 88.5 | 80.0 |
| grid | 90.4 | 75.2 | 14.3 | 20.5 | 99.5 | 98.3 | 52.9 | 54.6 | 99.7 | 98.5 | 57.2 | 54.9 | 99.9 | 99.7 | 76.3 | 70.0 | 100 | 99.6 | 78.6 | 71.6 |
| Category | DFMGAN [ 9 ] | AnoDiff [ 18 ] | DualAno [ 20 ] | SeaS [ 8 ] | Ours | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| KID | IC-L | KID | IC-L | KID | IC-L | KID | IC-L | KID | IC-L | |
| bottle | 70.90 | 0.12 | 137.71 | 0.17 | 151.09 | 0.31 | 148.29 | 0.21 | 42.78 | 0.17 |
| cable | 61.68 | 0.25 | 88.44 | 0.40 | 86.01 | 0.45 | 108.62 | 0.43 | 28.93 | 0.41 |
| capsule | 40.63 | 0.11 | 111.30 | 0.18 | 72.82 | 0.32 | 183.11 | 0.29 | 22.71 | 0.17 |
| carpet | 25.14 | 0.13 | 107.87 | 0.21 | 56.80 | 0.27 | 127.62 | 0.26 | 45.10 | 0.29 |
| grid | 101.04 | 0.13 | 51.55 | 0.45 | 64.13 | 0.44 | 60.85 | 0.41 | 7.04 | 0.38 |
| Metric | AUC-I | F1-I | AUC-P | F1-P |
|---|---|---|---|---|
| AnomalyAny | 98.4 | 96.9 | 97.4 | 65.1 |
| Ours | 99.6 (+ 1.2 ) | 99.2 (+ 2.3 ) | 99.2 (+ 1.8 ) | 80.6 (+ 15.5 ) |
| Category | DFMGAN [ 9 ] | AnoDiff [ 18 ] | TF 2 [ 41 ] | DualAno [ 20 ] | SeaS [ 8 ] | Ours |
|---|---|---|---|---|---|---|
| bottle | 56.59 | 88.37 | 79.36 | 67.44 | 81.40 | 86.05 |
| cable | 45.31 | 76.56 | 60.00 | 57.81 | 48.44 | 76.56 |
| capsule | 37.23 | 44.00 | 53.12 | 50.67 | 33.33 | 77.33 |
| carpet | 47.31 | 58.06 | 55.05 | 62.90 | 38.71 | 74.19 |
| grid | 40.83 | 60.00 | 47.36 | 67.50 | 47.50 | 80.00 |
| hazelnut | 81.94 | 81.25 | 88.88 | 79.17 | 81.25 | 95.83 |
| Method | Image-level | Pixel-level | ||||
|---|---|---|---|---|---|---|
| AUC-I | AP-I | F1-I | AUC-P | AP-P | F1-P | |
| DREAM | 99.6 | 99.1 | 94.7 | 99.3 | 74.8 | 73.3 |
| AnomalyAny | 100.0 | 100.0 | 100.0 | 98.6 | 78.8 | 75.0 |
| SeaS-zero | 100.0 | 100.0 | 100.0 | 97.5 | 78.6 | 73.7 |
| Ours-zero | 100.0 | 100.0 | 100.0 | 99.1 | 86.8 | 80.2 |
| SeaS-origin | 100.0 | 100.0 | 100.0 | 99.2 | 87.3 | 80.0 |
| Method | Metric | ||||
|---|---|---|---|---|---|
| TriAG | DAE | AGO | AUROC | AP | F1-max |
| ✓ | 99.0 | 81.9 | 77.6 | ||
| ✓ | ✓ | 99.0 | 83.3 | 77.9 | |
| ✓ | ✓ | 99.1 | 82.7 | 77.7 | |
| ✓ | ✓ | ✓ | 99.2 | 86.3 | 80.8 |
Appendix figures & tables36 assets
Supplementary material from the paper’s appendix.
Appendix
| Setting | AUC-I | AP-I | F1-I | AUC-P | AP-P | F1-P |
|---|---|---|---|---|---|---|
| Origin | 99.9 | 100.0 | 99.0 | 99.8 | 96.2 | 90.1 |
| Augment | 99.9 | 99.9 | 98.9 | 99.8 | 95.9 | 91.0 |
| Methods | Training Overall Time | Inference Time (per image) |
|---|---|---|
| DFMGAN [ 9 ] | 464 hours | 0.9 s |
| AnomalyDiffusion [ 18 ] | 310 hours | 7.4 s |
| DualAnoDiff [ 20 ] | 197 hours | 32.4 s |
| SeaS [ 8 ] | 124 hours | 10.7 s |
| AnomalyAny [ 41 ] | 0 hours | 120s |
| O2MAG (ours) | 0 hours | 28s |
| Mask Source | AUROC-I | AP-I | F1-I | AUROC-P | AP-P | F1-P | Pro |
|---|---|---|---|---|---|---|---|
| Perlin noise | 100 | 100 | 100 | 99.8 | 95.5 | 89.8 | 94.0 |
| Nano Banana | 100 | 100 | 100 | 99.9 | 97.3 | 92.1 | 95.1 |
| AnomalyDiffusion | 100 | 100 | 100 | 99.9 | 96.3 | 90.6 | 95.2 |
| SeaS | 100 | 100 | 100 | 99.6 | 94.8 | 89.3 | 95.9 |
| Category | AnomalyDiffusion [ 18 ] | DualAnoDiff [ 20 ] | SeaS [ 8 ] | Ours | ||||
|---|---|---|---|---|---|---|---|---|
| KID | IC-L | KID | IC-L | KID | IC-L | KID | IC-L | |
| capsules | 103.91 | 0.56 | 126.19 | 0.64 | 111.32 | 0.61 | 20.53 | 0.54 |
| candle | 183.21 | 0.17 | 180.22 | 0.38 | 47.65 | 0.10 | 41.91 | 0.12 |
| cashew | 78.22 | 0.38 | 52.46 | 0.48 | 10.37 | 0.35 | 10.29 | 0.35 |
| chewinggum | 39.63 | 0.34 | 29.76 | 0.43 | 24.19 | 0.29 | 33.36 | 0.33 |
| fryum | 238.41 | 0.27 | 102.00 | 0.41 | 82.20 | 0.24 | 24.93 | 0.18 |
| Category | AnomalyAny | Ours | ||||||
|---|---|---|---|---|---|---|---|---|
| I-AUC | I-F1 | P-AUC | P-F1 | I-AUC | I-F1 | P-AUC | P-F1 | |
| candle | 95.6 | 90.0 | 99.3 | 40.1 | 94.9 | 86.1 | 98.8 | 42.4 |
| capsules | 96.2 | 93.8 | 99.1 | 60.1 | 89.6 | 83.2 | 99.2 | 68.7 |
| cashew | 97.4 | 94.5 | 99.2 | 70.4 | 94.0 | 91.7 | 99.9 | 92.3 |
| chewinggum | 98.7 | 97.0 | 99.5 | 75.3 | 98.5 | 94.8 | 99.7 | 78.1 |
| fryum | 98.4 | 97.5 | 97.4 | 53.6 | 94.4 | 91.5 | 98.6 | 70.8 |
| Method | AUROC-I | AP-I | F1-I | AUROC-P | AP-P | F1-P | Pro |
|---|---|---|---|---|---|---|---|
| DualAnoDiff | 72.5 | 77.8 | 75.8 | 91.3 | 25.7 | 31.9 | 75.7 |
| SeaS | 76.7 | 80.4 | 77.2 | 87.7 | 31.1 | 36.5 | 76.9 |
| Ours | 79.3 | 84.0 | 80.4 | 93.6 | 37.3 | 41.9 | 82.9 |
| Methods | Training Time (single GPU) | Inference Time (per image) | GPU Memory |
|---|---|---|---|
| DualAnoDiff | 119 hours | 23 s | 12G |
| SeaS | 160 hours | 11 s | 24G |
| O2MAG Ours | 0 hours | 28 s | 32G |
| Category | AnomalyDiffusion | DualAnoDiff | SeaS | Ours | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AUC-I | AP-I | F1-I | AUC-I | AP-I | F1-I | AUC-I | AP-I | F1-I | AUC-I | AP-I | F1-I | |
| candle | 95.1 | 95.3 | 90.1 | 96.7 | 95.6 | 90.4 | 78.7 | 77.9 | 68.5 | 94.9 | 93.3 | 86.1 |
| capsules | 91.9 | 93.8 | 85.9 | 91.0 | 93.0 | 85.7 | 84.7 | 89.0 | 78.6 | 89.6 | 91.9 | 83.2 |
| cashew | 95.2 | 96.0 | 92.2 | 99.2 | 99.4 | 96.4 | 94.8 | 95.2 | 92.4 | 94.0 | 94.6 | 91.7 |
| chewinggum | 94.4 | 97.2 | 93.1 | 99.6 | 99.7 | 97.8 | 98.9 | 99.3 | 95.0 | 98.5 | 99.0 | 94.8 |
| fryum | 81.3 | 87.2 | 79.2 | 86.7 | 90.7 | 84.1 | 91.2 | 94.4 | 86.7 | 94.4 | 96.7 | 91.5 |
| Category | AnomalyDiffusion | DualAnoDiff | SeaS | Ours | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AUC-P | AP-P | F1-P | AUC-P | AP-P | F1-P | AUC-P | AP-P | F1-P | AUC-P | AP-P | F1-P | |
| candle | 99.2 | 24.7 | 33.0 | 98.9 | 48.8 | 49.7 | 96.5 | 29.9 | 37.5 | 98.8 | 39.8 | 42.4 |
| capsules | 99.6 | 60.2 | 61.2 | 98.4 | 60.7 | 63.8 | 99.5 | 59.1 | 62.3 | 99.2 | 70.2 | 68.7 |
| cashew | 98.4 | 68.8 | 63.9 | 99.9 | 98.0 | 94.5 | 99.9 | 98.2 | 95.3 | 99.9 | 96.4 | 92.3 |
| chewinggum | 98.7 | 78.3 | 72.4 | 99.9 | 86.6 | 78.2 | 99.5 | 84.3 | 77.6 | 99.7 | 85.5 | 78.1 |
| fryum | 91.0 | 28.2 | 31.8 | 97.9 | 76.7 | 74.7 | 97.4 | 74.5 | 69.5 | 98.6 | 80.6 | 70.8 |
| Category | DFMGAN | AnomalyDiffusion | DualAnoDiff | SeaS | Ours | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AUC-I | AP-I | F1-I | AUC-I | AP-I | F1-I | AUC-I | AP-I | F1-I | AUC-I | AP-I | F1-I | AUC-I | AP-I | F1-I | |
| bottle | 99.3 | 99.8 | 97.7 | 99.8 | 99.9 | 98.9 | 100 | 100 | 100 | 99.9 | 99.9 | 98.9 | 100 | 100 | 100 |
| cable | 95.9 | 97.8 | 93.8 | 100 | 100 | 100 | 99.8 | 99.8 | 98.5 | 98.0 | 98.8 | 96.1 | 100 | 100 | 100 |
| capsule | 92.8 | 98.5 | 94.5 | 99.7 | 99.9 | 98.7 | 96.3 | 99.2 | 94.7 | 97.1 | 99.2 | 95.4 | 99.3 | 99.8 | 98.0 |
| carpet | 67.9 | 87.9 | 87.3 | 96.7 | 98.8 | 94.3 | 98.6 | 99.9 | 96.7 | 97.4 | 99.0 | 96.7 | 100 | 100 | 100 |
| grid | 73.0 | 90.4 | 85.4 | 98.4 | 99.5 | 98.7 | 100 | 99.7 | 100 | 99.9 | 99.9 | 98.8 | 100 | 100 | 100 |
| Category | DFMGAN | AnomalyDiffusion | DualAnoDiff | SeaS | Ours | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| AUC-P | AP-P | F1-P | AUC-P | AP-P | F1-P | AUC-P | AP-P | F1-P | AUC-P | AP-P | F1-P | AUC-P | AP-P | F1-P | |
| bottle | 98.9 | 90.2 | 83.9 | 99.4 | 94.1 | 87.3 | 99.5 | 93.4 | 85.7 | 99.7 | 95.9 | 88.8 | 99.7 | 95.4 | 88.4 |
| cable | 97.2 | 81.0 | 75.4 | 99.2 | 90.8 | 83.5 | 98.5 | 82.6 | 76.9 | 96.0 | 83.1 | 77.7 | 99.4 | 91.2 | 85.0 |
| capsule | 79.2 | 26.0 | 35.0 | 98.8 | 57.2 | 59.8 | 99.5 | 73.2 | 67.0 | 93.7 | 41.9 | 47.3 | 97.0 | 60.6 | 59.0 |
| carpet | 90.6 | 33.4 | 38.1 | 98.6 | 81.2 | 74.6 | 99.4 | 89.1 | 80.2 | 99.3 | 86.4 | 78.1 | 99.5 | 88.5 | 80.0 |
| grid | 75.2 | 14.3 | 20.5 | 98.3 | 52.9 | 54.6 | 98.5 | 57.2 | 54.9 | 99.7 | 76.3 | 70.0 | 99.6 | 78.6 | 71.6 |