Welded part surface defect detection method and system based on gray level co-occurrence matrix and YOLOv11

Through the grayscale symbiosis matrix and the improved YOLOv11 model welded surface defect detection method, the problems of low efficiency of traditional detection methods and poor adaptability of deep learning models are solved, and efficient and stable detection of small defects on the surface of welded parts is achieved.

CN120495243APending Publication Date: 2025-08-15SHANDONG LAIGANG ENERGY SAVING ENVIRONMENTAL PROTECTION ENG
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202510595094.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-09
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

The existing welded surface defect detection methods are inefficient and poor adaptability, the deep learning model has weak detection capabilities for small targets, and the multimodal feature fusion is missing, resulting in insufficient detection accuracy and robustness.

Method used

Welded surface defect detection method based on grayscale symbiosis matrix and improved YOLOv11 model is adopted, and real-time detection is achieved through data enhancement, multi-scale texture feature extraction, attention mechanism and multi-scale feature fusion, combined with embedded device deployment.

Benefits of technology

It improves the detection accuracy and robustness of the tiny defects on the surface of the welded parts, reduces the calculation amount, meets the real-time requirements of embedded devices, and enhances the model's adaptability and detection stability to complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120495243A_ABST
    Figure CN120495243A_ABST
Patent Text Reader

Abstract

The invention discloses a weldment surface defect detection method and system based on a gray level co-occurrence matrix and YOLOv11, and belongs to the technical field of weldment surface defect detection. According to the technical scheme, the method and system for detecting the surface defects of the welding part based on the gray-level co-occurrence matrix and the YOLOv11 specifically comprise the following steps that S1, an industrial camera collects surface images of the welding part under different defect types and illumination conditions, data enhancement processing is carried out, and data enhancement comprises horizontal overturning, color changing, scaling and noise injection; s2, marking bounding box positions and category labels of defects in the enhanced image; according to the method, the texture features of the gray level co-occurrence matrix and the depth features of the improved YOLOv11 model are fused, the attention mechanism and the multi-scale feature fusion technology are combined, the problems that a traditional method is low in efficiency and poor in adaptability and a deep learning model is insufficient in small target detection capacity are effectively solved, and the method has the advantages of being high in detection precision and high in environmental adaptability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of weld surface defect detection, and specifically relates to a weld surface defect detection method and system based on gray-level co-occurrence matrix and YOLOv11. Background Art

[0002] Detecting surface defects in welds (such as pores, cracks, and slag inclusions) is a critical step in ensuring the safety and reliability of welded structures. Traditional inspection methods and existing automated technologies have the following major limitations: First, manual inspection is inefficient and highly subjective. Traditional inspection relies on visual inspection or simple optical instruments, resulting in low efficiency and susceptible to operator experience, making standardization difficult. In complex industrial environments such as strong light and smoke, the human eye easily fatigues, significantly increasing missed detection and false detection rates. Second, traditional image processing methods have poor adaptability. Image processing-based detection techniques (such as edge detection, threshold segmentation, and morphological operations) rely on manually designed features and are sensitive to interference such as lighting changes and surface reflections. For example, while the gray-level co-occurrence matrix (GLCM) can extract texture features, methods using GLCM alone have difficulty distinguishing subtle defects against complex backgrounds. Feature selection relies on expert experience, resulting in insufficient generalization. Third, existing deep learning models lack accuracy and efficiency. In recent years, deep learning-based object detection models (such as Faster R-CNN and the YOLO series) have been introduced into the field of defect detection. However, these models still face the following challenges: They have weak detection capabilities for small targets. Weld surface defects (such as micron-sized pores) are easily overlooked by the model due to their small size and unclear features. They also have poor robustness in complex environments. In scenarios such as strong light reflection and smoke obscuration, the models are susceptible to background noise interference, leading to false detections. Furthermore, existing models require high computational resources, and their large number of parameters makes them difficult to deploy in embedded devices or real-time inspection systems on production lines. Finally, multimodal feature fusion is lacking. Existing research on the fusion of traditional texture features (such as GLCM) with deep learning features is limited. Most solutions rely solely on raw image input, failing to fully utilize the ability of texture information to represent subtle defects. This results in insufficient sensitivity to specific defect types (such as cracks and spots). To address these issues, existing technologies urgently need improvement. Summary of the Invention

[0003] The present invention provides a method and system for detecting surface defects of welded parts based on gray-level co-occurrence matrix and YOLOv11 to solve at least one of the above technical problems.

[0004] The technical solution adopted in the present invention is:

[0005] A method for detecting surface defects of welded parts based on gray-level co-occurrence matrix and YOLOv11 has the following specific steps: S1, an industrial camera collects surface images of welded parts under different defect types and lighting conditions, and performs data enhancement processing, wherein the data enhancement includes horizontal flipping, color conversion, scaling and noise injection; S2, annotates the bounding box position and category label of the defects in the enhanced image, and divides the data set into a training set, a validation set and a test set in proportion; S3, converts the image into a grayscale image, and extracts multi-scale texture features based on the gray-level co-occurrence matrix (GLCM), wherein the texture features include energy, contrast and homogeneity; S4, constructs an improved YOLOv11 model, wherein the model includes a backbone network embedded with a CBAM attention mechanism, an edge feature enhancement layer and a multi-scale feature fusion module; S5, inputs the texture features extracted by GLCM into the improved YOLOv11 model for training to generate a welded part surface defect detection model; S6, deploys the detection model to an embedded device, and outputs the defect type, location and confidence in real time.

[0006] Preferably, in step S2, the annotation file format is XML, and a label file in YOLO format is generated by a conversion tool, and the label information includes normalized center coordinates, width, height and category number.

[0007] Preferably, the calculation of the grayscale co-occurrence matrix in step S3 includes the following steps: S31, compressing the image grayscale to a preset range to reduce the computational complexity; S32, statistically calculating the grayscale co-occurrence frequency based on the distance d and direction θ of the pixel neighborhood to generate a multi-scale GLCM; S33, extracting the energy, contrast and homogeneity characteristics of the GLCM to construct a multi-channel texture matrix.

[0008] Preferably, the CBAM attention mechanism is embedded in the backbone network of the improved YOLOv11 model, specifically including:

[0009] Step 1: Insert CBAM modules after layers 0, 1, 2, and 5 of the backbone network respectively;

[0010] Step 2: The CBAM module performs channel attention and spatial attention calculations in sequence, and outputs a weighted feature map.

[0011] Preferably, the structure of the edge feature enhancement layer includes: 1 edge detection convolution layer, 2 fully connected layers, 1 fusion convolution layer and 3 activation layers; the original feature map is fused with the edge enhancement feature through jump connection to retain the integrity of spatial information.

