Steel pipe weld defect detection trolley and detection method based on improved YOLOv11n

CN123016150APending Publication Date: 2026-10-30INNER MONGOLIA UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611043455.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-14
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0005]因此,本发明提供了基于改进YOLOv11n的钢管焊缝缺陷检测小车及检测方法,解决现有技术钢管焊缝缺陷检测存在的小目标缺陷检测精度低、多尺度特征融合效果差、边界模糊图像细节保留能力弱、类内一致性识别不足的问题

Benefits of technology

[0016]本发明有益效果为:本发明通过C3k2-coor模块的改进,将坐标注意力机制与多分支异构卷积结构结合,既实现了缺陷特征位置信息的精准保留,又通过多尺度卷积核实现了跨尺度特征的互补增强,显著提升了模型对焊缝细微缺陷、小目标缺陷的特征提取能力,解决了现有技术中小目标缺陷召回率低的问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123016150A_ABST
    Figure CN123016150A_ABST
Patent Text Reader

Abstract

The application discloses a steel pipe weld defect detection trolley and a detection method based on improved YOLOv11n, relates to the field of nondestructive testing of special equipment, and comprises the following steps: collecting steel pipe weld image data, constructing a steel pipe weld defect data set, preprocessing and data enhancement are performed on the data set, and the data set is divided into a training set, a verification set and a test set; a YOLOv11n-CFA weld defect detection model is constructed, including improving a C3k2 module in a backbone network into a C3k2-coor module, improving a spatial pyramid pooling module SPPF into a SPPF-freq module, and replacing an original feature pyramid network with an adaptive feature pyramid network AFPN; the training set is input into the YOLOv11n-CFA model for iterative training, the model performance is verified in real time through the verification set, the optimal weight is selected based on preset evaluation indexes, and a trained steel pipe weld defect detection model is obtained; a steel pipe weld image to be detected is input into the trained weld detection model, and the model outputs the class, the boundary box coordinates, the confidence and the defect position information of the weld defect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of nondestructive testing technology for special equipment, and in particular to a steel pipe weld defect detection trolley and detection method based on the improved YOLOv11n. Background Technology

[0002] Steel pipe structures, with their superior structural performance, are widely used in petrochemical, natural gas transportation, and bridge construction. Welding is the core process for solving the challenges of long-distance construction and adapting to complex working conditions of steel pipes. The quality of the weld directly determines the strength, sealing performance, and service life of the steel pipe structure. Defects such as cracks, porosity, spatter, and incomplete penetration are prone to occur during the welding process. These defects can seriously affect the safety and reliability of the steel pipe structure, and even lead to major safety accidents such as pipeline leaks and structural fractures. Therefore, efficient and accurate inspection of steel pipe weld quality is a core requirement in industrial production and operation and maintenance.

[0003] Currently, the mainstream methods for inspecting steel pipe welds include traditional non-destructive testing methods such as ultrasonic testing, magnetic particle testing, radiographic testing, and penetrant testing. While these methods can detect defects, they suffer from low efficiency, reliance on the professional experience of inspectors, inability to achieve real-time online inspection, and insufficient ability to identify subtle defects. In recent years, with the development of deep learning and computer vision technologies, YOLO-based target detection algorithms have become the mainstream technology for weld defect detection due to their balance between detection speed and accuracy. Existing YOLO-based weld defect detection technologies still have several shortcomings: First, they suffer from poor recall and precision for small defects such as micro-cracks, small pores, and spatter, as these features are easily drowned out by background noise, resulting in insufficient feature extraction capabilities. Second, multi-scale feature fusion is ineffective; weld defects exhibit significant differences in size and shape, making it difficult for existing algorithms to simultaneously address defects of different scales, leading to missed detections of large defects and false detections of small ones. Third, they have weak information processing capabilities for blurred boundary images; traditional upsampling techniques easily result in the loss of high-frequency detail information in boundary regions, leading to low defect edge recognition accuracy. Fourth, they lack consistency recognition within defect classes; the large variations in feature values ​​within weld defects can easily lead to misclassification of different parts of the same defect. Therefore, there is an urgent need for a YOLO detection algorithm optimized for the characteristics of steel pipe weld defects, which can significantly improve the detection accuracy and robustness of weld defects, especially small defects, while maintaining model lightweightness and real-time performance. Summary of the Invention

[0004] In view of the aforementioned existing problems, the present invention is proposed.

[0005] Therefore, this invention provides a steel pipe weld defect detection vehicle and detection method based on the improved YOLOv11n, which solves the problems of low detection accuracy of small target defects, poor multi-scale feature fusion effect, weak ability to preserve details of blurred image by boundary, and insufficient intra-class consistency recognition in the existing steel pipe weld defect detection technology.

