Abstract:The quality of resistance spot welding directly affects the structural stability and safety of automobile bodies. Pixel-level segmentation maps of welding defects are crucial for accurately analyzing defect morphology and severity. To address the limitations of traditional object detection methods in precisely segmenting small-scale defects and achieving high classification accuracy, this paper proposes a precise localization and segmentation method for RSW defects based on a multi-scale feature fusion network. By integrating cross-level feature connections and multi-scale feature matching, the network captures both global welding characteristics and fine-grained defect details, enabling accurate semantic segmentation of defects in large scenes and improving classification accuracy in RSW regions. A candidate region generation network is designed to fuse low-level detailed features with high-level semantic information, and a custom localization loss function is introduced to ensure accurate positioning of spot weld regions. Subsequently, a defect segmentation and localization network is proposed, which incorporates ROI Align and multi-scale feature matching to construct a normal feature bank for spot welds and formulates an anomaly scoring function for pixel-level anomaly scoring of weld regions. Experimental results show that, compared with traditional object detection models, the proposed method improves the classification accuracy for small RSW targets by 25.35% and enhances the F1 score by 14.81%. Moreover, it produces high-precision pixel-level segmentation maps, achieving a Pixel AUROC of 0.94, demonstrating excellent defect recognition capabilities. The method also achieves good performance on open-source RSW datasets from various industrial scenarios, with an F1 score of 0.93, verifying the generalization ability of the model.