Attention-enhanced deep learning framework with explainability and transfer learning for X-ray inspection
摘要
This study proposes a comprehensive defect-detection methodology for industrial welding X-ray images, integrating a lightweight deep learning model, cross-dataset transfer learning validation, and explainable AI (XAI) analysis. To address the prevalent challenges of insufficient data and inconsistent labeling standards in industrial inspection scenarios, a standardized cross-dataset workflow is established. This workflow incorporates automated image preprocessing and defect-region cropping, using the public RIAWELC and GDXray datasets for transfer learning experiments. Experimental results demonstrate that the proposed pipeline effectively enhances the model’s adaptability across diverse X-ray imaging sources and exhibits robust generalization performance. Considering the hardware resource constraints of edge computing devices in practical applications, this study further develops a lightweight ResNet15 model integrated with the Convolutional Block Attention Module (CBAM). Introducing channel and spatial attention mechanisms into the residual structure significantly enhances the representation capability of critical features, compensating for the limited feature-extraction depth found in shallower networks. Empirical results indicate that the proposed model achieves 81.81% classification accuracy with only 0.71 M parameters, performing comparably to significantly deeper architectures. This suggests that lightweight models hold substantial practical value for real-time industrial inspection. Furthermore, to improve the reliability and transparency of the model for industrial deployment, this paper employs various visualization methods, including Grad-CAM, Score-CAM, Grad-CAM++, and Eigen-CAM, to analyze the influence of the attention mechanism on model decision-making. The results show that integrating the CBAM module enables the model to focus more consistently on regions relevant to welding defects, mitigating the attention dispersion observed in the original ResNet architecture. This enhancement improves the interpretability of detection results and advances the practical feasibility of intelligent manufacturing systems.