[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution: In a first aspect, the present invention provides a method for detecting defects in steel pipe welds based on an improved YOLOv11n, comprising, Collect steel pipe weld image data, construct a steel pipe weld defect dataset, preprocess and augment the dataset and divide it into training set, validation set and test set; A YOLOv11n-CFA weld defect detection model was constructed, including improving the C3k2 module in the backbone network to the C3k2-coor module, improving the Spatial Pyramid Pooling Module (SPPF) to the SPPF-freq module, and replacing the original Feature Pyramid Network with the Progressive Feature Pyramid Network (AFPN). The training set is input into the YOLOv11n-CFA model for iterative training. The model performance is verified in real time through the validation set. The optimal weights are selected based on the preset evaluation index to obtain the trained steel pipe weld defect detection model. The image of the weld seam of the steel pipe to be inspected is input into the trained weld seam inspection model. The model outputs the category of weld defect, bounding box coordinates, confidence level and defect location information.

[0007] As a preferred embodiment of the improved YOLOv11n-based steel pipe weld defect detection method of the present invention, the following steps are described: acquiring steel pipe weld image data, constructing a steel pipe weld defect dataset, preprocessing and data augmentation of the dataset, and dividing it into training, validation, and test sets refer to using a fixed industrial area array camera to acquire surface images of the steel pipe weld, and using a low-angle ring light source to illuminate the weld area to obtain the original grayscale image of the steel pipe weld. ; Based on the original grayscale images of steel pipe welds, a set is formed, and weld defect categories are defined, including cracks, spatter, porosity, and incomplete penetration. Each weld in the image is labeled with a rectangular bounding box, adjusted to a uniform pixel size, and then normalized. The normalized grayscale images of steel pipe welds are then input into the YOLOv11n backbone network, which outputs four scale features. , , as well as ; Rectangular box annotations include rectangular box annotations for the weld reference area and the weld defect area; Generate a weld space reliability map based on the weld reference region. ; Data augmentation was performed on the normalized grayscale images of steel pipe welds, and the data was divided into training, validation, and test sets.

[0008] As a preferred embodiment of the steel pipe weld defect detection method based on the improved YOLOv11n described in this invention, the improvement of the C3k2 module in the backbone network to a C3k2-coor module includes using the scale features output by the backbone network as the input feature map. Input the four convolutional branches separately, and then concatenate and compress the outputs of the four convolutional branches. A coordinate attention mechanism is employed, using pooling kernels of sizes (H,1) and (1,W) to encode the horizontal and vertical spatial directions respectively. The horizontal and vertical spatial direction encodings are concatenated and input into a 1x1 convolutional function to obtain an intermediate feature map F. This intermediate feature map F is then split along the spatial direction into... and Attention weights are generated for the height and width directions, respectively. The enhanced feature map is then output by weighting based on attention weights.

[0009] As a preferred embodiment of the steel pipe weld defect detection method based on the improved YOLOv11n described in this invention, the improvement of the Spatial Pyramid Pooling Module (SPPF) to an SPPF-freq module includes using the enhanced feature map as the input feature of the SPPF-freq module, performing a one-dimensional transformation, and adjusting the channels to the initial fused features. Low-frequency features are generated using a low-pass filter kernel based on the initial fusion features; High-frequency features are generated by inverting the low-pass filter kernel to obtain the high-pass filter kernel; Define a neighborhood direction D, calculate the similarity between position p and its neighboring positions, generate a resampling offset and resampling features based on the similarity. The frequency domain enhancement features are obtained by fusing low-frequency features, high-frequency features, and resampling features. Preserve SPPF pooling branch output; After concatenating the frequency domain enhancement features with the output of the SPPF pooling branch, the channel dimensions are adjusted to output the final feature map.

[0010] As a preferred embodiment of the steel pipe weld defect detection method based on the improved YOLOv11n described in this invention, the method of replacing the original feature pyramid network with the progressive feature pyramid network AFPN includes defining four-scale features entering the AFPN, unifying the four-scale feature channels to the number of fusion channels, spatially aligning features of different scales, generating spatial adaptive weights using ASFF, and progressively fusing according to the spatial adaptive weights to obtain four-scale detection features.

[0011] As a preferred embodiment of the steel pipe weld defect detection method based on the improved YOLOv11n described in this invention, the construction of the YOLOv11n-CFA weld defect detection model further includes constructing a four-scale detection head using an anchor-free detection head, and outputting bounding box regression parameters, class probability, and target confidence for each scale detection feature.

[0012] As a preferred embodiment of the steel pipe weld defect detection method based on the improved YOLOv11n described in this invention, the hyperparameters for training the YOLOv11n-CFA model are set as follows: input image size 640×640, batch_size 16, training iterations Epochs 200, SGD optimizer, weight decay coefficient 0.0005, initial learning rate 0.01, momentum 0.937, and model evaluation metrics including precision, recall, mean accuracy mAP@0.5, mean accuracy mAP@0.5-0.95, and F1-Score. The model weights with the highest mAP@0.5 on the validation set are selected as the optimal weights. During training, a cosine annealing strategy is used to update the learning rate.

[0013] As a preferred embodiment of the steel pipe weld defect detection method based on the improved YOLOv11n described in this invention, the YOLOv11n-CFA model constructs a total loss function during training using bounding box loss, class loss, and target confidence loss.

[0014] As a preferred embodiment of the steel pipe weld defect detection method based on the improved YOLOv11n described in this invention, the method involves: inputting the image of the steel pipe weld to be detected into the trained weld detection model, outputting bounding box regression parameters, category probabilities, and target confidence; the model determines the category of weld defect based on the category probabilities; and parsing the bounding box regression parameters to obtain the bounding box coordinates and defect location information.

[0015] In a second aspect, the present invention provides a steel pipe weld defect detection trolley based on the improved YOLOv11n, wherein the detection trolley performs any step of the steel pipe weld defect detection method based on the improved YOLOv11n as described in the first aspect of the present invention.

[0016] The beneficial effects of this invention are as follows: By improving the C3k2-coor module, this invention combines the coordinate attention mechanism with the multi-branch heterogeneous convolution structure, which not only achieves accurate preservation of defect feature location information, but also achieves complementary enhancement of cross-scale features through multi-scale convolution kernels, significantly improving the model's feature extraction capability for weld seam minor defects and small target defects, and solving the problem of low recall rate of small target defects in the prior art.

[0017] This invention improves the SPPF-freq module by decomposing image features into high- and low-frequency information based on frequency domain analysis for separate processing. It enhances intra-class consistency of defects through an adaptive low-pass filter and strengthens boundary details through an offset generator and an adaptive high-pass filter, effectively solving the problem of lost image details due to blurred boundaries and improving the model's recognition accuracy for irregular and blurred-edge weld defects. Furthermore, this invention reconstructs the feature fusion architecture using the AFPN progressive feature pyramid network and combines it with an adaptive spatial fusion mechanism to achieve progressive fusion of low-level details and high-level semantics. This optimizes the interaction and utilization efficiency of multi-scale features. Combined with a multi-detection layer design, it significantly improves the model's robustness in detecting weld defects of different sizes, balancing the detection performance of large welds with small pores and spatter points. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a flowchart of the steel pipe weld defect detection method based on the improved YOLOv11n in Example 1.

[0020] Figure 2 This is the overall architecture diagram of the YOLOv11n-CFA network model.

[0021] Figure 3 This is a schematic diagram of the multi-branch heterogeneous convolutional architecture of the C3k2-coor module.

[0022] Figure 4 This is a schematic diagram of the SPPF-freq module.

[0023] Figure 5 This is a schematic diagram of the AFPN asymptotic feature pyramid structure.

[0024] Figure 6 This is a visualization comparing the weld defect identification results of the YOLOv11n-CFA described in this invention with the original YOLOv11n model. Detailed Implementation

[0025] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0026] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0027] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.

