Method and system for detecting magnetic flux leakage defect of long-distance pipeline based on improved YOLOv8

By improving the YOLOv8 model, combining the SPD-Conv module and the CBAM attention module, the problem of large amount of data and low manual analysis efficiency in the detection of magnetic leakage defects in long-term transmission pipelines is solved, and efficient and accurate detection of magnetic leakage defects is achieved.

CN119625283APending Publication Date: 2025-03-14SANYA MARINE OIL & GAS RESEARCH INSTITUTE NORTHEAST PETROLEUM UNIVERSITY

Patent Information

Application Number
CN202510009850.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-03
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

The existing magnetic leakage signal recognition mainly relies on manual calculation and analysis, which is time-consuming and labor-consuming, and is prone to missed detection and missed detection problems. At the same time, due to the long transmission distance of oil and gas pipelines, the amount of MFL data collected is huge, making manual analysis inefficient and difficult to achieve online detection.

Method used

Using the long-term pipeline leakage defect detection method based on improved YOLOv8, a lightweight SPD-Conv module and a CBAM attention module are introduced into the backbone network of the original YOLOv8 network model, and the loss function in the original model is replaced by the ECIOU_LOSS loss function to form an improved YOLOv8 model to detect leakage defects in the pipeline.

Benefits of technology

It improves detection efficiency, can show stronger robustness in complex scenarios, and at the same time improves detection accuracy, avoids the loss of small target information and missed detection and missed detection, and realizes online detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119625283A_ABST
    Figure CN119625283A_ABST
Patent Text Reader

Abstract

The invention provides a long-distance pipeline magnetic flux leakage defect detection method and system based on improved YOLOv8, and belongs to the field of pipeline safety detection.The method comprises the steps that magnetic flux leakage image data of a long-distance pipeline are obtained, defect labeling is conducted on the image data, and a data set is obtained. A lightweight SPD-Conv module is introduced into a backbone network of an original YOLOv8 network model, a CBAM attention module is added in a neck structure, an ECIOULOSS loss function is used for replacing a loss function in an original model, an improved YOLOv8 model is formed, part of data is selected from a data set according to the proportion to be input into the model for training, and a pipeline detection model is obtained. And inputting a to-be-detected image into the pipeline detection model, and outputting defect information and defect positions in the image. Through the improved YOLOv8 network model, the influence of human factors on magnetic flux leakage defect detection is effectively reduced, and the accuracy and reliability of long-distance pipeline magnetic flux leakage defect detection are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of pipeline safety detection, and in particular relates to a long-distance pipeline magnetic leakage defect detection method and system based on improved YOLOv8. Background Art

[0002] Pipelines are important facilities for long-distance transportation of oil and gas. However, with the increase in the service life of pipelines, pipeline leakage accidents have occurred frequently in recent years, which has attracted widespread attention from the world. In order to ensure the long-term safe operation of pipelines, regular inspection and maintenance of pipelines are essential. Commonly used non-destructive testing technologies include radiographic (RT) testing, eddy current (ECT) testing, ultrasonic (UT) testing and magnetic flux leakage (MFL) testing. Among them, MFL testing is the most popular method in oil and gas pipeline detection technology, which has the characteristics of high reliability, low testing requirements and wide applicability. However, the existing magnetic flux leakage signal recognition mainly relies on manual calculation and analysis for judgment, which is not only time-consuming and labor-intensive, but also prone to problems such as missed detection and false detection. In addition, due to the long transmission distance of oil and gas pipelines, the amount of MFL data collected is huge, which makes manual analysis inefficient and difficult to achieve online detection.

