Existing defect/anomaly generation methods often rely on few-shot learning, which overfits to specific defect categories due to the lack of large-scale paired defect editing data. This issue is aggravated by substantial variations in defect scale and morphology, resulting in limited generalization, degraded realism, and category consistency. We address these challenges by introducing UDG, a large-scale dataset of 300K normal-abnormal-mask-caption quadruplets spanning diverse domains, and by presenting UniDG, a universal defect generation foundation model that supports both reference-based defect generation and text instruction-based defect editing without per-category fine-tuning. UniDG performs Defect-Context Editing via adaptive defect cropping and structured diptych input format, and fuses reference and target conditions through MM-DiT multimodal attention. A two-stage training strategy, Diversity-SFT followed by Consistency-RFT, further improves diversity while enhancing realism and reference consistency. Extensive experiments on MVTec-AD and VisA show that UniDG outperforms prior few-shot anomaly generation and image insertion/editing baselines in synthesis quality and downstream single- and multi-class anomaly detection/localization. Code will be available at https://github.com/RetoFan233/UniDG.
Figures & tables
Figure 1: The framework of existing anomaly generation methods. The proposed UniDG maintains straightforward inference and fully open-sourced framework.
Figure 2: Overview of UDG Dataset. (a) The construction pipeline for generating normal-abnormal-mask-caption quadruplets. (b) The distribution across scenarios and the frequency of mapped defect categories.
Figure 3: Overall framework of UniDG. UniDG leverages MM-DiT with a Defect-Context Editing strategy to integrate reference defects into target regions. Diversity-SFT and Consistency-RFT further improve synthesis quality.
Metric
Few-shot Learning Anomaly Generation
Training-Free Few-shot Image Insertion
AnoDiff
AnoGen
DualAnoDiff
SeaS
AnyDoor
InsertAny
UniDG-SFT
UniDG-RFT
Cls.
Acc-C
68.4
61.4
64.0
59.1
61.8
63.6
74.9
77.4
Det.&Loc.
AUROC-I
97.9
97.0
94.9
96.2
80.3
95.3
98.0
98.4
AP-I
98.9
95.0
96.6
95.5
80.7
95.5
98.6
99.0
Table 1: Quantitative results for single-class anomaly classification, detection, localization, and synthesis quality on MVTec-AD dataset. Bold and underline represent optimal and sub-optimal average results, respectively. Training-Free Few-Shot means that no data from MVTec-AD datasets was used during training, and only single retrieved reference image used during inference for fair comparisons.
Methods
Binary Anomaly Detection Metrics
Semantic Segmentation Metrics
AUROC-I
AP-I
AUROC-P
AP-P
PRO-P
mIoU
BG-mIoU
FG-mIoU
Few-shot Anomaly Generation
AnoDiff
92.79
96.24
95.90
61.41
81.82 +0.0%
37.87 -4.7%
98.47
23.83 -9.9%
AnoGen
93.10
96.20
94.85
63.32
79.54 -2.8%
39.72 +0.0%
98.54
26.45 +0.0%
DualAnoDiff
91.00
95.40
95.31
63.19
79.96 -2.3%
39.43 -0.7%
98.57
26.27 -0.7%
SeaS
89.29
93.76
95.89
60.98
81.01 -1.0%
35.41 -10.9%
98.33
20.48 -22.6%
Table 2: Quantitative results for multi-class anomaly semantic segmentation on the MVTec-AD dataset.
Figure 4: Qualitative comparisons of anomaly generation performance on MVTec-AD dataset.
Figure 5: Qualitative comparisons of cross-object defect generation capabilities on MVTec-AD dataset.
Arch.
Single-class Metrics
Multi-class Metrics
Acc
AP-I
AP-P
PRO-P
mIoU
FG-mIoU
Baseline
57.8
92.5
43.1
75.3
29.4
13.3
+ Diptych input
62.3
94.0
51.6
78.5
32.3
16.4
+ Normal Reg
64.9
94.9
56.7
82.1
34.9
22.1
+ Defect Attn
65.5
95.8
60.1
84.0
36.1
22.8
+ Diversity-SFT
74.9
98.6
77.0
91.0
41.8
28.5
Table 3: Ablation studies on the components within UniDG.
Figure 6: Comparison of performance between UniDG-SFT and UniDG-RFT using Good-Same-Bad (GSB) evaluation.
Data Proportion
Multi-class Metrics
Synthesis Metrics
(a)
(b)
(c)
PRO-P
mIoU
FG-mIoU
Cons
Qual
0
1
1
76.2
30.3
14.5
3.82
3.73
1
0
1
78.3
31.4
15.7
3.91
3.87
1
1
0
90.5
39.1
26.0
3.89
3.92
1
1
1
91.0
41.8
28.5
4.15
4.09
2
1
1
90.9
41.9
28.5
4.14
4.12
Table 4: Ablation studies on the training data allocation.
Appendix figures & tables18 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 11
Figure 9: The part visualizations of the abnormal-normal-mask-caption quadruplets of the UDG Dataset.
Component
Parameters
Enabled
Status
FLUX.1-Fill-dev
CLIP Text Encoder
∼ 125M
/
T5 XXL Text Encoder
∼ 4.7B
/
FLUX-VAE
∼ 84M
/
MM-DiT
∼ 12B
/
& LoRA
FLUX.1-Redux-dev
Appendix
Table 5: Model Structure and Parameters. Enabled means that this component is enabled in the reference defect-based synthesis or text instruction-based synthesis.
Figure 10: The quantitative comparison between the proposed UniDG-Text and existing proprietary advanced methods.
Figure 11: The failure cases of UniDG-SFT.
Figure 12: The system prompt for Defect-Und-Reward and MLLM-based comprehensive scores.
Accuracy
GPT-4.1
GPT-5
Gemini-3-Pro
Qwen3-VL
Defect-Und-Reward-4B
Defect-Und-Reward-8B
4B
8B
32B
RefAd
84.2
82.6
86.4
74.6
72.4
80.0
82.4
84.8
Cons
81.6
83.8
88.8
75.2
78.4
79.8
82.0
86.0
Reas
86.4
88.4
87.6
62.8
68.0
73.2
84.8
85.4
Qual
92.0
92.4
94.8
84.2
86.8
87.4
91.6
93.4
Appendix
Table 6: Benchmark results on UDG-Reward-Bench, reporting the accuracy of prediction with advanced MLLMs on reference adherence, consistency, reasonability, overall quality.
Figure 13: The part visualizations of UDG-Reward-Bench.
Table 19
Model
Scale
Anomaly
Defect
Object
Average
Discrimination
Classification
Localization
Description
Analysis
Classification
Analysis
Random Chance
–
50.00
25.00
25.00
25.00
25.00
25.00
25.00
28.57
Human (expert)
–
95.24
75.00
92.31
83.33
94.20
86.11
80.37
86.65
Human (ordinary)
–
86.90
66.25
85.58
71.25
81.52
89.58
69.72
78.69
Claude-3.5-sonnet
–
60.14
60.14
48.81
67.13
79.11
85.19
79.83
68.36
Gemini-1.5-pro
–
68.63
60.12
58.56
70.38
82.46
89.20
82.25
73.09
Appendix
Table 9: The quadruplets of UDG improves MLLM-based anomaly classification and detection methods.
Method
AnoDiff
AnoGen
DualAnoDiff
SeaS
AnyDoor
InsertAny
UniDG
Paradigm
DDIM
Rectified Flow
Resolution
256×256
256×256
512×512
512×512
512×512
768×768
768×768
Iterations
50
50
100
25
50
50
28
Inference Time (s)
3.47
3.21
19.68
6.73
7.59
28.04
11.59
Appendix
Table 10: The Inference Time of different methods.
Coefficient
Single-class Metrics
Multi-class Metrics
Synthesis Metrics
wgen
wdet
Acc
AP-I
AP-P
PRO-P
mIoU
FG-mIoU
Cons
Qual
0.0
1.0
78.3
99.1
78.1
91.3
45.3
32.5
4.01
3.97
0.2
0.8
77.6
99.0
77.6
91.2
44.7
32.2
4.15
4.17
0.5
0.5
77.4
99.0
77.3
91.1
44.2
31.9
4.21
4.24
0.8
0.2
76.7
98.8
76.7
91.0
43.7
30.7
4.34
4.39
1.0
0.0
71.6
97.3
75.8
88.3
39.8
27.1
4.59
4.67
Appendix
Table 11: Ablation studies on the different reward models during Consistency-RFT. wgen and wdet denotes the coefficient of the Defect-Und-Reward and Defect-Recog-Reward models, respectively.
Method
Metric
Category
Average
bottle
cable
capsule
carpet
grid
hazelnut
leather
metal_nut
pill
screw
tile
toothbrush
transistor
wood
zipper
Few-shot Learning Anomaly Generation
AnoDiff
AUROC-I
100.0
99.8
91.3
93.2
97.5
99.6
99.9
100.0
99.1
88.0
100.0
100.0
99.8
100.0
100.0
97.9
AP-I
100.0
99.4
97.4
95.4
99.0
99.6
100.0
100.0
98.9
93.6
100.0
100.0
99.6
100.0
100.0
98.9
AUROC-P
99.1
82.2
97.7
97.2
91.8
99.7
99.8
99.6
99.8
93.6
99.1
98.1
94.1
98.3
99.4
96.6
AP-P
87.5
82.2
34.5
78.6
30.3
95.5
77.5
98.2
96.7
37.2
92.9
60.3
94.1
78.4
87.3
75.4
Appendix
Table 12: Quantitative results for anomaly detection and localization on MVTec-AD dataset. Bold and underline represent optimal and sub-optimal average results, respectively.
Category
AnoDiff
AnoGen
DualAnoDiff
SeaS
AnyDoor
InsertAny
UniDG-SFT
UniDG-RFT
bottle
90.70
53.49
55.81
83.72
65.12
79.07
88.37
83.72
cable
67.19
60.94
48.44
50.00
62.50
76.56
79.69
87.88
capsule
66.67
24.00
49.33
30.67
65.33
41.33
68.00
73.33
carpet
58.06
40.32
69.35
41.94
53.23
77.42
64.52
72.58
grid
42.50
57.50
62.50
32.50
60.00
32.50
50.00
40.00
hazel nut
85.42
85.42
79.17
85.42
81.25
95.83
95.83
95.83
Appendix
Table 13: Quantitative results for anomaly classification on MVTec-AD dataset. The higher accuracy denotes the generated data is more consistent with the real data.
Method
Metric
Category
Average
bottle
cable
capsule
carpet
grid
hazelnut
leather
metal_nut
pill
screw
tile
toothbrush
transistor
wood
zipper
AnoDiff
IL
0.16
0.37
0.16
0.20
0.39
0.29
0.39
0.24
0.23
0.23
0.50
0.15
0.27
0.34
0.23
0.28
IL-a
0.17
0.13
0.08
0.14
0.11
0.17
0.10
0.22
0.14
0.07
0.21
0.14
0.16
0.18
0.12
0.14
RefAd
3.76
4.00
3.69
3.96
4.11
3.43
3.82
3.86
3.97
3.62
3.87
2.63
3.74
3.49
4.25
3.84
Cons
3.80
3.93
4.13
4.29
3.62
3.54
4.21
3.92
4.16
3.75
4.13
2.99
4.01
3.82
4.00
3.97
Reas
4.29
4.39
4.48
4.69
4.41
3.58
4.07
4.19
3.85
4.00
3.89
3.06
4.38
3.85
4.26
4.18
Appendix
Table 14: Comparison of synthesis data on IL, IL-a, Reference Adherence, Consistency, Reasonability, Quality on MVTec-AD dataset.
Method
Metric
Category
Average
candle
capsules
cashew
chewinggum
fryum
macaroni1
macaroni2
pcb1
pcb2
pcb3
pcb4
pipe_fryum
Few-shot Learning Anomaly Generation
SeaS
AUROC-I
73.70
78.20
85.90
97.00
90.40
81.30
63.80
96.80
88.00
91.50
98.10
71.30
84.67
AP-I
71.60
82.70
90.50
98.10
93.60
70.70
52.10
95.90
89.00
88.40
94.80
75.50
83.58
AUROC-P
84.10
98.10
98.30
98.80
96.90
98.10
91.40
97.60
94.70
90.50
95.60
99.10
95.27
AP-P
1.60
50.70
83.60
77.80
67.10
7.60
0.10
86.70
21.40
38.30
49.50
78.70
46.93
Appendix
Table 15: Quantitative results for anomaly detection and localization on VisA dataset. Bold and underline represent optimal and sub-optimal average results, respectively.
Category
SeaS
UniDG-SFT
UniDG-RFT
candle
73.70
87.50
91.20
capsules
78.20
91.20
90.40
cashew
85.90
84.30
85.20
chewinggum
97.00
96.40
96.70
fryum
90.40
92.30
91.50
macaroni1
81.30
89.60
92.30
Appendix
Table 16: Quantitative results for anomaly classification on VisA dataset. The higher accuracy denotes the generated data is more consistent with the real data.
Methods
Binary Anomaly Detection Metrics
Semantic Segmentation Metrics
AUROC-I
AP-I
AUROC-P
AP-P
PRO-P
mIoU
BG-mIoU
FG-mIoU
Few-shot Anomaly Generation
SeaS
81.72
82.87
95.83
45.85
78.73
24.99
99.58
11.83
Training-Free Few-shot Image Insertion
UniDG-SFT
89.21
91.34
97.88
58.14
88.45
31.79
99.54
18.89
UniDG-RFT
91.37
92.96
97.59
63.20
90.92
36.23
99.55
23.47
Appendix
Table 17: Quantitative results for multi-class anomaly semantic segmentation on the VisA dataset.
Anomaly generation is often framed as few-shot fine-tuning with anomalous samples, which contradicts the scarcity that motivates generation and tends to overfit category priors. We tackle the setting where no real anomaly samples or training are available. We propose Delta-Denoising (DeltaDeno), a training-free zero-shot anomaly generation method that localizes and edits defects by contrasting two diffusion branches driven by a minimal prompt pair under a shared schedule. By accumulating per-step denoising deltas into an image-specific localization map, we obtain a mask to guide the latent inpainting during later diffusion steps and preserve the surrounding context while generating realistic local defects. To improve stability and control, DeltaDeno performs token-level prompt refinement that aligns shared content and strengthens anomaly tokens, and applies a spatial attention bias restricted to anomaly tokens in the predicted region. Experiments on public datasets show that DeltaDeno achieves great generation, realism and consistent gains in downstream detection performance. Code will be made publicly available at https://github.com/CROVO1026/DeltaDeno.
Chaoran Xu, Chengkan Lv, Qiyu Chen +3
Institute of Automation, Chinese Academy of Sciences, Beijing, China · School of Artificial Intelligence, University of Chinese Academy of Sciences, Beijing, China · CASI Vision Technology CO., LTD., Luoyang, China +1
Industrial anomaly inspection faces a major challenge due to the lack of real-world anomaly samples. While generative models are used to create anomaly data, existing methods still struggle when handling small-scale anomalies. This failure occurs because extreme downsampling in diffusion models causes the information of small anomalies to be lost in the latent space. To address this, we introduce UniScale, a unified training and inference framework for high-fidelity industrial anomaly generation across arbitrary scales. During training, we introduce an Error-Suppressed Multi-Scale Training (EMT) strategy, which enables the model to learn the rich location-aware textures of anomalies, while suppressing upsampling-induced interpolation errors in texture acquisition, ensuring the model is capable of learning small-scale anomalies, while remaining effective for regular scale anomalies. For inference, we propose Generation-then-Fusion Denoising. It decouples anomaly generation from background integration, preventing small anomalies from being overwhelmed. Extensive experiments demonstrate that our method outperforms state-of-the-art competitors in both anomaly generation quality and downstream detection performance. It achieves a relative IS(a) improvement of 45.86% (from 1.81 to 2.64) on VisA and 37.70% (from 1.22 to 1.68) on MVTec AD 2, while also improving the downstream pixel-level IoU by 4.22% on VisA and AUROC by 6.55% on MVTec AD 2. Code is available at https://github.com/HUST-SLOW/UniScale.
Shilei Zeng, Linxin Guan, Xurui Li +2
School of Electronic Information and Communications, Huazhong University of Science and Technology
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.
Haoxiang Rao, Zhao Wang, Chenyang Si +4
Nanjing University · China Mobile Zijin Innovation Institute · Shandong University of Science and Technology