[0028] Example 1, referring to Figures 1-6 This is the first embodiment of the present invention, which provides a method for detecting defects in steel pipe welds based on an improved YOLOv11n, including the following steps: S1. Collect steel pipe weld image data, construct steel pipe weld defect dataset, preprocess and augment the dataset and divide it into training set, validation set and test set; A fixed industrial area array camera was used to acquire images of the weld seam surface of the steel pipe, and a low-angle ring light source was used to illuminate the weld seam area to obtain the original grayscale image of the steel pipe weld seam. The camera is fixed directly above the steel pipe weld or at a small angle, and the light source illuminates the weld surface at a low angle, so that a stable grayscale difference is formed between cracks, pores, spatter points, incomplete penetration areas and the surrounding weld texture. Based on the original grayscale images of steel pipe welds, a set is formed, and weld defect categories are defined, including cracks, spatter, porosity, and incomplete penetration. The welds in each image are marked with rectangular boxes and normalized after being adjusted to uniform pixels, preferably 640*640 pixels. The matrix boxes are scaled and transformed synchronously. In order to be compatible with the original three-channel input structure of YOLOv11n, the single-channel grayscale images are copied into three-channel grayscale images. The normalized grayscale image of the steel pipe weld is input into the YOLOv11n backbone network, which outputs four scale features. , , as well as ,in This corresponds to shallow features with a stride of 4. Features corresponding to a stride of 8 Features corresponding to a stride of 16 The corresponding deep feature has a stride of 32; The rectangular box annotation includes the rectangular box annotation of the weld reference area and the weld defect area. The weld reference area annotation is not used as a defect alarm category, but as a structural reference for subsequent weld spatial reliability modeling, defect relative positioning and training sample recognition. Generate a weld space reliability map based on the weld reference region. Specifically: Extract the weld reference region rectangle from the matrix bounding box annotation set. If multiple weld reference region rectangles exist in a weld image, extract the rectangle with the largest area as the main weld reference frame. Calculate the height of the weld reference frame and define the horizontal centerline of the weld image as the weld centerline. Calculate the vertical distance from each pixel in the weld image to the weld centerline to construct the weld reliability map.