[0003] Deep learning technology can directly learn object-specific features from data. Since it was proposed, it has attracted much attention. It is necessary to apply deep learning technology to the detection of magnetic flux leakage defects in long-distance pipelines to change the shortcomings of traditional manual analysis methods. With the development of deep learning, more and more target detection algorithms have been proposed. These algorithms are mainly divided into two categories: region proposal-based algorithms and regression-based algorithms. Region proposal-based algorithms are two-stage target detection algorithms, which involve preprocessing steps for region proposals, so that the whole process is divided into two stages. Common two-stage algorithms include R-CNN, Fast R-CNN, Faster R-CNN, Mask R-CNN, etc. Although the two-stage target detection algorithm performs well in accuracy, it has high computational cost and slow processing speed. In contrast, the single-stage algorithm is an algorithm that does not require region proposal and does not separate the detection and proposal processes. Typical single-stage algorithms include YOLO (You Only Look Once) and SSD. Therefore, the detection of magnetic flux leakage defects through a single-stage algorithm is conducive to changing the current situation of large data volume and low efficiency of manual analysis. However, magnetic flux leakage detection in long-distance transportation pipelines has its own particularity, and directly using existing algorithms for detection cannot meet the needs. Summary of the invention

[0004] In order to solve the problems of large data volume and easy missed detection and false detection in magnetic leakage defect detection in long-distance pipelines, the present invention provides a long-distance pipeline magnetic leakage defect detection method and system based on improved YOLOv8.

[0005] In order to achieve the above object, the present invention provides the following technical solutions: A long-distance pipeline magnetic leakage defect detection method based on improved YOLOv8 includes the following steps: A lightweight SPD-Conv module is introduced into the backbone network of the original YOLOv8 network model, a CBAM attention module is added to the neck structure, and the loss function in the original model is replaced with the ECIOU_LOSS loss function to form an improved YOLOv8 model; Obtaining a magnetic flux leakage defect image of a long-distance oil and gas pipeline, annotating the magnetic flux leakage defect image to obtain a training set, inputting the data in the training set into the improved YOLOv8 model to train the model, and obtaining a pipeline detection model; The image of the long-distance oil and gas pipeline to be inspected is input into the pipeline detection model, the spatial information of the image is converted into depth information through the SPD-Conv module and a feature image is output after convolution, the feature image is input into the CBAM attention module, average pooling and maximum pooling operations are performed in the spatial dimension and channel dimension, and an attention feature map is output; the defect information and defect location are marked in the attention feature map, and the image of the long-distance oil and gas pipeline to be inspected with the defect information and defect location is output.

[0006] Preferably, the ECIOU_LOSS loss function is specifically: ; Among them, α is the weight function; v is used to calculate the height ratio consistency between the prediction box and the target box, which is measured by tan angle and is a balance parameter; IOU is the parameter value assigned priority; c is the diagonal distance of the minimum closure area that can contain both the prediction box and the true box; ρ is the relationship between IOU and the center point distance, which is used to measure the impact of the center point distance on the loss; b gt Represents the coordinates of the center point of the real frame; w gt and h gt Represent the width and height of the real box respectively; w and h represent the width and height of the predicted box respectively; c w and c h Represent the width and height of the minimum enclosed area of ​​the two boxes respectively; the calculation formulas of α and v are as follows: ; .

[0007] Preferably, the spatial information of the image is converted into depth information through the SPD-Conv module and the feature image is output after convolution. The SPD-Conv module consists of a spatial depth SPD layer and a convolution-free step size. The processing steps are specifically as follows: Downsample the feature map X1, retain all the information in the channel, and rearrange the spatial information in the feature map X1 to the depth channel; The feature map X1 arranged in the depth channel is divided into multiple sub-feature maps, which are concatenated in the channel direction to obtain the feature map X2; The feature map X2 is processed by the convolution layer of the C2 filter to obtain a feature image.

[0008] Preferably, the CBAM attention module includes a channel attention module and a spatial attention module, and the channel attention module and the spatial attention module are connected in series to process the image, and the specific steps are: The channel attention module uses the maximum pooling operation and the average pooling operation on the input feature map to obtain two C-dimensional pooled feature maps, which are and ,Will and The input contains the hidden layer of the multi-layer perceptron MLP and adds it to generate the channel attention map M C , M C The specific formula is: Mc(F)=σ(MLP(AvgPool(F))+MLP(MaxPool(F))); Where F represents the input feature map, with a size of H×W×C, where H and W are spatial dimensions and C is the number of channels; AvgPool(F) and MaxPool(F) represent global average pooling and global maximum pooling operations on the feature map, respectively, and the output result is a vector of size 1×1×C; MLP represents a multilayer perceptron, that is, a network consisting of two fully connected layers; σ is the sigmoid activation function; The channel attention map M output by the channel attention module C Input into the spatial attention module, perform average pooling and maximum pooling operations on the channel dimension, and re-output two feature maps and , the two feature maps are spliced ​​in the channel dimension to obtain a spliced ​​spatial feature map, and the spliced ​​feature map is processed by a convolution layer to obtain a spatial attention map M s , M s The specific formula is: Ms(F)=σ(f 7×7 ([AvgPool(F);MaxPool(F)])); Among them, F is the feature map after channel attention weighting; AvgPool(F) and MaxPool(F) respectively represent the average pooling and maximum pooling operations in the channel dimension to obtain two feature maps of size H×W×1; [AvgPool(F);MaxPool(F)] means concatenating these two feature maps in the channel dimension to obtain a feature map of size H×W×2; f7×7 represents a 7×7 convolution operation, which is used to fuse spatial information; σ is the sigmoid activation function.