[0012] Preferably, the multi-scale feature fusion module in step S4 includes: S41, three scale feature maps output by the backbone network; S42, feature pyramid network FPN cross-scale fusion of the feature maps to generate fused multi-scale defect features.

[0013] Preferably, the training of the model in step S5 adopts the following optimization strategy: S51, inputting the GLCM texture features and the original image features into the model through channel splicing; S52, using dynamic learning rate adjustment and early stopping mechanism to prevent overfitting.

[0014] Preferably, the functional modules of the detection system in step S6 include: S61, real-time detection screen display, model initialization interface, camera control unit, confidence threshold adjustment and operation log output.

[0015] A weld surface defect detection system based on gray-level co-occurrence matrix and YOLOv11 includes an industrial camera module for acquiring weld surface images; a deployment platform for supporting the real-time operation of the detection model on an embedded device and outputting defect detection results.

[0016] Preferably, it further includes a computer-readable storage medium, characterized in that the storage medium stores a computer program, and when the program is executed by a processor, the weld surface defect detection method according to any one of claims 1 to 8 is implemented.

[0017] Due to the adoption of the above technical solution, the beneficial effects achieved by the present invention are as follows:

[0018] 1. This solution achieves multimodal information fusion through feature splicing. Compared to the unmodified YOLO model, this solution significantly improves detection accuracy in strong light reflection scenarios. Simultaneously, model compression reduces computational complexity by approximately 40%, meeting the real-time requirements of embedded devices.

[0019] This effectively addresses the issue of missed detection of minor surface defects in welds, maintaining stable detection performance even on production lines subject to smoke interference. By integrating traditional texture features with deep learning features, the model's recognition accuracy for linear defects such as cracks increased by 25 percentage points. While maintaining detection accuracy, the improved network structure reduces the number of model parameters by 30%, enabling real-time detection at 30 frames per second on industrial embedded devices with limited computing power.

[0020] 2. Through a standardized conversion process, we ensure that the annotated data strictly matches the model input format, avoiding training errors caused by non-normalized coordinates and reducing the time and cost of manually adjusting annotation files. This seamlessly aligns the annotated data format with model requirements, eliminating model convergence difficulties caused by non-normalized coordinates and improving training efficiency. Automated conversion tools reduce manual intervention, lower annotation error rates, and ensure data consistency. Normalization allows the model to adapt to input images of various resolutions, enhancing deployment flexibility.

[0021] 3. Through multi-scale GLCM generation and multi-channel feature fusion, the texture features of defects of different sizes can be more comprehensively covered. For example, effective texture difference information can be extracted for both micron-scale pores and millimeter-scale cracks. At the same time, grayscale compression significantly reduces computational time. This solves the problem of missed detection of subtle defects caused by single-scale feature extraction in traditional GLCM methods, improves the robustness of texture features to complex background interference, and through grayscale quantization and multi-channel fusion design, achieves a balance between computational efficiency and detection accuracy while maintaining feature representation capabilities.

[0022] 4. This solution utilizes sequential channel-spatial attention computation to establish a feature screening mechanism at multiple network levels. This effectively improves the model's feature discrimination capabilities in scenarios with complex surface reflections and smoke interference on welds. This allows for precise localization of subtle surface defects, particularly when dealing with halo interference from highly reflective surfaces. Spatial attention can suppress false responses in non-defective areas. Furthermore, the channel-attention mechanism enhances the texture feature channels specific to defects such as cracks and pores, improving the model's detection stability in low-contrast images.

[0023] 5. By integrating a multi-level fully connected architecture with a skip connection mechanism, the edge response strength is enhanced while preserving the original feature resolution. This significantly improves the continuity of edge features when processing micron-scale porosity defects. This overcomes the problem of insufficient edge feature extraction in traditional models under complex lighting or noise interference, effectively improving the detection accuracy of linear defects such as cracks and slag inclusions on weld surfaces. This architecture enhances the model's sensitivity to subtle edge changes through a multi-level feature fusion mechanism while ensuring the spatial integrity of the feature map, enabling the detection model to accurately identify surface defects of varying sizes and shapes when running on embedded devices.

[0024] 6. Through the cross-scale fusion mechanism of the feature pyramid network, feature maps at different levels are effectively integrated, so that the fused features not only retain the detailed information of small targets, but also have the semantic representation ability of large targets. This application can improve the model's detection accuracy for defects of different sizes, especially in complex industrial scenarios. The characteristic information of defects such as tiny pores or cracks can be retained, while reducing the interference of background noise on the detection results, thereby improving the robustness of defect recognition.

[0025] 7. By combining multimodal feature fusion with dynamic optimization strategies, overfitting can be effectively suppressed while ensuring training efficiency. This application can improve the model's detection accuracy for defects such as tiny pores and cracks on the surface of welds, avoid model overfitting caused by insufficient training data or noise interference, and enhance the generalization performance of the detection system in complex industrial environments.

[0026] 8. This solution builds standardized functional modules to achieve dynamic adjustment of detection parameters and visual monitoring of operating status, effectively improving the convenience of system operation and data management efficiency.

[0027] Through the above technical solution, this application achieves stable operation and efficient human-computer interaction of the detection system on embedded devices, solving the deployment difficulties caused by the low functional integration of traditional solutions. The modular design reduces the complexity of system maintenance, and the continuous recording of operation logs provides data support for equipment status monitoring and process optimization.

[0028] 9. This solution ensures image acquisition quality through a dedicated industrial camera module and achieves lightweight model operation in combination with an embedded deployment platform. While maintaining detection accuracy, it reduces equipment power consumption to below 15W, meeting the needs of long-term continuous operation in industrial sites. This application effectively solves the problems of low efficiency of traditional manual inspection and the difficulty of deploying existing deep learning models on embedded devices, and realizes real-time automated detection of surface defects in welds. The system can still stably output detection results in complex environments such as strong light reflection and smoke interference, and significantly improves the detection rate of minor defects such as pores and cracks. At the same time, it avoids the difficulties of production line transformation caused by the large size of equipment in traditional solutions.

[0029] 10. Through a customized storage format and hierarchical storage architecture, model parameters are compressed to 30%-50% of their original size, while an on-demand loading mechanism is employed to reduce memory usage. Existing program execution processes often lack instruction set optimizations tailored to industrial inspection scenarios. This application, through hardware instruction acceleration and computational graph optimization, reduces single-frame inspection time to under 50 milliseconds.

[0030] Through the above technical solution, this application enables rapid deployment and stable operation of detection models in embedded devices, resolving the detection delay problem caused by insufficient storage media read and write efficiency in traditional solutions. Computing resources are dynamically allocated during program execution to ensure a stable frame processing rate even under high-frequency detection tasks. The storage media partition management mechanism prevents data corruption and ensures the long-term reliable operation of the detection system in complex industrial environments. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 This is a flow chart of the method for detecting surface defects of welded parts proposed by the present invention;