[0029] in For pixels To ensure the reliability of the effective weld inspection area, the value range is: , To ensure the effective influence of weld width control coefficient, it is preferably half the height of the weld reference frame. For pixels The vertical distance to the centerline of the weld; Data augmentation was performed on the normalized grayscale images of steel pipe welds, and the data was divided into training, validation, and test sets. The data augmentation includes at least one of image rotation, mirror flipping, stitching, brightness adjustment, contrast adjustment, and black and white processing. The dataset is randomly divided into a training set, a validation set, and a test set according to a preset sample size ratio, with a preferred ratio of 7:2:1.

[0030] S2. Construct the YOLOv11n-CFA weld defect detection model, including improving the C3k2 module in the backbone network to the C3k2-coor module, improving the spatial pyramid pooling module SPPF to the SPPF-freq module, and replacing the original feature pyramid network with the progressive feature pyramid network AFPN. S2.1 Integrating the CoordAttention mechanism into the original C3k2 module, the global pooling operation is decomposed into one-dimensional feature encoding in the horizontal and vertical directions through two steps: coordinate information embedding and coordinate attention generation. This captures long-distance feature dependencies and retains accurate positional information. A multi-branch parallel convolutional structure is constructed, with four independent convolutional branches configured with four heterogeneous convolutional kernels of 1×1, 3×3, 5×5, and 7×7 respectively. Each branch uses Conv-BN-SiLU basic units. Convolutional kernels of different sizes work together to cover multi-level receptive fields from 3×3 to 14×14. The multi-branch convolutional output features are multiplied element-wise with the attention weights output by the coordinate attention mechanism, and then fused with the original input features through residual connections to output an enhanced feature map. The scale features output by the backbone network are used as the input feature map. The four convolutional branches are input separately, where C is the number of channels, H is the feature map height, and W is the feature map width:

[0031]

[0032]

[0033]

[0034] in , , , They represent The output of the convolution branch, Indicates the kernel size as Conv-BN-SiLU unit; Specifically, when selecting scale features, only C3k2 modules with strides of 8, 16, and 32 are replaced with C3k2-coor modules; that is, only the C3k2-coor modules are selected. , as well as As input, the original lightweight convolutional structure with a stride of 4 stages is retained in the shallowest layer because the shallow features themselves have high resolution, and introducing complex attention structures too early will increase the computational cost; the mid-to-high-level features require more positional attention and multi-scale semantic enhancement, so replacing them with strides of 8, 16, and 32 stages can balance accuracy and speed. Different sized convolutional kernels work together to cover multi-level receptive fields ranging from 3×3 to 14×14; among them, the 1×1 convolutional kernel is a feature channel basis vector projection layer to realize cross-channel information interaction; the 3×3 convolutional kernel is a basic receptive field extension layer to capture the primary geometric features of target edges and corners; the 5×5 convolutional kernel captures mid-range spatial dependencies through cascaded small convolutional kernels; and the 7×7 convolutional kernel captures high-level semantic information. The outputs of the four convolutional branches are concatenated and channel compressed:

[0035] Where B represents the spliced ​​and compressed output; A coordinate attention mechanism is employed, using pooling kernels of sizes (H,1) and (1,W) to encode the horizontal and vertical spatial directions, respectively:

[0036]

[0037] in, This indicates that the c-th channel is located at coordinates The feature value, i.e., the pixel value, This represents the encoding of the c-th channel at the i-th position in the height direction. This represents the encoding of the c-th channel at the j-th position in the width direction; The horizontal and vertical spatial direction codes are concatenated and input into a convolution function to obtain the intermediate feature map F:

[0038] in Encoding for vertical spatial orientation, Encoding for horizontal spatial direction, It is a 1×1 convolution transform function. It is a non-linear activation function; The intermediate feature map F is split along the spatial direction into... and Attention weights are generated for the height and width directions respectively:

[0039]

[0040] in and These represent two 1×1 convolution transformation functions. It is the Sigmoid activation function. and These are the attention weights in the height and width directions, respectively; The enhanced feature map is then weighted based on the attention weights and output.

[0041] Where Y is the enhanced feature map, including , as well as , respectively corresponding , as well as .

[0042] S2.2 Introduce the FreqFusion frequency domain feature fusion module into the original SPPF module to decompose the input feature map into low-frequency information and high-frequency information for separate processing; where the low-frequency information corresponds to the consistency of defect categories and global semantic features, and the high-frequency information corresponds to the details of defect boundaries and the contour features of objects. The enhanced feature map is used as the input feature of the SPPF-freq module, and a one-dimensional transformation is performed to adjust the channels to form the initial fused features. Only those representing deep semantic features are selected. Input the SPPF-freq module, and generate low-frequency features using a low-pass filter kernel based on the initial fused features:

[0043]

[0044] in This is the low-pass filter kernel at position p in the feature map. Let p be the feature value at position p in the feature map. For p as the center Neighborhood, where q represents the neighborhood offset. The low-frequency feature at position p; select The neighborhood can smooth local noise and preserve the structure near the boundary; if the filtering neighborhood is too large, it will weaken the boundaries of fine cracks and small pores. High-frequency features are generated by inverting the low-pass filter kernel to obtain the high-pass filter kernel:

[0045]

[0046] in This represents the high-frequency feature at position p. This is a filter inversion operation; Define the neighborhood direction D to calculate the similarity between position p and its neighboring positions:

[0047] in Let d represent the cosine similarity, and d be the neighborhood direction. D represents the eight-neighbor direction. To prevent division by zero decimals; Specifically, the set of eight neighboring directions includes:

[0048] Generate resampling offset and resampling features based on similarity. :

[0049]

[0050] in Let p be the offset. The maximum offset limit coefficient is preferably set to 1.5, which means that the offset range is limited to the local neighborhood. This can correct the problem of blurred weld defect boundaries, while avoiding excessive offset that could lead to feature misalignment. Indicates bilinear interpolation sampling; The frequency domain enhancement features are obtained by fusing low-frequency features, high-frequency features, and resampling features:

[0051] in For frequency domain enhancement features, , , These are the fusion coefficients for low-frequency, high-frequency, and resampling features, respectively. ; Preserve SPPF pooling branch output:

[0052]

[0053]

[0054] in , , They represent three consecutive times. Max pooling output; After concatenating the frequency domain enhanced features with the output of the SPPF pooling branch, the channel dimension is adjusted to output the final feature map.

[0055] in This is the final feature map.

[0056] S2.3 Replace the original YOLOv11n PAFPN feature pyramid network with AFPN. In the multi-level feature fusion process, introduce the adaptive spatial fusion mechanism ASFF to assign dynamic spatial weights to features at different levels. A gradual fusion of low-level detailed information and high-level semantic information is achieved through feature interaction between levels. Cross-layer feature splicing and channel attention weighting are implemented in the shallow feature extraction stage to gradually inject spatial detailed information into deep semantic features. The top-level features and bottom-level features are spatially aligned. Through layer-by-layer information fusion and feature alignment, the semantic gap between features at different levels is reduced. Define the four-scale features for entering AFPN:

[0057] in , , , It is a four-scale feature; Unify the four-scale feature channels into the number of fused channels:

[0058] in For the l-th layer features after channel compression, the optimal number of fused channels is 128. YOLOv11n is a lightweight model, and 128 channels can retain sufficient semantic expression while controlling the computational cost of AFPN. Features at different scales are spatially aligned, and spatially adaptive weights are generated using ASFF:

[0059] in For the r-th input feature at position The fusion weight at the point, This represents the 1×1 convolution weight generation function. The set of features currently participating in the fusion. For the spatially aligned r-th input feature at position The feature value at point u is the feature index; The fused output is:

[0060] in This indicates the position of the fused output features. Eigenvalues ​​at; Four-scale detection features are obtained through progressive fusion based on spatial adaptive weights. First, integration and Small target enhancement features are obtained. It is mainly used for defect detection of small targets; Second, After downsampling and , Fusion, yielding fusion characteristics of small and medium-sized targets. ; Third, After downsampling and , Integration yields the integration characteristics of medium and large target groups. ; Fourth, After downsampling and Fusion yields semantic features of the large target. .

[0061] S2.4. Construct a four-scale detection head using an anchor-free detection head, and output bounding box regression parameters, class probability, and target confidence for each scale detection feature.

[0062] S3. Input the training set into the YOLOv11n-CFA model for iterative training, verify the model performance in real time through the validation set, select the optimal weights based on the preset evaluation index, and obtain the trained steel pipe weld defect detection model. The hyperparameters for training the YOLOv11n-CFA model were set as follows: input image size 640×640, batch size 16, training iterations 200, SGD optimizer, weight decay coefficient 0.0005, initial learning rate 0.01, momentum 0.937, and model evaluation metrics including precision, recall, mean AP@0.5, mean AP@0.5-0.95, and F1-Score. The model weights with the highest mAP@0.5 on the validation set were selected as the optimal weights. During training, a cosine annealing strategy is used to update the learning rate.

[0063] During training, the YOLOv11n-CFA model constructs a total loss function using bounding box loss, class loss, and object confidence loss. Specifically, calculate the normalized area of ​​the m-th real defect target. Calculate the area weight of small targets :