[0009] Preferably, the defect types in the magnetic flux leakage defect image specifically include: flange, metal loss, weld defect and tee.

[0010] Preferably, the method further comprises performing image enhancement after marking the magnetic leakage defect image.

[0011] The present invention also provides a long-distance pipeline magnetic leakage defect detection system based on improved YOLOv8, which specifically includes: The model building module is used to introduce a lightweight SPD-Conv module into the backbone network of the original YOLOv8 network model, add a CBAM attention module into the neck structure, and replace the loss function in the original model with the ECIOU_LOSS loss function to form an improved YOLOv8 model.

[0012] The training module is used to obtain the magnetic leakage defect image of the long-distance oil and gas pipeline, annotate the magnetic leakage defect image to obtain a training set, input the data in the training set into the improved YOLOv8 model to train the model, and obtain a pipeline detection model.

[0013] The detection module is used to input the image of the long-distance oil and gas pipeline to be detected into the pipeline detection model, convert the spatial information of the image into depth information through the SPD-Conv module and output a feature image after convolution, input the feature image into the CBAM attention module, perform average pooling and maximum pooling operations in the spatial dimension and channel dimension, and output an attention feature map; mark the defect information and defect location in the attention feature map, and output the image of the long-distance oil and gas pipeline to be detected with the defect information and defect location.

[0014] The present invention also provides a computer device, comprising a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps described in the method for detecting magnetic leakage defects in long-distance pipelines based on improved YOLOv8.

[0015] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is loaded by a processor, the steps described in the method for detecting magnetic leakage defects in long-distance pipelines based on improved YOLOv8 can be executed.

[0016] The invention provides a long-distance pipeline magnetic leakage defect detection method based on improved YOLOv8, which has the following beneficial effects: The present invention introduces a lightweight SPD-Conv module into the backbone network of the original YOLOv8 network model, converts the spatial information of the image into depth information and outputs a feature image after convolution, which can enhance the spatial and channel information of the image and avoid the loss of small target information. A CBAM attention module is added to the neck structure, and the enhanced image output by the backbone network is then passed through the CBAM attention module, which can focus on important areas in space and enhance the relevance of the image. The loss function in the original model is replaced by the ECIOU_LOSS loss function, the prediction frame adjustment is increased and the frame regression rate is accelerated. Therefore, the pipeline detection model obtained after training based on the improved YOLO8 model not only improves the detection efficiency, but also can show stronger robustness in complex scenes, while improving the accuracy of detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiment of the present invention and its design scheme, the following briefly introduces the drawings required for this embodiment. The drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0018] Figure 1 The present invention is a flowchart of a method for detecting magnetic leakage defects in long-distance pipelines based on improved YOLOv8.

[0019] Figure 2 is a magnetic leakage image collected in an embodiment of the present invention, wherein Figure 2 (a) is the flange defect diagram, Figure 2 (b) is the metal loss defect diagram, Figure 2 (c) is the weld defect diagram, Figure 2 (d) is the tee defect diagram.

[0020] Figure 3 This is a comparison between the original magnetic flux leakage image and the transformed image of the present invention. The letter symbols in the figure represent different transformation forms: Figure 3 (a) is the original image, Figure 3 (b) is to add noise, Figure 3 (c) is to change the brightness, Figure 3 (d) is a 180° rotation. Figure 3 (e) is vertical flip, Figure 3 (f) is horizontal flip.