[0032] Figure 2 This is the UI interface of the welding defect detection system in the specific embodiment of the present invention;

[0033] Figure 3 Schematic diagram of the composition of the YOLOv11 architecture in the present invention.

[0034] The drawings described herein are used to provide further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention. DETAILED DESCRIPTION

[0035] In order to more clearly illustrate the overall concept of the present invention, a detailed description is given below in an exemplary manner in conjunction with the accompanying drawings.

[0036] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the scope of protection of the present invention is not limited to the specific embodiments disclosed below.

[0037] In the present invention, unless otherwise clearly specified and limited, a first feature "above" or "below" a second feature may be that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. In the description of this specification, the description with reference to the terms "implementation method", "embodiment", "one embodiment", "example" or "specific example" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in an appropriate manner in any one or more embodiments or examples.

[0038] Reference Figure 1-Figure 3As a specific implementation method of the present application, the present application proposes a method for detecting surface defects of welded parts based on gray-level co-occurrence matrix and YOLOv11, and the specific steps are as follows: an industrial camera collects surface images of welded parts under different defect types and lighting conditions and performs data enhancement processing; annotates the bounding box positions and category labels of defects in the enhanced images and divides the data set; converts the image into a grayscale image and extracts multi-scale texture features based on the gray-level co-occurrence matrix; constructs an improved YOLOv11 model, which includes a backbone network embedded with an attention mechanism, an edge feature enhancement layer and a multi-scale feature fusion module; inputs texture features into the improved model for training to generate a detection model; and deploys the model to an embedded device to realize real-time detection.

[0039] Data augmentation processing refers to increasing data diversity through image transformation. Specifically, horizontal flipping can be used to change the image's orientational symmetry, color transformation can be used to adjust the color gamut distribution, scaling can be used to simulate different shooting distances, and noise injection can be used to increase robustness. The grayscale co-occurrence matrix is a two-dimensional matrix that reflects the texture characteristics of the image. Specifically, it can be achieved by counting the grayscale co-occurrence frequency of pixel neighborhoods, extracting energy features to represent texture uniformity, contrast features to reflect clarity, and homogeneity features to reflect local similarity. The multi-scale feature fusion module integrates feature maps of different resolutions. Specifically, a feature pyramid network can be used to transfer information across scales and preserve the spatial information of small target features.

[0040] Specifically, after capturing images with an industrial camera, sample variants are generated through horizontal flipping and color transformation. Scaling operations are used to simulate different imaging scales, and Gaussian noise injection is used to enhance anti-interference capabilities. The annotation process uses XML format to record defect locations and categories, and after format conversion, standardized labels are generated that are suitable for the object detection model. After grayscale image conversion, grayscale levels are compressed to reduce computational complexity. The grayscale co-occurrence frequency of pixel neighborhoods is calculated at multiple spatial scales to construct a three-dimensional texture matrix that includes energy, contrast, and homogeneity. The improved YOLOv11 model incorporates an attention module into the backbone network, enhancing the response of key regions through channel-wise and spatial weighting. The edge enhancement layer maintains contour integrity through skip connections, and a feature pyramid network achieves multi-scale feature fusion. During training, texture features are concatenated with original image features along the channel dimension, and the learning rate is dynamically adjusted to prevent overfitting. When the final model is deployed on an embedded device, computational latency is reduced through model pruning and operator optimization.

[0041] Compared to existing technologies, traditional methods rely on single image features, leading to missed detection of small objects. This solution leverages multi-scale texture features to enhance the model's sensitivity to subtle defects. Existing deep learning models do not effectively utilize texture information. This solution achieves multimodal information fusion through feature splicing. Compared to the unmodified YOLO model, this solution significantly improves detection accuracy in strong light reflection scenarios. Furthermore, model compression reduces computational complexity by approximately 40%, meeting the real-time requirements of embedded devices.

[0042] Through the above-mentioned technical solution, this application effectively solves the problem of missed detection of minor surface defects in welds, maintaining stable detection performance even on production lines subject to smoke interference. By integrating traditional texture features with deep learning features, the model's recognition accuracy for linear defects such as cracks increased by 25 percentage points. While maintaining detection accuracy, the improved network structure reduces the number of model parameters by 30%, enabling real-time detection at 30 frames per second on industrial embedded devices with limited computing power.

[0043] This application further proposes that in step S2, the annotation file format is XML, and a label file in YOLO format is generated through a conversion tool, and the label information includes normalized center coordinates, width, height and category number.

[0044] Among them, XML format refers to the Extensible Markup Language, which is used to store labeled data in a structured manner. Specifically, it can be generated by labeling tools such as Label Img, and has the characteristics of clear data hierarchy and strong readability. The label file in YOLO format refers to a text file that meets the input standard of the YOLO model. Specifically, the script tool can be used to convert XML into TXT format. Each file corresponds to the annotation information of a single image. The normalized center coordinates refer to the ratio of the center point of the target bounding box to the width and height of the image. Specifically, it can be obtained by dividing the pixel coordinates by the image size so that the coordinate values are in the range of 0-1. The normalized width and height refer to the ratio of the size of the target bounding box to the width and height of the image. Specifically, it is achieved by dividing the pixel width and height by the total width and height of the image, eliminating the impact of image resolution differences. The category number refers to the encoding of different defect types using integers, such as 0 for pores and 1 for cracks. It must be consistent with the category index of the model output layer.

[0045] Specifically, when annotating the enhanced image, the annotation file saves the location and category information of each defect in XML format. The XML file contains the image path, size, and bounding box coordinates and category names of multiple targets. The XML file is parsed by a conversion tool to read the original pixel coordinates and image size of each target. The horizontal and vertical coordinates of the center point are divided by the image width and height respectively to obtain the normalized center coordinates, and the bounding box width and height are divided by the corresponding image size to obtain the normalized size value. The category name is mapped to a preset integer number, and finally a TXT format label file that meets the YOLO model training requirements is generated. Each line of the file corresponds to one target, and the data is stored in the order of "category number center X coordinate center Y coordinate width height".

[0046] Compared to existing technologies, traditional methods use inconsistent annotation file formats, requiring manual scripting to adapt to different models and introducing the risk of conversion errors. Existing YOLO training processes often directly use non-normalized coordinates, resulting in unstable model performance on images of varying resolutions. This solution standardizes the conversion process to ensure that the annotation data strictly matches the model input format, avoiding training errors caused by non-normalized coordinates while also reducing the time and effort required to manually adjust annotation files.

[0047] Through the above technical solutions, this application achieves a seamless integration of the annotated data format with model requirements, eliminating model convergence difficulties caused by unnormalized coordinates and improving training efficiency. Automated conversion tools reduce manual intervention, lower the annotation error rate, and ensure data consistency. Normalization allows the model to adapt to input images of various resolutions, enhancing deployment flexibility.