[0064] in The reference value for the small target area is preferably 0.01, which means that when the target area occupies about 1% of the input image, it is used as a reference for small target enhancement. The enhancement factor for small targets is preferably 1.5; Simultaneous calculation of weld space weighting coefficient:

[0065] in Let m be the center point of the defect. The weld space enhancement coefficient is preferably 0.5, which can moderately increase the training attention to defects in the core area of ​​the weld, while not completely ignoring real defects in the weld edge or heat-affected zone. Calculate the overall objective weight :

[0066] Based on the comprehensive target weight Calculate the bounding box loss and the class loss:

[0067]

[0068] in and These are the bounding box loss and the class loss, respectively. The number of defective targets in the current batch is obtained through annotation of the training set. For complete intersection and union ratio indicators, Represents the true bounding box. This represents the model's predicted bounding box. For class-balanced weights, ,in The average number of samples in each class. Let c be the number of samples in category c. Let be the probability that the m-th target is predicted as the true class c. FocalLoss represents the focusing coefficient for difficult samples; Furthermore, negative sample enhancement weights are set based on the center point of the model detection grid. :

[0069] in To detect the center point of the grid, The weld reliability threshold is preferably 0.5, indicating that the mesh is located in or near the weld body and belongs to the weld texture area that is prone to false detection. Areas below this value are mostly ordinary background and do not require excessive reinforcement of negative sample constraints. The enhancement coefficient for difficult negative samples is preferably 0.8. Negative samples within the weld zone are indeed more likely to cause false detections than ordinary backgrounds, requiring enhanced constraints. However, if the coefficient is too large, it will cause the model to excessively suppress the response in the weld zone, affecting the recall of true defects. Specifically, the inspection grid can be obtained by dividing the weld image; Define the training weights of the grid If the g-th grid matches the m-th real defect target, then the training weights are: If the g-th grid Then it is defined as the difficult negative sample grid within the weld seam, and the training weights are... If it is another ordinary grid, the training weight is 1; Calculate the target confidence loss:

[0070] in The number of detection grids participating in training. This indicates whether the g-th grid contains a real target. This indicates the probability that the model predicts the grid contains the target; The bounding box loss, class loss, and target confidence loss are weighted and combined into a total loss function.

[0071] S4. Input the image of the weld seam of the steel pipe to be inspected into the trained weld seam detection model. The model outputs the category of weld seam defects, bounding box coordinates, confidence level and defect location information.

[0072] After inputting the image of the weld seam of the steel pipe to be inspected into the trained weld seam detection model, the model outputs the bounding box regression parameters, class probability, and target confidence. The model determines the category of weld defect based on the class probability and analyzes the bounding box regression parameters to obtain the bounding box coordinates and defect location information.

[0073] This embodiment also provides a steel pipe weld defect detection trolley based on the improved YOLOv11n, which is applicable to the steel pipe weld defect detection method based on the improved YOLOv11n, and realizes the steel pipe weld defect detection method based on the improved YOLOv11n proposed in the above embodiment.

[0074] In summary, this invention, through improvements to the C3k2-coor module, combines the coordinate attention mechanism with a multi-branch heterogeneous convolution structure. This not only achieves accurate preservation of defect feature location information but also enables complementary enhancement of cross-scale features through multi-scale convolution kernels. This significantly improves the model's feature extraction capabilities for minor weld defects and small target defects, solving the problem of low recall rate for small target defects in existing technologies.

[0075] This invention improves the SPPF-freq module by decomposing image features into high- and low-frequency information based on frequency domain analysis and processing them separately. It enhances intra-class consistency of defects through an adaptive low-pass filter and strengthens boundary detail information through an offset generator and an adaptive high-pass filter. This effectively solves the problem of loss of image details due to blurred boundaries and improves the model's recognition accuracy for irregular and blurred weld defects.

[0076] This invention reconstructs the feature fusion architecture through the AFPN progressive feature pyramid network, and combines it with an adaptive spatial fusion mechanism to achieve progressive fusion of low-level details and high-level semantics. It optimizes the interaction and utilization efficiency of multi-scale features, and with the multi-detection layer design, it significantly improves the model's robustness in detecting weld defects of different sizes, while taking into account the detection performance of large welds as well as small pores and spatter points.

[0077] In this embodiment, an experimental dataset was constructed by combining a self-built steel pipe weld dataset with a publicly available weld defect dataset. The dataset contains 5615 steel pipe weld images, covering four types of labeled targets: cracks, spatter, porosity, and weld lines. The LabelImg annotation tool was used to annotate bounding boxes on all images, with annotation information including the defect category and the corresponding bounding box coordinates. The annotation results were verified, and incorrectly labeled samples were removed to ensure the accuracy of the dataset annotation.