[0021] Figure 4 This is a diagram of the improved YOLOv8 network structure in an embodiment of the present invention.

[0022] Figure 5 This is a structural diagram of the SPD-Conv module of the present invention.

[0023] Figure 6 This is a block diagram of the CBAM module of the present invention. Figure 6 (a) is the channel attention module, Figure 6 (b) is the spatial attention module, Figure 6 (c) is the CBAM attention module.

[0024] Figure 7 This is a training result diagram of the present invention. DETAILED DESCRIPTION

[0025] In order to enable those skilled in the art to better understand the technical solution of the present invention and implement it, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the scope of protection of the present invention.

[0026] Example The present invention provides a long-distance pipeline magnetic leakage defect detection method based on improved YOLOv8, such as Figure 1 As shown, the specific steps include: S1. Use the leakage magnetic online detection tool to collect the actual leakage magnetic signal of a long-distance oil and gas pipeline, and generate different types of leakage magnetic images after professional processing, such as Figure 2 As shown in the figure, after completing the magnetic flux leakage detection of a long-distance pipeline, a channel curve image is generated by line tracking points, and representative magnetic flux leakage images are screened out, mainly including four categories: flange, metal loss, weld defect and tee.

[0027] S2, adding noise (AddNoise), changing brightness (ChangeLight), rotating (Rotate) and flipping (Flip) to the collected magnetic leakage image data set in batches, generating a total of 1313 640×640 pixel magnetic leakage images; Figure 3 As shown in the figure, after adding noise, changing brightness, rotating and flipping some images in the dataset, a total of 1313 640×640 pixel magnetic flux leakage images were generated. The dataset contains four different categories of images, namely flange, metal loss, weld defect and tee. The specific number of images is shown in the table below:

[0028] Table 1 Image enhancement quantity table S3. Build an improved YOLOv8 network model, specifically including: introducing a lightweight SPD-Conv module into the backbone network of the original YOLOv8 network model, adding a CBAM attention module into the neck structure, and replacing the loss function in the original model with the ECIOU loss function to form an improved YOLOv8 model.

[0029] like Figure 5 As shown in Figure 2, the SPD-Conv module consists of a spatial depth (SPD) layer and a convolution-free stride (Conv stride = 1); Figure 5 In (a), the SPD layer first downsamples the feature map X[S×S×C1] but retains all information within the channel; Figure 5 (b) shows an example of scale=2, from spatial to depth operation, where the spatial information is rearranged into the depth channel; Figure 5 (c) shows that the feature map is divided into 4 sub-feature maps, each of which has a size of X1[S / 2×S / 2×C1], so no information loss occurs; then, Figure 5 (d) Concatenate the four sub-feature maps in the channel direction to obtain a feature map X2 of size [S / 2×S / 2×4C1]; after the SPD structure is completed, Figure 5 In (e), a convolution layer with a C2 filter is added, where the convolution step size stride = 1, and C2 < 4C1, and finally a feature map X3 of size [S / 2×S / 2×C2] is obtained; in this process, the convolution step size is set to 1 to avoid the loss of small target information, thereby improving the detection effect of small targets. Where S×S is the spatial resolution and C1 is the number of channels.

[0030] Add the CBAM attention module to the neck of YOLOv8. The structure of the CBAM module is as follows Figure 6 As shown in Figure 2, CBAM consists of two modules, the channel attention module and the spatial attention module, which are connected in series. This improvement can enhance the relevance of the image in the channel dimension and focus on important areas in space, which helps to improve the recognition effect.

[0031] The channel attention module uses maximum pooling and average pooling operations on the input feature map to aggregate spatial information and output two C-dimensional pooled feature maps, respectively. and .Will and Input into a multilayer perceptron (MLP) with hidden layers to generate two channel attention maps with parameters of 1×1×C. To reduce the number of parameters, the hidden layer neurons need to compress the input information, and the number of neurons is C / r, where r is the compression ratio. Finally, the output of the previous step is added to get the channel attention map M C, It is expressed by the following formula:

[0032] ; Among them, F represents the input feature map, with a size of H×W×C, where H and W are spatial dimensions; C is the number of channels; σ is the sigmoid activation function, which is used to normalize the output, and the output range is [0,1]; AvgPool(F) and MaxPool(F) represent the average pooling and maximum pooling operations on the feature map, respectively, and the output result is a vector of size 1×1×C; MLP represents Multi-Layer Perceptron, which is a network consisting of two fully connected layers.

[0033] The spatial attention module first performs average pooling and maximum pooling operations on F′ in the channel dimension and outputs two feature maps and , the parameter size is H×W×1. Then, the two feature maps are concatenated in the channel dimension to generate a concatenated spatial feature map. Finally, a convolutional layer with a size of 7x7 is used to process the concatenated feature map to further generate a spatial attention map M. s, M s It is expressed by the following formula: ; Among them, F is the feature map after channel attention weighting; [AvgPool(F);MaxPool(F)] means concatenating these two feature maps in the channel dimension to obtain a feature map of size H×W×2; f 7×7 Represents a 7×7 convolution operation, which is used to fuse spatial information.

[0034] The ECIOU_LOSS loss function is used in the improved model. The specific ECIOU_LOSS loss function is: ; Among them, α is the weight function; v is used to calculate the height ratio consistency between the prediction box and the target box, which is measured by tan angle and is a balance parameter; IOU is the parameter value assigned priority; c is the diagonal distance of the minimum closure area that can contain both the prediction box and the true box; ρ is the relationship between IOU and the center point distance, which is used to measure the impact of the center point distance on the loss; b gt Represents the coordinates of the center point of the real frame; w gt and h gt Represent the width and height of the real box respectively; w and h represent the width and height of the predicted box respectively; c w and c h Represent the width and height of the minimum enclosed area of ​​the two boxes respectively; the calculation formulas of α and v are as follows: ; .

[0035] S4. Divide the dataset into training set, validation set, and test set in a ratio of 7:2:1. Train the model with the training set and validate it with the validation set. After each training and validation, calculate the loss function value and update the model parameters through back propagation to determine whether the loss value has converged. If the loss value has converged, save the model parameters and load the model parameters to test the test set to obtain the pipeline detection model. If the loss value has not converged, tune the model parameters. Set the model hyperparameters, including: batch size batch_size is 16, optimizer optimizer is SGD, initial learning rate lr is 0.01, and input image size size is 640×640.

[0036] The model performance is evaluated using precision P (Precision), recall R (Recall), F1, average precision AP and mean average precision mAP. The higher the P, R, F1 and mAP values, the higher the network detection accuracy. Finally, it is compared with the original version of the YOLOv8 model to prove the superiority of the improved YOLOv8 performance and the effectiveness of the improvement.

[0037] ; ; ; ; ; Among them, TP represents the number of samples correctly predicted as positive by the model, FN represents the number of positive samples incorrectly classified as negative by the model, FP represents the number of negative samples incorrectly classified as positive by the model, and C is the total number of classes of detection targets.

[0038] S5. Input the image of the long-distance oil and gas pipeline to be inspected into the pipeline inspection model, and output the defect information and defect location of the image.

[0039] The present invention also provides a long-distance pipeline magnetic leakage defect detection system based on improved YOLOv8, which specifically includes: The model building module is used to introduce a lightweight SPD-Conv module into the backbone network of the original YOLOv8 network model, add a CBAM attention module into the neck structure, and replace the loss function in the original model with the ECIOU_LOSS loss function to form an improved YOLOv8 model.

[0040] The training module is used to obtain the magnetic leakage defect images of long-distance oil and gas pipelines, annotate the magnetic leakage defect images, obtain a training set, input the data in the training set into the improved YOLOv8 model to train the model, and obtain a pipeline detection model.

[0041] The detection module is used to input the image of the long-distance oil and gas pipeline to be inspected into the pipeline detection model, convert the spatial information of the image into depth information through the SPD-Conv module and output the feature image after convolution, input the feature image into the CBAM attention module, perform average pooling and maximum pooling operations in the spatial dimension and channel dimension, and output the attention feature map; mark the defect information and defect location in the attention feature map, and output the image of the long-distance oil and gas pipeline to be inspected with the defect information and defect location.