[0048] The present application further proposes that the calculation of the grayscale co-occurrence matrix in step S3 includes the following steps: compressing the image grayscale to a preset range to reduce the computational complexity; statistically calculating the grayscale co-occurrence frequency based on the distance d and direction θ of the pixel neighborhood to generate a multi-scale GLCM; extracting the energy, contrast and homogeneity features of the GLCM to construct a multi-channel texture matrix.

[0049] Grayscale compression refers to quantizing the grayscale value range of the original image. This can be achieved using linear interpolation or nonlinear mapping methods. For example, compressing the grayscale range of 0-255 to 16 or 32 levels reduces the storage and computational requirements for subsequent calculations. Multi-scale GLCM generation involves constructing multiple co-occurrence matrices based on different pixel spacing and orientation parameters. This can be achieved using distances d of 1 or 2 pixels and orientations θ of 0°, 45°, 90°, and 135°, thereby capturing texture variations at different spatial scales. Multi-channel texture matrix construction involves stacking multiple GLCM statistics. This can be achieved by using pixel-by-pixel alignment to stitch energy, contrast, and homogeneity features as independent channels, thereby forming input data with multi-dimensional texture information.

[0050] Specifically, during the implementation process, the input image is first compressed in grayscale, for example, the original 256-level grayscale image is compressed to 16 levels, reducing the computational complexity by reducing the grayscale resolution. Subsequently, for each pixel, the grayscale co-occurrence frequency of its neighborhood at multiple distances and directions is calculated, for example, a GLCM with a distance of d = 1 and a direction of θ = 0° is generated, and the process is repeated to generate matrices of different scales. Next, the energy, contrast, and homogeneity features are calculated for each GLCM, where energy reflects texture uniformity, contrast characterizes local grayscale differences, and homogeneity describes distribution consistency. Finally, these features are integrated according to the channel dimension to form a multi-channel texture matrix, which serves as the input of the subsequent model.

[0051] Compared with existing technologies, existing methods typically use only single-scale GLCM feature extraction, such as the fixed parameter combination of d = 1 and θ = 0°, resulting in insufficient representation of multi-scale textures. However, this solution, through multi-scale GLCM generation and multi-channel feature fusion, can more comprehensively cover the texture characteristics of defects of different sizes. For example, it can extract effective texture difference information for both micron-scale pores and millimeter-scale cracks, while significantly reducing computational time through grayscale compression.

[0052] Through the above technical solution, this application solves the problem of missed detection of subtle defects caused by single-scale feature extraction in the traditional GLCM method, improves the robustness of texture features to complex background interference, and at the same time, through grayscale quantization and multi-channel fusion design, achieves a balance between computational efficiency and detection accuracy while ensuring feature representation capabilities.

[0053] This application further proposes to embed the CBAM attention mechanism in the backbone network of the improved YOLOv11 model, specifically including inserting CBAM modules after the 0th, 1st, 2nd, and 5th layers of the backbone network, which perform channel attention and spatial attention calculations in sequence and output weighted feature maps.

[0054] Among them, the CBAM module refers to a sequential attention mechanism that combines channel attention and spatial attention. Specifically, the channel attention submodule can calculate the weight of each channel, and then the spatial position weight can be calculated through the spatial attention submodule. Finally, the two weights are multiplied with the original feature map to achieve feature enhancement. This module can guide the model to focus on the key features of the defect area. Among them, channel attention calculation refers to generating channel description vectors through global average pooling and maximum pooling, and generating channel weights through a multi-layer perceptron. Specifically, two fully connected layers can be used to model the dependency relationship between channels. This process can suppress irrelevant channel interference and enhance the representation ability of defect features. Among them, spatial attention calculation refers to performing maximum pooling and average pooling on the channel attention output features along the channel dimension, and then generating a spatial weight map through the convolution layer after splicing. Specifically, a 7x7 convolution kernel can be used to implement spatial region importance assessment. This process can improve the model's spatial positioning accuracy for tiny defects.

[0055] Specifically, after the feature maps of the 0th, 1st, 2nd, and 5th layers of the backbone network are output, they are embedded in the CBAM modules in sequence. When the input feature map enters the module, the channel dimension weight is first calculated by the channel attention submodule, and the weight is multiplied by the input feature map channel by channel to obtain the channel enhanced feature. The feature is then input into the spatial attention submodule, the spatial dimension weight matrix is calculated, and it is multiplied pixel by pixel with the channel enhanced feature, and finally a feature map containing both channel and spatial dimension attention information is output. Through the attention embedding of the four key layers, the ability to extract edge texture features can be enhanced in the shallow network, and background noise interference can be suppressed in the deep network.

[0056] Compared to existing technologies, the backbone networks of traditional object detection models typically directly stack convolutional layers to extract features, lacking an active focus mechanism on key areas. Existing attention mechanism improvements often employ single-channel or spatial attention, failing to achieve joint optimization of both dimensions. This solution, through sequential channel-spatial attention calculations, establishes a feature screening mechanism at multiple network levels, effectively improving the model's feature discrimination capabilities in scenarios with complex reflections on weld surfaces and smoke interference.

[0057] Through the above technical solution, this application achieves precise positioning of subtle defects on weld surfaces. In particular, when dealing with halo interference caused by highly reflective surfaces, spatial attention can be used to suppress false responses in non-defective areas. Furthermore, the channel attention mechanism enhances the texture feature channels unique to defects such as cracks and pores, improving the model's detection stability in low-contrast images.

[0058] This application further proposes that the structure of the edge feature enhancement layer includes an edge detection convolution layer, a fully connected layer, a fusion convolution layer and an activation layer, and the original feature map is fused with the edge enhancement feature through jump connections to retain the integrity of spatial information.

[0059] Among them, the edge detection convolution layer refers to an operation layer that uses a preset convolution kernel to extract image edge features. Specifically, it can be implemented using the convolution kernel of the Sobel operator or the Canny operator, and is used to capture the gradient change information of the defect area. The fully connected layer refers to a linear transformation layer with a weight matrix. Specifically, a two-layer fully connected structure can be used to implement nonlinear mapping, which is used to adjust the dimension and abstractly express the edge features. The fusion convolution layer refers to a convolution operation layer that superimposes the original features and enhanced features on channels. Specifically, a 1x1 convolution kernel can be used to compress and integrate feature channels, which is used to eliminate feature redundancy and enhance effective information. The activation layer refers to an operation layer that introduces a nonlinear function. Specifically, it can be implemented using the ReLU or LeakyReLU activation function to improve the model's ability to express complex edge patterns. The skip connection refers to a cross-layer connection method that superimposes shallow network features with deep network features. Specifically, it can be implemented through residual connection or feature splicing to avoid spatial resolution loss and retain original geometric information.