[0078] The dataset was preprocessed by normalizing all images to 640×640 pixels and performing grayscale normalization to normalize pixel values ​​to the 0-1 range, reducing the computational cost of the model. Data augmentation was performed using image rotation, mirroring, random stitching, brightness adjustment, contrast adjustment, and black-and-white conversion to simulate image characteristics under complex industrial conditions such as dim lighting, uneven illumination, and occlusion, thereby expanding the dataset sample size and improving the model's generalization and robustness.

[0079] The preprocessed dataset was randomly divided into a training set, a validation set, and a test set, with 4815 images in the training set, 400 images in the validation set, and 400 images in the test set.

[0080] The experimental environment was configured as follows: operating system was Ubuntu 18.04.6 LTS, CPU was Intel(R)Core(TM) i7-10700K CPU @ 3.80GHz×16, RAM was 64G, GPU was NVIDIA GeForce RTX 4090, Python version was 3.9.19, PyTorch version was 2.0.1, and CUDA version was 11.8.

[0081] The model training hyperparameters were set as follows: input image size 640×640, batch size 16, training iterations 200, SGD optimizer, weight decay coefficient 0.0005, initial learning rate 0.01, and momentum 0.937. During training, after each training round, the model's precision, recall, mAP@0.5, mAP@0.5-0.95, and F1-Score were calculated on the validation set. The model weights with the highest mAP@0.5 on the validation set were saved as the optimal weights, resulting in the trained steel pipe weld defect detection model.

[0082] To verify the performance advantages of the model of this invention, comparative experiments and ablation experiments were conducted in this embodiment: Comparative Experiment: Mainstream YOLO models YOLOv3-tiny, YOLOv5n, YOLOv7-tiny, YOLOv8n, YOLOv10n, and YOLOv11n were selected and compared under the same dataset and experimental environment. The results are shown in the table below: Table 1: Comparative Experiment Table YOLOv3-tiny 79.6 67.3 73.7 52.8 72.9 YOLOv5n 84.4 75.8 83.0 59.0 79.9 YOLOv7-tiny 87.4 80.9 85.6 58.6 84.0 YOLOv8n 84.9 77.0 83.7 61.3 80.8 YOLOv10n 83.8 76.6 83.3 61.1 80.0 YOLOv11n 86.3 78.1 85.1 61.8 82.0 This invention, YOLOv11n-CFA 91.6 84.6 91.2 69.5 88.0 The comparative experimental results show that the YOLOv11n-CFA model proposed in this invention outperforms the mainstream YOLO series models in all evaluation metrics. Compared with the original YOLOv11n model, the precision is improved by 5.3%, the recall is improved by 6.5%, the mAP@0.5 is improved by 6.1%, the mAP@0.5-0.95 is improved by 7.7%, and the F1-Score is improved by 6%, resulting in a significant improvement in overall detection performance.

[0083] Ablation experiments: Based on the YOLOv11n model, the three improved modules were tested individually and in combination to verify the effectiveness of each module. The experimental results are shown in the table below: Table 2: Ablation Experiment Table - - - 86.3 78.1 85.1 61.8 82.0 √ - - 87.9 77.7 85.2 62.3 82.5 - √ - 86.2 77.3 84.2 61.7 81.5 - - √ 87.1 79.0 86.3 63.5 82.8 √ √ √ 91.6 84.6 91.2 69.5 88.0 The ablation experiment results show that when the three improved modules are used together, the overall performance of the model is maximized. The C3k2-coor module effectively improves the feature extraction capability, the AFPN module significantly optimizes the multi-scale feature fusion effect, and the three modules form a synergistic optimization, achieving a comprehensive improvement in the performance of weld defect detection.

[0084] The visualization comparison of the model detection results is shown in Table 2. Compared with the original YOLOv11n model, the YOLOv11n-CFA model of the present invention has comparable detection accuracy for large targets in welds, and significantly higher confidence in identifying small target defects such as porosity and spatter. The false negative rate and false positive rate are greatly reduced, which verifies the effectiveness of the method of the present invention.

[0085] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A method for detecting defects in steel pipe welds based on the improved YOLOv11n, characterized in that: include, Collect steel pipe weld image data, construct a steel pipe weld defect dataset, preprocess and augment the dataset and divide it into training set, validation set and test set; A YOLOv11n-CFA weld defect detection model was constructed, including improving the C3k2 module in the backbone network to the C3k2-coor module, improving the Spatial Pyramid Pooling Module (SPPF) to the SPPF-freq module, and replacing the original Feature Pyramid Network with the Progressive Feature Pyramid Network (AFPN). The training set is input into the YOLOv11n-CFA model for iterative training. The model performance is verified in real time through the validation set. The optimal weights are selected based on the preset evaluation index to obtain the trained steel pipe weld defect detection model. The image of the weld seam of the steel pipe to be inspected is input into the trained weld seam inspection model. The model outputs the category of weld defect, bounding box coordinates, confidence level and defect location information.

