The performance of visual anomaly inspection in industrial quality control is often constrained by the scarcity of real anomalous samples. Consequently, anomaly synthesis techniques have been developed to enlarge training sets and enhance downstream inspection. However, existing methods either suffer from poor integration caused by inpainting or fail to provide accurate masks. To address these limitations, we propose GroundingAnomaly, a novel few-shot anomaly image generation framework. Our framework introduces a Spatial Conditioning Module that leverages per-pixel semantic maps to enable precise spatial control over the synthesized anomalies. Furthermore, a Gated Self-Attention Module is designed to inject conditioning tokens into a frozen U-Net via gated attention layers. This carefully preserves pretrained priors while ensuring stable few-shot adaptation. Extensive evaluations on the MVTec AD and VisA datasets demonstrate that GroundingAnomaly generates high-quality anomalies and achieves state-of-the-art performance across multiple downstream tasks, including anomaly detection, segmentation, and instance-level detection.
Figures & tables
Figure 1: Anomaly Generation methods inpaint anomalies onto normal images; Anomaly Image Generation methods jointly generate anomalies with products and predict masks after generation; our GroundingAnomaly grounds anomalies with semantic maps and generate the whole anomalous images.
Figure 2: Proposed framework of GroundingAnomaly : (i) Spatial Conditioning Module that encodes a pixel-wise semantic map fuses with disentangled product and anomaly tokens; (ii) Gated Self-Attention Module , which injects the spatial conditioning into a frozen U-Net. (iii) The framework is trained on mixed batches of normal and anomalous images to leverage cross-domain appearance priors, and it generates diverse, high-fidelity anomaly images.
Figure 3: (i) Spatial Conditioning Module; (ii) Gated Self-Attention Module.
Dataset
DFMGAN [ 6 ]
AnoDiff [ 16 ]
DualAnoDiff [ 18 ]
SeaS [ 40 ]
Ours
IS
IC-L
IS
IC-L
IS
IC-L
IS
IC-L
IS
IC-L
MVTec AD
1.72
0.20
1.80
0.32
1.91
0.37
1.95
0.34
1.99
0.41
VisA
1.25
0.26
1.26
0.25
1.25
0.25
1.27
0.26
1.29
0.31
Table 1: Comparison on IS and IC-LPIPS on MVTec AD and VisA. Bold indicates the best performance.
Figure 4: Left: Comparison on the generation results on MVTec AD and VisA. Cable, grid and leather to MVTec AD and candle and macaroni2 belong to VisA. Our method generates high-quality anomaly images that are accurately grounded with masks. Right: Visualization of U-Net segmentation results on MVTec AD and VisA. The detection model trained on GroundingAnomaly-generated data exhibits more robust performance.
Category
DRÆM [ 37 ]
DFMGAN [ 6 ]
AnomalyDiffusion [ 16 ]
DualAnoDiff [ 18 ]
SeaS [ 40 ]
Ours
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
AP-I
AUC-P
AP-P
F1-P
AP-I
bottle
96.7
80.2
74.0
99.8
98.9
90.2
83.9
99.8
99.4
94.1
87.3
99.9
99.5
93.4
85.7
100.0
99.7
95.5
87.9
100.0
99.6
94.1
88.1
100.0
cable
80.3
21.8
28.3
83.2
97.2
81.0
75.4
97.8
99.2
90.8
83.5
100.0
97.5
82.6
76.9
98.3
94.5
77.8
75.0
98.5
97.9
81.0
78.2
99.5
capsule
76.2
25.5
32.1
98.7
79.2
26.0
35.0
98.5
98.8
57.2
59.8
99.9
99.5
73.2
67.0
99.2
95.7
51.7
52.4
99.6
98.3
65.5
59.4
98.8
carpet
92.6
43.0
41.9
98.7
90.6
33.4
38.1
98.5
98.6
81.2
74.6
98.8
99.4
89.1
80.2
99.9
99.5
84.5
76.5
99.1
99.5
89.3
86.3
99.6
grid
99.1
59.3
58.7
99.9
75.2
14.3
20.5
90.4
98.3
52.9
54.6
99.5
98.5
57.2
54.9
99.7
99.6
67.7
62.1
99.9
99.7
73.6
69.9
100.0
Table 2: Comparison on pixel-level segmentation and image-level detection on MVTec AD dataset by training U-Nets on the generated data from DRÆM, DFMGAN, AnomalyDiffusion, DualAnoDiff, SeaS and our proposed GroundingAnomaly.
Category
DRÆM [ 37 ]
DFMGAN [ 6 ]
AnomalyDiffusion [ 16 ]
DualAnoDiff [ 18 ]
SeaS [ 40 ]
Ours
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
AP-I
AUC-P
AP-P
F1-P
AP-I
candle
86.2
18.7
23.7
77.5
87.1
24.7
31.4
85.9
89.1
28.7
33.9
87.2
93.7
48.1
46.5
89.0
89.4
45.1
44.1
87.8
98.9
61.2
58.3
94.4
capsules
90.7
50.4
53.8
85.1
91.3
55.0
58.6
86.5
94.1
60.5
62.3
90.7
95.8
61.8
64.5
92.0
97.2
61.2
64.2
88.7
99.3
78.4
72.1
92.3
cashew
89.0
45.2
47.1
91.1
92.2
65.7
65.1
92.3
95.1
82.1
80.9
95.0
96.5
83.1
87.1
96.1
97.0
80.9
81.3
93.3
99.3
87.1
84.2
95.3
chewinggum
94.3
59.7
65.0
97.0
96.0
67.4
63.0
96.7
97.3
80.5
75.3
95.5
98.8
80.3
77.1
98.8
98.5
81.2
74.8
99.3
99.5
84.6
78.2
99.4
fryum
88.2
41.3
34.1
81.9
90.4
45.7
43.2
89.3
93.4
57.1
52.9
92.1
94.8
62.9
56.8
94.4
95.8
63.8
59.0
93.6
91.5
55.1
51.3
96.4
Table 3: Comparison on pixel-level segmentation and image-level detection on VisA dataset by training U-Nets on the generated data from DRÆM, DFMGAN, AnomalyDiffusion, DualAnoDiff, SeaS and our proposed GroundingAnomaly.
Table 8
Figure 5: Left: Qualitative analysis of SFF. The red outline denotes the ground-truth mask. While SeaS [ 40 ] suffers from spatial misalignment, our model without SFF (w/o SFF) achieves accurate bounding. Our full model (Ours) leverages SFF to achieve both precise spatial grounding and high-fidelity anomaly synthesis. Right: Unseen anomaly generation results on MVTec AD and VisA. GroundingAnomaly is trained on anomalous images and finetuned on normal images from another product.
Table 10
Figure 6: Multi-anomaly generation result of GroundingAnomaly.
Appendix figures & tables19 assets
Supplementary material from the paper’s appendix.
Appendix
Model
IS
IC-L
AUC-P
AP-P
AP-I
N=1K=1
1.79
0.37
97.2
80.5
99.1
N=1K=4
1.77
0.39
97.7
79.7
98.9
N=4K=1
1.73
0.40
95.6
78.7
98.7
N=4K=4 ( Ours )
1.99
0.41
99.2
85.9
99.2
Appendix
Table 8: Ablation on different numbers of tokens.
Figure 7: Illustration of ablations on GSM. (i) Gated Cross-Attention Module; (ii) Discarding Visual Tokens; (iii) Ungated Self-Attention Module; (iv) Ours.
Model
IS
IC-L
AUC-P
AP-P
AP-I
GCM
1.71
0.35
98.1
80.7
99.0
DVT
1.72
0.39
98.3
81.7
98.7
USM
1.68
0.40
94.9
74.1
98.0
w/o LoRA
1.93
0.39
98.3
83.3
99.0
Ours
1.99
0.41
99.2
85.9
99.2
Appendix
Table 9: Ablation on Gated Self-Attention Module.
Figure 8: Qualitative comparison of spatial conditioning. GroundingAnomaly achieves the highest fidelity and conditioning accuracy. Futhermore, models conditioned on binary masks, by contrast, often produce anomalies that are less semantically similar to the expected anomaly class.
Model
IS
IC-L
AUC-P
AP-P
AP-I
ControlNet+Mask
1.81
0.39
96.7
69.2
96.1
ControlNet+SM
1.86
0.40
96.9
70.3
96.2
GLIGEN+Mask
1.85
0.39
98.1
73.3
97.7
GLIGEN+SM
1.88
0.42
98.3
75.2
97.8
Ours+Mask
1.89
0.39
98.2
74.9
97.1
Ours+SM
1.99
0.41
99.2
85.9
99.2
Appendix
Table 10: Ablation on spatial conditioning.
Model
DFMGAN
AnomalyDiffusion
DualAnoDiff
SeaS
Ours
AUROC
AP
F1-max
maxIoU
AUROC
AP
F1-max
maxIoU
AUROC
AP
F1-max
maxIoU
AUROC
AP
F1-max
maxIoU
AUROC
AP
F1-max
maxIoU
MVTec AD
BiSeNet V2
94.57
60.42
60.54
45.83
96.27
64.50
62.27
42.89
96.88
66.21
61.17
46.97
97.21
69.21
66.37
55.28
97.58
75.03
68.71
52.34
UPerNet
92.33
57.01
56.91
46.64
96.87
69.92
66.95
50.80
97.17
72.08
67.55
51.15
97.87
74.42
70.70
61.24
97.24
77.09
75.60
59.49
Segformer
93.20
58.50
58.10
47.30
97.10
71.20
68.00
52.10
97.63
73.55
68.71
56.33
97.50
81.30
74.85
59.81
98.53
82.63
75.51
60.66
Average
93.37
58.64
58.52
46.59
96.75
68.54
65.74
48.60
97.23
70.61
65.81
51.48
97.53
74.98
70.64
58.78
97.78
78.25
73.27
57.50
Appendix
Table 11: Comparison on trained unified supervised segmentation models for pixel-level anomaly segmentation on MVTec AD and VisA.
Model
DFMGAN
AnomalyDiffusion
DualAnoDiff
SeaS
Ours
AUROC
AP
F1-max
AUROC
AP
F1-max
AUROC
AP
F1-max
AUROC
AP
F1-max
AUROC
AP
F1-max
MVTec AD
BiSeNet V2
90.90
94.43
90.33
90.08
94.84
91.84
91.33
96.79
94.49
96.00
98.14
95.43
96.41
97.87
95.88
UPerNet
90.74
94.43
90.37
96.62
98.61
96.21
97.89
99.00
96.77
98.29
99.20
97.34
98.63
98.77
97.24
Segformer
90.97
94.69
91.11
95.73
98.66
96.37
96.97
98.79
97.03
98.33
99.17
97.41
98.74
98.93
97.55
Average
90.87
94.52
90.60
94.14
97.37
94.81
95.40
98.19
96.10
97.54
98.84
96.73
97.93
98.52
96.89
Appendix
Table 12: Comparison on trained unified supervised segmentation models for image-level anomaly detection on MVTec AD and VisA.
Figure 9: Examples of 1-shot and 2-shot generated images.
Figure 10: P-AUROC of U-Nets trained by synthesized data.
Figure 11: Examples of anomaly generation on MVTec AD.
Figure 12: Examples of anomaly generation on MVTec AD.
Figure 13: Examples of anomaly generation on MVTec AD.
Figure 14: Examples of anomaly generation on VisA.
Figure 15: Examples of anomaly generation on VisA.
Category
DFMGAN
AnoDiff
DualAnoDiff
SeaS
Ours
IS ↑
IC-L ↑
IS ↑
IC-L ↑
IS ↑
IC-L ↑
IS ↑
IC-L ↑
IS ↑
IC-L ↑
bottle
1.62
0.12
1.58
0.19
2.17
0.36
1.78
0.21
1.97
0.35
cable
1.96
0.25
2.13
0.41
2.12
0.43
2.09
0.42
2.23
0.43
capsule
1.59
0.11
1.59
0.21
1.60
0.31
1.69
0.21
1.92
0.34
carpet
1.23
0.13
1.16
0.24
1.36
0.29
1.21
0.25
1.39
0.30
grid
1.97
0.13
2.04
0.44
2.09
0.42
2.62
0.44
3.13
0.53
Appendix
Table 13: Per category IS and IC-LPIPS on MVTec AD.
Category
DFMGAN
AnoDiff
DualAnoDiff
SeaS
Ours
IS ↑
IC-L ↑
IS ↑
IC-L ↑
IS ↑
IC-L ↑
IS ↑
IC-L ↑
IS ↑
IC-L ↑
candle
1.19
0.23
1.28
0.17
1.27
0.15
1.20
0.12
1.25
0.17
capsules
1.25
0.22
1.39
0.50
1.37
0.55
1.58
0.60
1.58
0.60
cashew
1.25
0.24
1.27
0.26
1.29
0.24
1.21
0.28
1.21
0.33
chewinggum
1.33
0.24
1.15
0.19
1.19
0.20
1.29
0.27
1.29
0.32
fryum
1.28
0.20
1.20
0.14
1.17
0.14
1.14
0.21
1.14
0.26
Appendix
Table 14: Per category IS and IC-LPIPS on VisA.
Category
DFMGAN
AnoDiff
DualAnoDiff
SeaS
Ours
mAP ↑
mAP ↑
mAP ↑
mAP ↑
mAP ↑
MVTec AD
bottle
39.56
47.44
45.41
43.77
50.90
cable
58.23
58.07
59.07
57.40
60.16
capsule
7.83
7.31
7.52
9.23
10.30
carpet
15.97
14.19
26.75
23.48
26.38
Appendix
Table 15: Per category instance-level mAP (%) for MVTec AD (top) and VisA (bottom) of Faster R-CNN.
Category
DFMGAN
AnoDiff
DualAnoDiff
SeaS
Ours
mAP ↑
mAP ↑
mAP ↑
mAP ↑
mAP ↑
MVTec AD
bottle
35.90
40.90
41.12
40.45
44.75
cable
67.08
59.87
44.93
57.71
54.82
capsule
9.09
6.94
10.29
12.11
12.11
carpet
17.28
18.59
34.82
25.92
33.91
Appendix
Table 16: Per category instance-level mAP (%) for MVTec AD (top) and VisA (bottom) of DETR.
Category
DFMGAN
AnoDiff
DualAnoDiff
SeaS
Ours
mAP ↑
mAP ↑
mAP ↑
mAP ↑
mAP ↑
MVTec AD
bottle
43.63
55.66
51.47
52.04
56.84
cable
66.80
64.29
68.13
61.67
68.60
capsule
8.40
11.03
8.28
9.30
11.54
carpet
24.04
23.21
35.81
29.22
35.32
Appendix
Table 17: Per category instance-level mAP (%) for MVTec AD (top) and VisA (bottom) of YOLOv5.