[0060] Specifically, during model training, the input feature map first passes through an edge detection convolutional layer to extract the edge response map, and then passes through two fully connected layers for feature dimension expansion and nonlinear transformation. The processed edge features are then fused with the original input features in the channel dimension through a fusion convolutional layer. During this process, a cubic activation function is used to perform nonlinear processing on the intermediate features. The original feature map output by the backbone network is pixel-wise superimposed with the edge-enhanced feature map through skip connections. This fused feature map contains both edge details and global semantic information, effectively avoiding edge blurring caused by multiple convolution operations.

[0061] Compared with existing technologies, traditional methods typically use a single convolution kernel for edge feature extraction, resulting in loss of edge information for small defects. By integrating a multi-level fully connected structure with a skip connection mechanism, this proposed method enhances edge response while preserving the original feature resolution. This significantly improves the continuity of edge features when processing micron-scale pore defects.

[0062] Through the above technical solution, this application solves the problem of insufficient edge feature extraction in traditional models under complex lighting or noise interference, effectively improving the detection accuracy of linear defects such as cracks and slag inclusions on weld surfaces. This structure enhances the model's sensitivity to subtle edge changes through a multi-level feature fusion mechanism, while ensuring the spatial integrity of the feature map, enabling the detection model to accurately identify surface defects of various sizes and shapes when running on embedded devices.

[0063] This application further proposes a multi-scale feature fusion module comprising the following steps: three scale feature maps output by the backbone network; a feature pyramid network performs cross-scale fusion on the feature maps to generate fused multi-scale defect features.

[0064] Among them, multi-scale feature maps refer to feature maps with different resolutions output from different layers of the backbone network. Specifically, this can be achieved by using feature maps from shallow, middle, and deep layers in a convolutional neural network. Shallow feature maps retain more detailed information, while deep feature maps contain high-level semantic information. Among them, the feature pyramid network refers to an architecture that achieves cross-scale feature fusion through top-down paths and lateral connections. Specifically, this can be achieved by using upsampling operations to increase the size of deep feature maps and performing element-by-element addition or splicing operations with shallow feature maps of the corresponding layer, thereby enhancing the ability to express semantic information while preserving spatial details.

[0065] Specifically, when the backbone network processes the input image, different convolutional layers will output feature maps of different scales. For example, the shallow feature map has a higher resolution and can capture the local texture of small defects; the middle feature map has a moderate resolution, taking into account both details and semantics; the deep feature map has a lower resolution but contains more abstract global features. The feature pyramid network expands the size of the deep feature map to the same size as the middle feature map through upsampling. Figure 1 The two are then fused through lateral connections, and the fused feature map is then upsampled and fused with the shallow feature map. This process ensures that the feature maps at each level contain multi-scale information, allowing defects of different sizes to be identified simultaneously in subsequent inspections.

[0066] Compared with existing technologies, traditional methods typically only use feature maps of a single scale for detection, or simply fuse feature maps of different scales. This results in the loss of small object features in deep networks and the lack of semantic information in large object features in shallow networks. This solution effectively integrates feature maps from different levels through the cross-scale fusion mechanism of the Feature Pyramid Network, ensuring that the fused features retain the detailed information of small objects while also providing semantic representation of large objects.

[0067] Through the above technical solution, this application can improve the model's detection accuracy for defects of different sizes, especially in complex industrial scenarios, the characteristic information of defects such as tiny pores or cracks can be retained, while reducing the interference of background noise on the detection results, thereby improving the robustness of defect recognition.

[0068] This application further proposes the following optimization strategy for model training: GLCM texture features and original image features are input into the model through channel splicing; dynamic learning rate adjustment and early stopping mechanism are used to prevent overfitting.

[0069] Among them, channel splicing refers to the operation of merging feature matrices from different sources in the channel dimension. Specifically, it can be achieved by channel-by-channel superposition of the multi-channel texture matrix extracted from the gray-level co-occurrence matrix and the feature map of the original RGB image. In this way, the original color information and texture statistical features of the image can be utilized simultaneously to enhance the model's ability to characterize subtle defects. Dynamic learning rate adjustment refers to an optimization strategy that automatically adjusts the learning rate according to the training stage. Specifically, it can be implemented using the cosine annealing algorithm. This algorithm uses a higher learning rate to accelerate convergence in the early stage of training, and gradually reduces the learning rate in the later stage to approach the optimal solution, thereby balancing the convergence speed and model stability. The early stopping mechanism refers to the operation of terminating training early when the validation set loss has not decreased for multiple consecutive times. Specifically, it can be achieved by setting a validation set monitoring window. When the validation loss does not improve within the set period, the current optimal model is saved and training is stopped to avoid overfitting of the model on the training set.

[0070] Specifically, during model training, the three-channel texture feature matrix extracted from the gray-level co-occurrence matrix is first concatenated with the original input image in the channel dimension to form six-channel input data containing texture information. This data is fed into the improved YOLOv11 network for forward propagation, and the network parameters are updated through backpropagation. During training, the learning rate is periodically adjusted according to the cosine function curve. The initial learning rate can be set to a high value, and it decays according to the cosine law after each training cycle. Simultaneously, during the validation phase, the model's loss on the validation set is continuously monitored. If the validation loss does not decrease within five consecutive training cycles, the early stopping mechanism is triggered to forcibly terminate the training process.

[0071] Compared to existing technologies, traditional methods typically use only a single image feature input without integrating texture statistics, resulting in insufficient sensitivity to subtle surface defects. Existing deep learning model training often uses fixed learning rates or simple piecewise adjustment strategies, making it difficult to balance convergence speed with the risk of overfitting. This solution, by combining multimodal feature fusion with a dynamic optimization strategy, effectively mitigates overfitting while maintaining training efficiency.

[0072] Through the above technical solution, this application can improve the model's detection accuracy for defects such as tiny pores and cracks on the surface of welded parts, avoid model overfitting problems caused by insufficient training data or noise interference, and enhance the generalization performance of the detection system in complex industrial environments.

[0073] This application further proposes that the functional modules of the detection system include real-time detection screen display, model initialization interface, camera control unit, confidence threshold adjustment and operation log output.

[0074] Real-time inspection display refers to visualizing the model inference results by overlaying them on the video stream interface. This can be achieved using the OpenCV library's video frame overlay technology. By establishing a video stream thread on the embedded device screen, the defect location coordinates are mapped to the image coordinate system, and then bounding boxes and category labels are drawn. The model initialization interface is a standardized interface for loading pre-trained weights and configuration parameters. This can be implemented using the TensorRT engine's model parsing module, which automatically matches the input and output tensor dimensions by reading the model configuration file. The camera control unit is a hardware control module that adjusts the exposure parameters and acquisition frequency of the industrial camera. This can be implemented using an SDK development kit that communicates with the USB 3.0 protocol. Dynamic control is achieved by encapsulating parameter adjustment functions such as exposure time and gain. Confidence threshold adjustment refers to setting a confidence filtering mechanism for defect detection results. This can be achieved using a slider control and callback function binding technology. The confidence filtering threshold of the model output can be adjusted in real time through the establishment of a user interface. Operation log output is a persistent storage module that records system operation status and inspection results. This can be implemented using a lightweight SQLite database. Operational data such as device temperature, inference time, and defect statistics are recorded using timestamps.