[0042] Each module in the above-mentioned long-distance pipeline magnetic flux leakage defect detection system based on improved YOLOv8 can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the corresponding operations of the above modules.

[0043] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps in an embodiment of a method for detecting magnetic leakage defects in a long-distance pipeline based on improved YOLOv8. The specific implementation method can be found in the method embodiment, which will not be repeated here.

[0044] Furthermore, the present invention also provides a non-temporary computer-readable storage medium containing instructions, and a computer program is stored on the storage medium. For example, a memory containing instructions, the above instructions can be executed by a processor of a computer device to complete the above method. For example, the non-temporary computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a tape, a floppy disk, and an optical data storage device. When the computer program is executed by the processor, it can implement the steps in an embodiment of a method for detecting magnetic leakage defects in a long-distance pipeline based on an improved YOLOv8. The specific implementation method can be found in the method embodiment, which will not be repeated here.

[0045] It should be understood by those skilled in the art that embodiments of the present invention may provide methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0046] The present invention is described with reference to flowcharts and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as a combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0047] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0048] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0049] It should be pointed out that the specific implementation methods described above can enable those skilled in the art to understand the invention more comprehensively, but do not limit the invention in any way. Therefore, although the invention has been described in detail in this specification and embodiments, those skilled in the art should understand that the invention can still be modified or replaced by equivalents; and all technical solutions and improvements that do not deviate from the spirit and scope of the invention are included in the protection scope of the patent for the invention. Any figure mark in the claims should not be regarded as limiting the claims involved. Any simple change or equivalent replacement of the technical solution that can be obviously obtained by any technician familiar with the field within the technical scope disclosed in the present invention belongs to the protection scope of the present invention.

Claims

1. A long-distance pipeline magnetic leakage defect detection method based on improved YOLOv8, characterized in that: The following steps are involved: A lightweight SPD-Conv module is introduced into the backbone network of the original YOLOv8 network model, a CBAM attention module is added to the neck structure, and the loss function in the original model is replaced with the ECIOU_LOSS loss function to form an improved YOLOv8 model; Obtaining a magnetic flux leakage defect image of a long-distance oil and gas pipeline, annotating the magnetic flux leakage defect image to obtain a training set, inputting the data in the training set into the improved YOLOv8 model to train the model, and obtaining a pipeline detection model; The image of the long-distance oil and gas pipeline to be detected is input into the pipeline detection model, the spatial information of the image is converted into depth information through the SPD-Conv module and a feature image is output after convolution, the feature image is input into the CBAM attention module, average pooling and maximum pooling operations are performed in the spatial dimension and channel dimension, and an attention feature map is output; The defect information and defect location are marked in the attention feature map, and an image of the long-distance oil and gas pipeline to be inspected with the defect information and defect location is output.

2. According to the method for detecting magnetic flux leakage defects in long-distance pipelines based on improved YOLOv8 in claim 1, it is characterized in that: The ECIOU_LOSS loss function is specifically: ; Among them, α is the weight function; v is used to calculate the height ratio consistency between the prediction box and the target box, which is measured by tan angle and is a balance parameter; IOU is the parameter value assigned priority; c is the diagonal distance of the minimum closure area that can contain both the prediction box and the true box; ρ is the relationship between IOU and the center point distance, which is used to measure the impact of the center point distance on the loss; b gt Represents the coordinates of the center point of the real frame; w gt and h gt Represent the width and height of the real box respectively; w and h represent the width and height of the predicted box respectively; c w and c h Represent the width and height of the minimum enclosed area of ​​the two boxes respectively; the calculation formulas of α and v are as follows: ; 。 3. According to the method for detecting magnetic leakage defects in long-distance pipelines based on improved YOLOv8 in claim 1, it is characterized in that: The SPD-Conv module converts the spatial information of the image into depth information and outputs the feature image after convolution. The SPD-Conv module consists of a spatial depth SPD layer and a convolution-free step. The specific processing steps are: Downsample the feature map X1, retain all the information in the channel, and rearrange the spatial information in the feature map X1 to the depth channel; The feature map X1 arranged in the depth channel is divided into multiple sub-feature maps, which are concatenated in the channel direction to obtain the feature map X2; The feature map X2 is processed by the convolution layer of the C2 filter to obtain a feature image.

