Ground-truth defect masks in industrial inspection datasets are typically reserved for evaluation. This paper repurposes them as spatial supervision signals during training of classification networks, teaching a model not just what to predict but where to look. The method adds an activation-based attention alignment loss that steers convolutional feature maps toward defect regions, in a mixed-supervision formulation that also accommodates samples without masks, such as diffusion-generated images. Combined with DDPM augmentation, synthetic images contribute quantity while masks contribute spatial precision. We evaluate 85 models (four CNN backbones under a 2x2 data/training factorial over five seeds, plus a Swin-V2-T transformer baseline) on the MVTec-AD bottle benchmark, with localization measured on held-out defect images excluded from classifier gradient updates. Main findings: (1) attention-guided training improves activation-based localization (Pixel-AUROC) by +18.0% for EfficientNetB0 with augmentation (p=0.005, Cohen's d=2.6) and +18.7% for ResNet50 (p=0.008), significant in four of eight CNN settings (uncorrected for multiple comparisons) with no significant change in classification; (2) for EfficientNetB0 a data x training-mode interaction is significant (p=0.002), consistent with a super-additive effect (+13.6% combined vs +1.6% summed individual effects); (3) architectures with weaker spatial representations benefit most, whereas ConvNeXt-T shows no effect, apparently because its depthwise-convolution activations yield spatially uninformative channel-mean maps; (4) unsupervised PatchCore remains the strongest localizer (Pixel-AUROC=0.983), contextualizing the supervised gains. These results show that existing evaluation masks can act as practical training signals that measurably and reproducibly improve where defect classifiers attend.
Figures & tables
Approach
Use of Masks
Difference from Proposed
Segmentation (U-Net, DeepLab)
Direct output target
Predicts mask; typically trained with dense mask supervision
Ross et al. [ 15 ]
Gradient penalty
Input gradients (not activations); not industrial
Kasem et al. [ 13 ]
None (architectural)
CBAM modules in architecture, not a training loss
Region-Aware CAM [ 14 ]
Evaluation only
Weakly-supervised; no mask-guided training
PatchCore [ 20 ]
Evaluation only
Unsupervised; masks unused during training
Prior work [ 3 ]
Evaluation only
DDPM augmentation for classification; no localization
Table 1: Positioning relative to prior work. Among the approaches reviewed, the proposed method is distinctive in combining auxiliary mask supervision with diffusion augmentation in a mixed-supervision setting.
Figure 1: Pipeline overview. Data: MVTec-AD bottle with optional DDPM augmentation. Training: 85 models total, four CNN backbones under a 2×2 factorial (data setting × training mode) across five seeds, plus Swin-V2-T baseline across five seeds. Evaluation: held-out classification metrics and held-out localization via Pixel-AUROC.
Backbone
Type
Year
Params
Input Size
EfficientNetB0 [ 25 ]
CNN
2019
5.3M
224 × 224
MobileNetV2 [ 26 ]
CNN
2018
3.5M
224 × 224
ResNet50 [ 27 ]
CNN
2016
25.6M
224 × 224
ConvNeXt-T [ 28 ]
CNN
2022
28.6M
224 × 224
Swin-V2-T [ 29 ]
Transformer
2022
28M
256 × 256
Table 2: Backbone Architectures.
Backbone
Config
F1
AUROC
Recall
EfficientNetB0
Real, Std
.888 ± .072
.961 ± .048
.911
Real, AG
.878 ± .086
.949 ± .066
.911
Aug, Std
.902 ± .063
.975 ± .016
.842
Aug, AG
.886 ± .052
.977 ± .012
.827
MobileNetV2
Real, Std
.844 ± .067
.962 ± .031
.867
Real, AG
.878 ± .058
.971 ± .018
.889
Table 3: Held-out classification performance (F1 and AUROC as mean ± std across 5 seeds; Recall as mean). Best F1 per backbone in bold. For ConvNeXt-T, standard and attention-guided training yield classification metrics that coincide to three decimal places (the alignment loss produces no discernible change in its classification; see Section 6.1 ), so the two modes are reported jointly as “Std/AG.”
Figure 2: ( a ) Held-out classification F1 across four training configurations for three CNN architectures. Swin-V2-T reference line at F1=1.000. ( b ) Best configuration per architecture, showing ConvNeXt-T and Swin-V2-T dominate classification while lighter CNNs achieve 0.88 to 0.90 F1.
Backbone
Data
Std
AG
Δ
p
d
EfficientNetB0
Real
0.552 ± .047
0.582 ± .058
+5.4%
0.051
1.23
+DDPM
0.531 ± .063
0.627 ± .040
+18.0%
0.005
2.57
MobileNetV2
Real
0.563 ± .053
0.585 ± .055
+4.0%
0.020
1.68
+DDPM
0.562 ± .054
0.588 ± .044
+4.5%
0.238
0.62
ResNet50
Real
0.464 ± .045
0.550 ± .049
+18.7%
0.008
2.18
+DDPM
0.454 ± .040
0.509 ± .013
+12.0%
0.023
1.61
Table 4: Held-out localization (activation-based Pixel-AUROC, mean ± std across 5 seeds). Each model is evaluated only on held-out validation defect images excluded from its gradient updates. Δ is the relative change from standard (Std) to attention-guided (AG); p is a paired t -test (by seed) and d is Cohen’s d . Significant improvements ( p<0.05 , uncorrected for multiple comparisons) in bold. Swin-V2-T (occlusion) and PatchCore (unsupervised) are localization references. 0 0 footnotetext: † ConvNeXt-T shows no consistent effect and very high seed variance; a plausible explanation is that its depthwise-convolution activations are spatially uninformative, which would leave the alignment loss with little useful gradient (Section 6.1 ).
Figure 3: ( a ) Held-out activation-based localization (Pixel-AUROC): standard vs. attention-guided across three CNN architectures and two data settings, with error bars (std across 5 seeds) and the PatchCore reference line. ( b ) 2×2 decomposition for EfficientNetB0: DDPM augmentation and attention guidance together show a significant super-additive interaction ( p=0.002 ; Section 5.3 ).
Figure 4: Held-out activation-based vs. Grad-CAM localization for the four CNN backbones (AugmentedData-trained, evaluated on held-out defect images). Arrows show the shift from standard (circle) to attention-guided (square) training. All points fall below the diagonal, indicating that Grad-CAM outperforms raw activation maps. Arrows point upward for EfficientNetB0, MobileNetV2, and ResNet50, showing that attention guidance improves activation-based localization while leaving Grad-CAM largely unchanged. ConvNeXt-T’s arrow does not point up: its activation map is spatially uninformative and high-variance, and the alignment loss does not improve it, even though its Grad-CAM localization is the strongest of all backbones (see Section 6.1 ).
Backbone
Data
Std
AG
Δ
p
d
EfficientNetB0
Real
0.749 ± .041
0.753 ± .041
+0.5%
0.526
0.31
+DDPM
0.752 ± .064
0.772 ± .039
+2.6%
0.323
0.50
MobileNetV2
Real
0.623 ± .086
0.623 ± .063
0.0%
0.993
0.00
+DDPM
0.696 ± .073
0.703 ± .051
+1.1%
0.714
0.18
ResNet50
Real
0.543 ± .023
0.579 ± .025
+6.6%
0.044
1.30
+DDPM
0.485 ± .044
0.537 ± .026
+10.7%
0.024
1.59
Table 5: Held-out Grad-CAM localization (Pixel-AUROC, mean ± std across 5 seeds), reported as in Table 4 . Δ is the standard → attention-guided change; p is a paired t -test (by seed) and d is Cohen’s d . Grad-CAM values exceed the activation-based ones (cf. Table 4 ); attention guidance transfers to Grad-CAM significantly only for ResNet50 (significant improvements in bold).
Figure 5: Qualitative comparison of activation heatmaps for EfficientNetB0 (AugmentedData). Columns: input image, ground-truth mask, standard training heatmap, attention-guided heatmap. Attention-guided models produce activations that are visually more concentrated on the actual defect regions.
Industrial surface defect detection often suffers from limited defect samples, severe long-tailed distributions, and difficulties in accurately localizing subtle defects under complex backgrounds. To address these challenges, this paper proposes an unsupervised defect detection method that integrates a Denoising Diffusion Probabilistic Model (DDPM) with an asymmetric teacher-student architecture. First, at the data level, the DDPM is trained solely on normal samples. By introducing constant-variance Gaussian perturbations and Perlin noise-based masks, high-fidelity and physically consistent defect samples along with pixel-level annotations are generated, effectively alleviating the data scarcity problem. Second, at the model level, an asymmetric dual-stream network is constructed. The teacher network provides stable representations of normal features, while the student network reconstructs normal patterns and amplifies discrepancies between normal and anomalous regions. Finally, a joint optimization strategy combining cosine similarity loss and pixel-wise segmentation supervision is adopted to achieve precise localization of subtle defects. Experimental results on the MVTecAD dataset show that the proposed method achieves 98.4% image-level AUROC and 98.3% pixel-level AUROC, significantly outperforming existing unsupervised and mainstream deep learning methods. The proposed approach does not require large amounts of real defect samples and enables accurate and robust industrial defect detection and localization. \keywords{Industrial defect detection \and diffusion models \and data generation \and teacher-student architecture \and pixel-level localization}
Shuo Feng, Runlin Zhou, Yuyang Li +1
School of Automation, Southeast University, Nanjing, China
Industrial anomaly detection and localization are limited by scarce real anomalies and pixel-level annotations, a bottleneck that synthetic image-mask pairs can alleviate. However, existing few-shot mask-guided generation may over-follow mask geometry, produce weak anomalies, or use condition masks incompatible with the current object instance. We propose OSAGEN, which combines object-aware mask priors with multistage decoupled diffusion. Its three-stage adaptation sequentially learns normal appearance, defect appearance under coarse conditions, and fine-grained mask calibration, improving defect realization and local control. QBG injects object structure from a matched normal image into mask diffusion to produce object-aware priors, while ISC restricts anomaly propagation and preserves normal content during sampling. A lightweight materialization step recovers pixel-level labels aligned with the realized defects. On MVTec AD and VisA, OSAGEN achieves AP-P/F1-P scores of 88.1/82.2 and 68.5/66.1, respectively, under a unified downstream localization protocol. The code will be released upon acceptance.
Jinyi Xu, Peng Chen, Yunkang Cao +3
School of Cyber Science and Technology, Shenzhen Campus of Sun Yat-sen University · School of Artificial Intelligence and Robotics, Hunan University · Department of Computer and Information Science, University of Macau +1
Accurate defect segmentation is critical for industrial inspection, yet dense pixel-level annotations are rarely available. A common workaround is to convert inexpensive bounding boxes into pseudo-masks using foundation segmentation models such as the Segment Anything Model (SAM). However, these pseudo-labels are systematically noisy on industrial surfaces, often hallucinating background structure while missing sparse defects. To address this limitation, a noise-robust box-to-pixel distillation framework, Boxes2Pixels, is proposed that treats SAM as a noisy teacher rather than a source of ground-truth supervision. Bounding boxes are converted into pseudo-masks offline by SAM, and a compact student is trained with (i) a hierarchical decoder over frozen DINOv2 features for semantic stability, (ii) an auxiliary binary localization head to decouple sparse foreground discovery from class prediction, and (iii) a one-sided online self-correction mechanism that relaxes background supervision when the student is confident, targeting teacher false negatives. On a manually annotated wind turbine inspection benchmark, the proposed Boxes2Pixels improves anomaly mIoU by +6.97 and binary IoU by +9.71 over the strongest baseline trained under identical weak supervision. Moreover, online self-correction increases the binary recall by +18.56, while the model employs 80% fewer trainable parameters. Code is available at https://github.com/CLendering/Boxes2Pixels.
Camile Lendering, Erkut Akdag, Egor Bondarev
AIMS Group, Department of Electrical Engineering, Eindhoven University of Technology