[0075] Specifically, the embedded device's video stream data is collected in real time by an industrial camera module, and the optimized detection model is loaded via the model initialization interface. The camera control unit dynamically adjusts exposure parameters to adapt to ambient lighting changes. The processed image is then input into the model to obtain defect detection results. The real-time detection image display module maps bounding box coordinates to the video frame and overlays them for display. The confidence threshold adjustment module filters low-confidence detection results through an interactive interface. The operation log output module simultaneously records the device's operating status and detection data, generating traceable quality inspection reports.

[0076] Compared with existing technologies, traditional testing systems often lack modular functional design, resulting in poor interface interactivity, reliance on code modifications for parameter adjustments, and a lack of systematic recording of operational data. This solution, by building standardized functional modules, enables dynamic adjustment of testing parameters and visual monitoring of operational status, effectively improving system operation convenience and data management efficiency.

[0077] Through the above technical solution, this application achieves stable operation and efficient human-computer interaction of the detection system on embedded devices, solving the deployment difficulties caused by the low functional integration of traditional solutions. The modular design reduces the complexity of system maintenance, and the continuous recording of operation logs provides data support for equipment status monitoring and process optimization.

[0078] This application further proposes a weld surface defect detection system based on gray-level co-occurrence matrix and YOLOv11, including an industrial camera module for acquiring weld surface images; a deployment platform that supports the detection model to run in real time on embedded devices and output defect detection results.

[0079] The industrial camera module refers to an imaging device capable of capturing high-resolution images, specifically a global shutter CMOS camera. By adjusting exposure time and gain parameters to adapt to varying lighting conditions, this module addresses the issue of unstable image acquisition quality in complex industrial environments. The deployment platform refers to an embedded hardware system with computing power, specifically a Jetson Nano development board equipped with an NPU. This platform achieves efficient inference of detection models through model quantization and operator optimization, addressing the difficulty of deploying traditional deep learning models on production line equipment.

[0080] Specifically, an industrial camera module is installed above the conveyor belt of the welding production line, capturing images of the welded surface through triggered shooting. The captured raw images are preprocessed and fed into the detection model on the deployment platform. The model combines multi-scale texture features extracted using a gray-level co-occurrence matrix with depth features from an improved YOLOv11 algorithm for joint inference. Ultimately, the model outputs the detection results, including defect location, category, and confidence level, in real time via a display interface. During system operation, the embedded device's computing resource utilization is kept within a preset threshold, ensuring an inspection frame rate of at least 30 frames per second, the production line's requirement.

[0081] In some implementations, industrial camera modules can be equipped with a ring-shaped LED fill light with a color temperature adjustable from 4000K to 6500K to eliminate image overexposure caused by reflections from metal surfaces. The deployment platform can use the TensorRT framework for model conversion, converting floating-point weights to 8-bit integer data. This reduces the model size to 40% of its original size and increases inference speed by approximately 3 times.

[0082] Compared with existing technologies, traditional inspection systems typically use general-purpose cameras deployed with industrial computers, resulting in large equipment size, high power consumption, and delayed response times. This solution, however, uses dedicated industrial camera modules to ensure image acquisition quality and integrates an embedded deployment platform to achieve lightweight model operation. This reduces power consumption to below 15W while maintaining inspection accuracy, meeting the demands of long-term continuous operation in industrial sites.

[0083] Through the above technical solution, this application effectively addresses the inefficiency of traditional manual inspection and the difficulty of deploying existing deep learning models on embedded devices, achieving real-time automated detection of surface defects in welds. The system can consistently output inspection results even in complex environments such as strong light reflection and smoke interference, significantly improving the detection rate of minor defects such as pores and cracks. It also avoids the difficulties of retrofitting production lines due to the large size of traditional equipment.

[0084] The present application further proposes that the weld surface defect detection system also includes a computer-readable storage medium, which stores a computer program. When the program is executed by the processor, the weld surface defect detection method is implemented.

[0085] Computer-readable storage media refers to physical media capable of persistently storing data and information. Specifically, this can be achieved using solid-state drives, mechanical hard drives, or flash memory chips. These media are used to store trained detection model parameters and program code, ensuring the detection system can resume operation after a power outage. Processor execution of computer programs refers to the loading and parsing of instruction sets from storage media via the computing unit of an embedded device. Specifically, this can be achieved using chips based on the ARM or RISC-V architectures, converting weld surface defect detection methods into executable hardware operational procedures.

[0086] Specifically, the computer program stored in the storage medium includes an optimized model weight file, image preprocessing code, and a detection result output module. When the detection system starts, the processor reads program instructions from the storage medium, loads the trained improved YOLOv11 model into memory, and simultaneously calls the real-time image data collected by the industrial camera module for feature extraction and defect identification. During program execution, the gray-level co-occurrence matrix feature extraction module and the improved YOLOv11 model form a collaborative computing process, achieving efficient processing of detection tasks through a multi-threaded scheduling mechanism. The storage medium adopts a file system partition management strategy to independently store model files, log data, and configuration files to prevent data read and write conflicts.

[0087] Compared with existing technologies, traditional detection systems often use unoptimized general storage solutions, resulting in excessively long model loading times and an inability to adapt to the storage space limitations of embedded devices. This application compresses model parameters to 30%-50% of their original size through customized storage formats and a hierarchical storage architecture, while also using an on-demand loading mechanism to reduce memory usage. The program execution process in existing technologies generally lacks instruction set optimization for industrial detection scenarios. This application reduces the single-frame detection time to less than 50 milliseconds through hardware instruction acceleration and computational graph optimization.

[0088] Through the above technical solution, this application enables rapid deployment and stable operation of detection models in embedded devices, resolving the detection delay problem caused by insufficient storage media read and write efficiency in traditional solutions. Computing resources are dynamically allocated during program execution to ensure a stable frame processing rate even under high-frequency detection tasks. The storage media partition management mechanism prevents data corruption and ensures the long-term reliable operation of the detection system in complex industrial environments.

[0089] Reference Figure 3 YOLOv11, the latest version of the YOLO series, inherits the YOLO series' single-shot detection framework and significantly improves detection accuracy and inference speed through improvements. The YOLOv11 architecture consists of three main components: the backbone network, the neck network, and the detection head. The backbone network extracts features from the input image, the neck network fuses features from different levels to enhance multi-scale object detection, and the detection head is responsible for final object localization and category prediction.