4. According to the method for detecting magnetic flux leakage defects in long-distance pipelines based on improved YOLOv8 in claim 1, it is characterized in that: The CBAM attention module includes a channel attention module and a spatial attention module. The channel attention module and the spatial attention module are connected in series to process the image. The specific steps are as follows: The channel attention module uses the maximum pooling operation and the average pooling operation on the input feature map to obtain two C-dimensional pooled feature maps, which are and ,Will and The input contains the hidden layer of the multi-layer perceptron MLP and adds it to generate the channel attention map M C , M C The specific formula is: Mc(F)=σ(MLP(AvgPool(F))+MLP(MaxPool(F))); Where F represents the input feature map, with a size of H×W×C, where H and W are spatial dimensions and C is the number of channels; AvgPool(F) and MaxPool(F) represent global average pooling and global maximum pooling operations on the feature map, respectively, and the output result is a vector of size 1×1×C; MLP represents a multilayer perceptron, that is, a network consisting of two fully connected layers; σ is the sigmoid activation function; The channel attention map M output by the channel attention module C Input into the spatial attention module, perform average pooling and maximum pooling operations in the channel dimension, and re-output two feature maps and , the two feature maps are spliced ​​in the channel dimension to obtain a spliced ​​spatial feature map, and the spliced ​​feature map is processed by a convolution layer to obtain a spatial attention map M s , M s The specific formula is: Ms(F)=σ(f 7×7 ([AvgPool(F);MaxPool(F)])); Among them, F is the feature map after channel attention weighting; AvgPool(F) and MaxPool(F) respectively represent the average pooling and maximum pooling operations in the channel dimension to obtain two feature maps of size H×W×1; [AvgPool(F);MaxPool(F)] means concatenating these two feature maps in the channel dimension to obtain a feature map of size H×W×2; f 7×7 represents a 7×7 convolution operation, which is used to fuse spatial information; σ is the sigmoid activation function.

5. According to the method for detecting magnetic leakage defects in long-distance pipelines based on improved YOLOv8 in claim 1, it is characterized in that: The defect types in the magnetic flux leakage defect image specifically include: flange, metal loss, weld defect and tee.

6. According to the method for detecting magnetic leakage defects in long-distance pipelines based on improved YOLOv8 in claim 1, it is characterized in that: The method also includes performing image enhancement after marking the magnetic leakage defect image.

7. A long-distance pipeline magnetic leakage defect detection system based on improved YOLOv8, characterized in that: include: The model building module is used to introduce a lightweight SPD-Conv module into the backbone network of the original YOLOv8 network model, add a CBAM attention module into the neck structure, and replace the loss function in the original model with the ECIOU_LOSS loss function to form an improved YOLOv8 model; A training module is used to obtain a magnetic flux leakage defect image of a long-distance oil and gas pipeline, annotate the magnetic flux leakage defect image to obtain a training set, input the data in the training set into the improved YOLOv8 model to train the model, and obtain a pipeline detection model; A detection module is used to input the image of the long-distance oil and gas pipeline to be detected into the pipeline detection model, convert the spatial information of the image into depth information through the SPD-Conv module and output a feature image after convolution, input the feature image into the CBAM attention module, perform average pooling and maximum pooling operations in the spatial dimension and channel dimension, and output an attention feature map; The defect information and defect location are marked in the attention feature map, and an image of the long-distance oil and gas pipeline to be inspected with the defect information and defect location is output.

8. A computer device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is loaded into a processor, it can execute the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Pipeline magnetic flux leakage internal detection method and system and related components

    CN115457391A

  • Pipeline circumferential weld defect identification method and device

    CN118088943A

Cited By

  • Ultra-light natural gas pipeline weld defect detection method and system

    CN119942096A

  • Pipeline magnetic flux leakage signal detection method and system, and electronic equipment

    CN120275490A

  • Pipeline magnetic leakage signal detection method, system, and electronic equipment

    CN120275490B

  • Target detection method and device based on infrared image, equipment and storage medium

    CN120953593A

  • Visual inspection method and device for stud welding threaded surface

    CN121258871A