2. The method for detecting defects in steel pipe welds based on the improved YOLOv11n as described in claim 1, characterized in that: The process of acquiring steel pipe weld seam image data, constructing a steel pipe weld seam defect dataset, and preprocessing and augmenting the dataset before dividing it into training, validation, and test sets involves using a fixed industrial area array camera to acquire surface images of the steel pipe weld seam, and illuminating the weld seam area with a low-angle ring light source to obtain the original grayscale image of the steel pipe weld seam. ; Based on the original grayscale images of steel pipe welds, a set is formed, and weld defect categories are defined, including cracks, spatter, porosity, and incomplete penetration. Each weld in the image is labeled with a rectangular bounding box, adjusted to a uniform pixel size, and then normalized. The normalized grayscale images of steel pipe welds are then input into the YOLOv11n backbone network, which outputs four scale features. , , as well as ; Rectangular box annotations include rectangular box annotations for the weld reference area and the weld defect area; Generate a weld space reliability map based on the weld reference region. ; Data augmentation was performed on the normalized grayscale images of steel pipe welds, and the data was divided into training, validation, and test sets.

3. The method for detecting defects in steel pipe welds based on the improved YOLOv11n as described in claim 2, characterized in that: The improvement of the C3k2 module in the backbone network to a C3k2-coor module includes using the scale features output by the backbone network as the input feature map. Input the four convolutional branches separately, and then concatenate and compress the outputs of the four convolutional branches. A coordinate attention mechanism is employed, using pooling kernels of sizes (H,1) and (1,W) to encode the horizontal and vertical spatial directions respectively. The encodings of the horizontal and vertical spatial directions are then concatenated and input. The convolution function yields an intermediate feature map F. This intermediate feature map F is then split along the spatial direction into... and Attention weights are generated for the height and width directions, respectively. The enhanced feature map is then output by weighting based on attention weights.

4. The method for detecting defects in steel pipe welds based on the improved YOLOv11n as described in claim 3, characterized in that: The improvement of the Spatial Pyramid Pooling (SPPF) module to an SPPF-freq module includes using the enhanced feature map as the input feature of the SPPF-freq module, performing a one-dimensional transformation, and adjusting the channels to the initial fused features. Low-frequency features are generated using a low-pass filter kernel based on the initial fusion features; High-frequency features are generated by inverting the low-pass filter kernel to obtain the high-pass filter kernel; Define a neighborhood direction D, calculate the similarity between position p and its neighboring positions, generate a resampling offset and resampling features based on the similarity. The frequency domain enhancement features are obtained by fusing low-frequency features, high-frequency features, and resampling features. Preserve SPPF pooling branch output; After concatenating the frequency domain enhancement features with the output of the SPPF pooling branch, the channel dimensions are adjusted to output the final feature map.

5. The method for detecting defects in steel pipe welds based on the improved YOLOv11n as described in claim 4, characterized in that: The process of replacing the original feature pyramid network with the progressive feature pyramid network AFPN includes defining four-scale features entering the AFPN, unifying the four-scale feature channels to the number of fusion channels, spatially aligning features of different scales, generating spatially adaptive weights using ASFF, and performing progressive fusion based on the spatially adaptive weights to obtain four-scale detection features.

6. The method for detecting defects in steel pipe welds based on the improved YOLOv11n as described in claim 5, characterized in that: The construction of the YOLOv11n-CFA weld defect detection model also includes using an anchor-free detection head to construct a four-scale detection head, and outputting bounding box regression parameters, class probability, and target confidence for each scale detection feature.

7. The method for detecting defects in steel pipe welds based on the improved YOLOv11n as described in claim 6, characterized in that: The hyperparameters for training the YOLOv11n-CFA model were set as follows: input image size 640×640, batch size 16, training iterations 200, SGD optimizer, weight decay coefficient 0.0005, initial learning rate 0.01, momentum 0.937, and model evaluation metrics including precision, recall, mean AP@0.5, mean AP@0.5-0.95, and F1-Score. The model weights with the highest mAP@0.5 on the validation set were selected as the optimal weights. During training, a cosine annealing strategy is used to update the learning rate.

8. The method for detecting defects in steel pipe welds based on the improved YOLOv11n as described in claim 7, characterized in that: The YOLOv11n-CFA model constructs a total loss function during training using bounding box loss, class loss, and target confidence loss.

9. The method for detecting defects in steel pipe welds based on the improved YOLOv11n as described in claim 8, characterized in that: After the image of the steel pipe weld to be detected is input into the trained weld detection model, the bounding box regression parameters, class probability, and target confidence are output. The model determines the category of weld defect based on the class probability and analyzes the bounding box regression parameters to obtain the bounding box coordinates and defect location information.

10. A steel pipe weld defect detection trolley based on the improved YOLOv11n, characterized in that: The inspection trolley is used to implement the steps of the steel pipe weld defect inspection method based on the improved YOLOv11n as described in any one of claims 1 to 9.