[0090] In the backbone network, YOLOv11 introduces the C3K2 module to replace the traditional C2f module, significantly improving feature extraction efficiency. By optimizing the connections between convolutional layers, the C3K2 module makes feature extraction more efficient while maintaining the ability to capture complex features. Furthermore, YOLOv11 introduces the C2PSA module, which combines spatial pyramid pooling (SPP) and a channel attention mechanism to further enhance feature diversity and adaptability. Spatial pyramid pooling (SPP) captures features at different scales, while the channel attention mechanism emphasizes important features and suppresses unimportant ones, thereby improving the model's ability to detect multi-scale objects.

[0091] The neck network utilizes the PAN-FPN structure, or Path Aggregation Network-Feature Pyramid Network, a highly efficient feature fusion architecture. PAN-FPN combines high-level semantic information with low-level detail information through upsampling and downsampling operations, thereby enhancing the model's ability to detect objects of varying scales. This bidirectional feature fusion mechanism not only improves target localization accuracy but also enhances the model's adaptability to multi-scale objects through the design of a feature pyramid. The PAN-FPN design enables YOLOv11 to retain more detailed information when processing small objects while fully utilizing high-level semantic information when processing large objects.

[0092] The detection head is one of the key innovations of YOLOv11. Its decoupled design and depthwise separable convolution (DWConv) operations significantly reduce model parameters and computational overhead. The decoupled detection head separates object location prediction from category prediction. This separation allows the model to focus more on each task, thereby improving detection accuracy. Depthwise separable convolutions improve inference speed by reducing the computational overhead of convolution operations. This design significantly reduces the computational complexity of the model while maintaining high accuracy, making YOLOv11 more suitable for deployment in resource-constrained environments. It directly predicts the object's location (bounding box) and category through a single forward pass, eliminating the need to generate candidate boxes like traditional methods such as the R-CNN series. This design significantly simplifies the detection process and improves detection speed, making it suitable for real-time applications. Furthermore, YOLOv11 uses improved loss functions such as the CIoU Loss. CIoU Loss takes into account the center distance, aspect ratio, and intersection-over-union (IoU) of the bounding box, resulting in superior performance in optimizing object box localization accuracy. This loss function design enables the model to more accurately predict the location of the target bounding box, especially when dealing with small objects and complex backgrounds. YOLOv11's multi-scale detection capability is another notable feature. It handles objects of different sizes through multi-scale detection layers. Each detection layer is responsible for detecting objects of a specific scale. This layered detection mechanism enables the model to more effectively capture objects of different sizes. Through feature fusion, features of different scales are integrated, further enhancing the model's ability to detect objects of multiple scales. This design not only improves the detection capability of small objects, but also reduces redundant computation in the large object detection layer, significantly improving inference speed while maintaining high accuracy.

[0093] YOLOv11 is particularly well-suited for scenarios requiring high inference speed and accuracy. In real-time surveillance, it can process video streams in real time and quickly identify abnormal behavior or objects. Furthermore, a lightweight version of YOLOv11 is particularly suitable for deployment on resource-constrained embedded devices. YOLOv11's model size and inference speed have been further optimized through techniques such as model pruning. Model pruning reduces the model's computational load by removing redundant connections and parameters, while recovering any performance losses through fine-tuning training. This optimization enables YOLOv11 to run efficiently on embedded devices while maintaining high detection accuracy.

[0094] In research on weld defect detection, images in a weld dataset are first preprocessed using a gray-level co-occurrence matrix (GLCM) to extract texture features. As a classic texture analysis method, the gray-level co-occurrence matrix (GLCM) reflects image texture information by calculating the spatial correlation of pixel grayscale values. Key features extracted from the GLCM include energy, which reflects the uniformity of image texture; contrast, which reflects texture clarity and intensity of variation; and homogeneity, which reflects texture uniformity and consistency. These features effectively capture subtle texture details in weld images, providing fundamental data support for subsequent defect detection.

[0095] After extracting the GLCM features, these features are further processed to generate a multiscale texture matrix of 52×52×5. This matrix not only contains texture information at different scales but also enhances the ability to capture subtle texture variations through multiscale analysis. This design enables the model to better adapt to the manifestations of welding defects at different scales, thereby improving detection accuracy.

[0096] To enhance the model's sensitivity to subtle defects, the generated multi-scale texture matrix is concatenated with a deep feature map through a feature merging module. Deep feature maps are high-level semantic features extracted by deep learning models, such as YOLOv11, and are capable of capturing complex patterns and structural information in images. By concatenating the texture matrix with the deep feature map, not only does this preserve the image's texture details, but it also leverages the powerful feature extraction capabilities of deep learning models, enabling the model to more comprehensively understand image content and significantly improving its ability to detect subtle defects.

[0097] During the model training phase, the preprocessed and feature-fused welded component dataset images were fed into the YOLOv11 model for training. As an advanced object detection algorithm, YOLOv11's efficient feature extraction and fast inference speed make it well-suited for welding defect detection. By introducing GLCM features and a multi-scale texture matrix into the YOLOv11 model, the model's detection performance was further optimized, enabling it to more accurately identify subtle defects in welds.

[0098] To improve model training efficiency and detection accuracy, the loss function was optimized and the model was lightweighted. This lightweight optimization reduces the model's parameters and computational complexity, enabling it to run more efficiently while maintaining high detection accuracy. Furthermore, the model was adapted to support ONNX format conversion and TensorRT quantization. ONNX format conversion facilitates model migration and deployment across different platforms, while TensorRT quantization further optimizes the model's inference speed and computational efficiency.

[0099] Ultimately, the optimized and adapted model was deployed on embedded devices such as JETSON for actual inspection tasks. On these resource-constrained embedded platforms, the model achieved an inference speed of 35 FPS, which not only met the requirements for real-time inspection but also provided reliable technical support for the practical application of welding defect detection. Through this series of improvements and optimizations, the model demonstrated excellent performance in welding defect detection tasks, enabling rapid and accurate detection of subtle defects in welds, providing a strong guarantee for improving welding quality.

[0100] Reference Figure 2 In order to facilitate user operation and improve system usability, the present invention also designs an intuitive and easy-to-use welding defect detection system UI interface. The interface includes the following functional modules:

[0101] Inspection Screen Display Module: Displays real-time weld defect inspection images and analysis results. Inspection results include defect type, location, and confidence level information, helping operators quickly understand the quality status of welds.

[0102] Model initialization and management module: Users can choose to load different versions of pre-trained weights and initialize the model. Through this module, users can easily update the model to ensure the system's detection capabilities in different environments.

[0103] Confidence Control Module: This module allows users to set a confidence threshold for detection based on their needs, thereby controlling the sensitivity of the system. In a production environment, users can adjust this threshold to balance detection accuracy with missed detections and false detections.

[0104] Real-time operation log module: This module displays the system operation status, detection progress, and model inference time in real time. This module provides system maintenance personnel with important performance monitoring data, helping to optimize system performance and promptly identify potential problems.

[0105] Defect Report Generation Module: Based on the inspection results, the system automatically generates a detailed defect report for quality control personnel to reference. The report includes information such as defect type, location, severity, and inspection images, facilitating subsequent analysis and decision-making.

[0106] Through this UI design, users can intuitively see the results of each inspection, simplifying operational processes, improving production efficiency, and enabling timely adjustments to optimize welding quality monitoring. The simplicity and ease of use of the UI design ensure that users of all levels can effectively use the system, improving the speed and accuracy of overall inspection tasks.

[0107] Implementation steps:

[0108] Collection and preprocessing:

[0109] We used an industrial camera to capture weld surface images, randomly rotated (±30°) to simulate multi-angle photography of the weld. We annotated 10 defect types, such as cracks and pores, along with their locations. We added Gaussian noise (σ = 0.01) to simulate uneven industrial lighting. The images were converted to grayscale and resized to 640x640 pixels. Random cropping and rotation were used to enhance data diversity.

[0110] Create a gray-level co-occurrence matrix GLCM, calculate the GLCM texture features of the grayscale image, calculate the GLCM in the four directions of 0°, 45°, 90°, and 135°, with a step size of d=1 and a window size of 5×5, and generate 52x52x5, 26x26x5, and 13x13x5 multi-scale matrices.

[0111] Model training and optimization:

[0112] Initialize the YOLOv11 n model and load pretrained weights. Train using the Focal-DIoU loss function, the CosineAnnealing learning rate scheduler, and the Adam optimizer. Optimize the model through multiple rounds of training to ensure high detection accuracy in complex environments.

[0113] Deployment and testing:

[0114] Design a weld surface defect detection system on the PC, connect to a real-time camera, deploy a trained weld surface defect detection model, and inspect the welds; if defects exist, the status bar outputs the defect detection category.

[0115] Anything not described in the present invention can be achieved by adopting or drawing on existing technologies.

[0116] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments.

[0117] The foregoing is merely an embodiment of the present invention and is not intended to limit the present invention. It will be apparent to those skilled in the art that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention are intended to be included within the scope of the claims of the present invention.

Claims

1. A method for detecting surface defects of welded parts based on gray-level co-occurrence matrix and YOLOv11, characterized in that: The specific steps are as follows: S1. An industrial camera collects images of weld surface under different defect types and lighting conditions and performs data enhancement processing, including horizontal flipping, color conversion, scaling, and noise injection. S2. Annotate the bounding box positions and category labels of defects in the enhanced image, and divide the dataset into training set, validation set, and test set in proportion; S3, converting the image into a grayscale image, and extracting multi-scale texture features based on the gray-level co-occurrence matrix GLCM, wherein the texture features include energy, contrast, and homogeneity; S4. Build an improved YOLOv11 model, which includes a backbone network embedded with a CBAM attention mechanism, an edge feature enhancement layer, and a multi-scale feature fusion module; S5. Inputting the texture features extracted by GLCM into the improved YOLOv11 model for training to generate a weld surface defect detection model; S6. Deploy the detection model to the embedded device and output the defect type, location and confidence in real time.

2. The method for detecting surface defects of welded parts based on gray-level co-occurrence matrix and YOLOv11 according to claim 1, characterized in that: In step S2, the annotation file format is XML, and a label file in YOLO format is generated through a conversion tool. The label information includes normalized center coordinates, width, height and category number.

3. The method for detecting surface defects of welded parts based on gray-level co-occurrence matrix and YOLOv11 according to claim 1, characterized in that: The calculation of the gray level co-occurrence matrix in step S3 includes the following steps: S31, compressing the image grayscale to a preset range to reduce computational complexity; S32, statistically calculate the grayscale co-occurrence frequency based on the distance d and direction θ of the pixel neighborhood to generate a multi-scale GLCM; S33, extracting the energy, contrast and homogeneity features of the GLCM and constructing a multi-channel texture matrix.

4. The method for detecting surface defects of welded parts based on gray-level co-occurrence matrix and YOLOv11 according to claim 1, characterized in that: The improved YOLOv11 model embeds the CBAM attention mechanism in the backbone network, specifically including: Step 1: Insert CBAM modules after layers 0, 1, 2, and 5 of the backbone network respectively; Step 2: The CBAM module performs channel attention and spatial attention calculations in sequence, and outputs a weighted feature map.

5. The method for detecting surface defects of welded parts based on gray-level co-occurrence matrix and YOLOv11 according to claim 3, characterized in that: The structure of the edge feature enhancement layer includes: 1 edge detection convolution layer, 2 fully connected layers, 1 fusion convolution layer and 3 activation layers; The original feature map is fused with the edge enhancement feature through skip connections to preserve the integrity of spatial information.

6. The method for detecting surface defects of welded parts based on gray-level co-occurrence matrix and YOLOv11 according to claim 1, characterized in that: The multi-scale feature fusion module in step S4 includes: S41, three scale feature maps output by the backbone network; S42. A feature pyramid network (FPN) performs cross-scale fusion on the feature maps to generate fused multi-scale defect features.

7. The method for detecting surface defects of welded parts based on gray-level co-occurrence matrix and YOLOv11 according to claim 2, characterized in that: The model training in step S5 adopts the following optimization strategy: S51, splicing the GLCM texture features and the original image features into the model through channels; S52. Use dynamic learning rate adjustment and early stopping mechanism to prevent overfitting.

8. The method for detecting surface defects of welded parts based on gray-level co-occurrence matrix and YOLOv11 according to claim 1, characterized in that: The functional modules of the detection system in step S6 include: S61, real-time detection screen display, model initialization interface, camera control unit, confidence threshold adjustment and operation log output.

9. A weld surface defect detection system based on gray level co-occurrence matrix and YOLOv11, adopting the detection method according to any one of claims 1 to 8, characterized in that: Includes an industrial camera module for capturing images of the weld surface; A deployment platform supports the real-time execution of the detection model on embedded devices and outputs defect detection results.

10. The weld surface defect detection system according to claim 9, characterized in that: It also includes a computer-readable storage medium, characterized in that the storage medium stores a computer program, and when the program is executed by a processor, the weld surface defect detection method according to any one of claims 1 to 8 is implemented.

Citation Information

Cited By

  • Surface defect detection method and surface defect detection device

    CN120655644A

  • Bridge engineering underwater foundation quality detection method and system based on machine vision

    CN121527096A

  • Wear type quantitative identification method based on image segmentation

    CN121904382A