Petroleum pipeline magnetic flux leakage defect detection method based on DSN-Y0L0v5
By constructing the DSN-Y0L0v5 network model, combining NextViT backbone network, neck feature fusion network and DyHead detection head network, the problem of low detection accuracy of defects in the oil pipeline leakage magnetic signal curve expression is solved, and higher detection accuracy and speed are achieved.
Patent Information
- Application Number
- CN202411985949.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-29
AI Technical Summary
The prior art is poor when detecting defects in the leakage magnetic signal curve expression in oil pipelines, resulting in low detection accuracy.
The DSN-Y0L0v5-based magnetic leakage defect detection method is adopted. By constructing a DSN-Y0L0v5 network model, including NextViT backbone network, neck feature fusion network and DyHead detection head network, combined with SA attention mechanism module and deformable convolution, the model's detection ability of magnetic leakage defects is improved.
The accuracy and speed of detection of magnetic leakage defects in oil pipelines has been significantly improved, especially when dealing with defects that are not obvious in the leakage signal curve, the detection accuracy has been increased by nearly 10%.
Smart Images

Figure BDA0005222580800000041 
Figure BDA0005222580800000042 
Figure BDA0005222580800000043
Abstract
Description
Technical Field
[0001] The present application relates to the field of oil pipeline inner wall defect detection, and in particular to an oil pipeline magnetic leakage defect detection method based on DSN-Y0L0v5. Background Art
[0002] As an important infrastructure for the transportation of oil and natural gas, the background technology of oil pipelines involves many aspects such as material selection, manufacturing process, transportation technology, and detection technology. It plays an indispensable role and status in daily life and scientific and technological development.
[0003] Due to the long-term transportation of pipelines, it is easy to be damaged due to the environment or other reasons, such as corrosion, scratches from debris, etc. Once the pipeline is damaged, the inspection and testing work of the staff is a task that requires a lot of energy and money, and the detection accuracy is unstable. Therefore, the improvement of pipeline detection and troubleshooting is of great significance.
[0004] Magnetic leakage detection technology, as a non-destructive testing technology for pipeline inspection, is a technology that can perform target detection only under the electromagnetic effect of the target detection object, which meets the needs of troubleshooting and detecting problems inside the pipeline.
[0005] YOLOv5 is a model that focuses on target detection, performing detection with high accuracy and speed. Although YOLOv5 performs well in detection, it requires longer training time and computing resources due to the large number of algorithm layers and operation parameters. The YOLOv5 model has some problems of high latency and low accuracy when performing some problems with unclear expressions caused by small defect features.
[0006] In the transportation of oil and gas pipelines, the amount of magnetic flux leakage detection data generated is also large due to the long length of the pipeline. If more traditional detection and identification methods are used, they rely heavily on the subjectivity and professionalism of the inspectors, and a lot of time and energy will be spent on actual detection. Therefore, an accurate and fast method is needed to detect and identify magnetic flux leakage defects. In recent years, the research on target detection algorithms in the field of deep learning has developed rapidly, and there has also been research and development on the combination with pipeline detection. The existing technology preprocesses the pipeline data and uses Cycle-GAN to enhance the data set. On the one hand, it can generate defect image expression capabilities, and on the other hand, it can expand the data set by expanding the amount of data. Finally, the Transformer and the algorithm are combined to greatly improve the detection accuracy of pipeline inner wall defects; the Comsol simulation and YOLO are combined, and the leakage magnetic environment simulation is performed through the Comsol software to realize the augmentation of simulated leakage magnetic defect detection data, and SPD-Conv is introduced in the YOLO algorithm to downsample the image to effectively save the image data. Finally, the improved C3 network is introduced in the backbone network of FSDDNet, which reduces the amount of network calculation and improves the detection speed. Finally, the detection accuracy of defects in the improved leakage magnetic defect detection model is improved by nearly 10% compared with the original model. However, the above methods have improved the effect in the field of defect detection, but they are not effective for defects where the leakage magnetic signal curve is not obvious, thus affecting the final detection accuracy. Summary of the invention
[0007] The purpose of the embodiment of the present application is to provide a method for detecting magnetic leakage defects in oil pipelines based on DSN-Y0L0v5, so as to solve the problem that the prior art has poor effect on defects where the magnetic leakage signal curve is not obvious, thereby affecting the final detection accuracy.
[0008] In order to solve the above technical problems, the embodiments of the present application provide the following technical solutions:
[0009] The present application provides a method for detecting magnetic leakage defects in oil pipelines based on DSN-Y0L0v5, which is characterized by comprising the following steps:
[0010] Step 1, obtaining the image data of magnetic leakage defects of oil pipelines;
[0011] Step 2, marking and extracting the oil pipeline magnetic leakage defect image data in step 1, and saving the marked data points to prepare a data set;
[0012] Step 3, construct a DSN-Y0L0v5 network model, which includes: an input end, a backbone network, a neck feature fusion network, and a detection head network. The backbone network adopts the NextViT backbone network, and the neck feature fusion network is provided with an SA attention mechanism module and a deformable convolution. The detection head network adopts the DyHead network.
[0013] Step 4: input the image data processed in step 2 into the DSN-Y0L0v5 network model in step 3 for training, output the defects and their positions in the data image, and obtain the leakage magnetic curve detection model;
[0014] Step 4.1, inputting the processed magnetic leakage defect image data into the NextViT backbone network through the input end for upsampling to obtain feature data graphs of different sizes;
[0015] Step 4.2, inputting the minimum size feature data map output in step 4.1 into the neck feature fusion network for multiple upsampling, and performing multi-scale feature fusion on the feature data map after multiple upsampling in step 4.2 and the feature map of the same size output in step 4.1;
[0016] Step 4.3: Input the data output from step 4.2 into the DyHead network, integrate the attention mechanism through the DyHead network, and output the defects in the final magnetic leakage image and the locations of the defects in the detection image.
[0017] In some modified implementations of the present application, the NextViT backbone network includes a Patch Embedding module, an NCB module, an NTB module, a BN module, a global pooling operation and a fully connected layer. The image is first segmented and extracted through the Patch Embedding module, and then passes through the NCB module and the NTB module in sequence; then passes through the BN module, and the global pooling operation is performed after the output of the BN module to extract the channel information of the feature map and generate a channel identifier; finally, the fully connected layer accurately locates and classifies the target feature points identified in the processed data.
[0018] In some modified implementations of the present application, the Patch Embedding module processes image data including the following steps:
[0019] Lift the image block and divide the data image into several blocks of fixed size;
[0020] Linear transformation, each of the blocks is converted into a vector through a linear transformation.
[0021] In some modified implementations of the present application, the NCB module includes: multi-head convolutional attention and a multi-layer perception layer. The multi-head convolutional attention groups the data image processed by the Patch Embedding module for 3×3 convolution, and the result is mean-normalized through the BN layer and input into the activation function ReLU, and finally output through 1×1 convolution. The last layer of the NCB module is input into the first multi-layer perception layer, and the complex model of the input image data is captured and learned through the hidden layer, and finally the final prediction result is output.
[0022] In some modified implementations of the present application, the NTB module includes two 1×1 convolutions that sequentially process image data, respectively combined with efficient multi-head self-attention and multi-head convolutional attention, and a multi-layer perception layer; first, the 1×1 convolution of the data image is used to detect the contours and compilation of the features in the image, and then on the one hand, it is input into the convolution layer of the next layer, and on the other hand, it is input into the efficient multi-head self-attention or multi-head convolutional attention for feature enhancement processing, and the features are resolved in turn, and finally the multi-layer perception layer outputs the results.
[0023] In some modified implementations of the present application, the neck feature fusion network includes a convolution operation and a Concat layer, and the convolution operation is performed on the image data to extract features in the image. The Concat layer splices feature maps of different levels in a certain dimension to achieve feature fusion, thereby enabling the model to capture a more comprehensive feature representation.
[0024] In some modified implementations of the present application, the SA attention mechanism module is arranged after the first convolution operation of the neck feature fusion network to perform a more comprehensive recognition of the features in the magnetic leakage defect detection image of the Concat layer to transmit them to the following feature processing layer.
[0025] In some modified implementations of the present application, the deformable convolution is arranged behind the SA attention mechanism module, and feature enhancement processing is performed on the feature information of the leakage magnetic defect detection image data, and the leakage magnetic image processing of the fusion layer processed by the SA attention mechanism module is output to the next layer of convolution of different image scales.
[0026] In some modified implementations of the present application, the data images of three sizes output by the neck feature fusion network are input into the DyHead network, and the DyHead network integrates the attention mechanism in three dimensions of feature level, spatial position and output channel, and outputs the final detection result in the detection image.
[0027] In some modified implementations of the present application, the following steps are also included:
[0028] Step 5: Load the optimal weight file in step 4 into the DSN-Y0L0v5 network model in step 3 to perform reasoning detection to obtain the defect information status in the image to be detected;
[0029] Step 5.1, upload the produced magnetic flux leakage defect image to be detected to the model file, load the pre-trained weight file into the DSN-Y0L0v5 network model to detect the location and status of the magnetic flux leakage defect data;
[0030] Step 5.2: Detect the evaluation indicators of the detection algorithm of the improved model. The specific indicators are as follows:
[0031]
[0032] In formula (1), Recall represents the recall rate, TP represents the number of samples that should be predicted as correct samples and have been determined to be correct samples in the test samples, and FN represents the number of samples that should be correctly predicted in the test samples but have not been predicted;
[0033]
[0034] In formula (2), Precision measures the proportion of positive samples predicted by the model that are actually positive samples, and FP represents the number of samples that are detected by mistake when they should not be detected.
[0035]
[0036] In formula (3), the F1 score is the harmonic mean of precision and recall, which provides a balanced evaluation between the two, taking into account both false positives (FP) and false negatives (FN). A high F1 score means that the model can effectively identify the target (high recall) when detecting objects, and can ensure that most of the identified targets are correct (high precision).
[0037]
[0038] In formula (4), mAP is the average precision of all categories, classes represents the number of categories divided in the data set, P(X) and D(X) represent the average precision of the Xth category, and mAP is obtained by calculating the Average Precision (AP) of each category and then averaging these AP values. AP is the area under the Precision-Recall curve of a category. In the object detection task, mAP measures the comprehensive performance of the model's detection accuracy and recall rate for different object categories.
[0039]
[0040] In formula (5), FPS means frames per second, which represents the processing time of each frame. This means that FPS is a measure of image processing speed, that is, how many frames of images the model can process in one second; the higher the FPS value, the faster the processing speed of the model.
[0041] Compared with the prior art, the oil pipeline magnetic leakage defect detection method based on DSN-Y0L0v5 provided in this application uses the NextViT network as the backbone network, and replaces the original CSPNet with the NextViT backbone network to reduce the number of parameters of the backbone network. On the basis of lightweight, it improves the detection speed and detection accuracy, and can better process target feature information of different scales;
[0042] The SA attention mechanism module and deformable convolution are set in the neck feature fusion network. The SA attention mechanism module is set to enhance the model's ability to extract different feature information and broaden the model's detection generalization; the deformable convolution module is used to enhance the model's robustness and different feature extraction capabilities;
[0043] Use the DYHead network as the detection head network and add a dynamic detection head to superimpose multiple attentions, such as scale-aware attention and space-aware attention, to enhance the detection performance of the model. While enhancing the ability to represent the features of the magnetic leakage image, it can also better solve the problem of unclear magnetic leakage defect images when the magnetic leakage defect is small.
[0044] The present invention can be applied to complex recognition tasks of magnetic flux leakage detection images of oil pipelines, and can greatly improve the detection accuracy compared with traditional detection methods and models, meeting the actual needs of magnetic flux leakage defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become easy to understand. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0046] Figure 1 The NextViT backbone network flow chart in the present invention is schematically shown;
[0047] Figure 2 The flowchart of the SA attention mechanism module in the present invention is schematically shown;
[0048] Figure 3 The flowchart of the DYHead network module in the present invention is schematically shown;
[0049] Figure 4The application framework structure diagram of the DYHead network module in the single-stage target detection algorithm in the present invention is schematically shown;
[0050] Figure 5 The network structure diagram of DSN-Y0L0v5 of the present invention is schematically shown;
[0051] Figure 6 The DSN-Y0L0v5 accuracy curve of the present invention is schematically shown;
[0052] Figure 7 The DSN-Y0L0v5 recall rate curve of the present invention is schematically shown;
[0053] Figure 8 The F1 curve of DSN-Y0L0v5 of the present invention is schematically shown;
[0054] Fig. 9 The PR curve diagram of DSN-Y0L0v5 of the present invention is schematically shown;
[0055] Fig.10 The result detection diagram of DSN-Y0L0v5 of the present invention is schematically shown. DETAILED DESCRIPTION
[0056] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0057] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should have the common meanings understood by technicians in the field to which this application belongs.
[0058] Example
[0059] like Figures 1 to 10 As shown, this embodiment provides a method for detecting magnetic leakage defects in oil pipelines based on DSN-Y0L0v5, comprising the following steps:
[0060] Step 1: Obtain the image data of magnetic leakage defects of oil pipelines.
[0061] Step 2: annotate and extract the oil pipeline magnetic leakage defect image data in step 1, and save the annotated data points to make a data set;
[0062] Specifically, the labelimg software is used to annotate and extract the defect point features of the enhanced defect data image, and the annotated data points are saved in a txt file as 640×640×3, and then the image is output to the YOLO adaptation detection format to make a data set. Among them, the data is processed, and image modifications such as color and angle are used to enhance the number and generalization of the data set; in order to solve the problem of low model detection accuracy caused by uneven distribution of feature expression points in small target detection, YOLO combines multiple random image processing methods such as random scaling and cropping of four randomly selected pictures to achieve Mosaic data enhancement, which can enrich the data set and reduce the GPU computing load.
[0063] Step 3, construct the DSN-Y0L0v5 network model; wherein, the DSN-Y0L0v5 network model includes: input end, backbone network, neck feature fusion network, detection head network, the backbone network adopts NextViT backbone network, the neck feature fusion network is set with SA attention mechanism module (shuffle attention mechanism) and deformable convolution (DCNv2), and the detection head network adopts DyHead network;
[0064] In the specific implementation, the backbone network adopts the NextViT backbone network, and the original CSPNet is changed to the NextViT backbone network, which reduces the number of parameters of the backbone network and improves the detection speed and detection accuracy; the SA attention mechanism module is set in the neck feature fusion network and the C3 module is replaced by DCNv2 to enhance the model robustness and the ability to extract different feature information; the detection head network adopts the DYHead network and adds a dynamic detection head to superimpose multiple attentions, such as scale-aware attention and space-aware attention, to enhance the detection performance of the model. While enhancing the feature representation capability of the leakage magnetic image, it can also better solve the problem of unclear leakage magnetic defect images caused by small leakage magnetic defects.
[0065] Specifically, the backbone network, neck feature fusion network and detection head network of the original model were improved, and the Y0L0v5 network structure model was debugged and improved to construct the DSN-Y0L0v5 network model and conduct model testing.
[0066] Step 4: Input the image data processed in step 2 into the DSN-Y0L0v5 network model in step 3 for training, output the defects and their locations in the data image, and obtain the leakage magnetic curve detection model.
[0067] Step 4.1: Input the magnetic leakage defect image processed in step 2 into the NextViT backbone network through the input end for upsampling to obtain feature data graphs of different sizes.
[0068] Preferably, the NextViT backbone network consists of four Patch Embedding modules, four NCB modules, four NTB modules, a BN module, a global pooling operation and an FC layer. The image data processed in step 2 is input into the first 3×3 convolution and then redesigned. After the convolution operation, the image is firstly passed through the Patch Embedding module for image segmentation and feature extraction, and then input into the NCB module, and the NTB module outputs. The NTB module inputs the data into the next convolution on the one hand, and inputs it into the Patch Embedding module for repeated operations or the BN module on the other hand, and outputs through the BN module, the global pooling operation and the FC layer.
[0069] Specifically, the Patch Embedding module divides the data image processed in step 2 into patches of fixed size. Each patch is converted into a vector of fixed dimension. This process includes two steps: Patch Extraction and Linear Projection. In the linear transformation step, each small patch is converted into a vector through a linear transformation so that the model can process image data more efficiently.
[0070] The NCB module includes a multi-head convolutional attention (MHCA) and a multi-layer perception layer (MLP). The PatchEmbedding module outputs data. The MHCA in the NCB module first groups the data image output by the Patch Embedding module for 3×3 convolution. The result is mean-normalized through the BN layer and input into the activation function ReLU. Finally, it is output through 1×1 convolution and input into the MLP in the NCB module at the last layer of the NCB module. The complex model of the input image data is captured and learned through the hidden layer, and finally the final prediction result is output. Among them, the NCB module deploys a friendly MHCA to capture short-term dependency information in visual data, so that the model can efficiently capture local features and high-frequency information.
[0071] The NTB module consists of three parts: two 1×1 convolutions, an efficient multi-head self-attention (E-MHSA), a combination of MHCA and a single MLP, which are connected in sequence to process image data; first, the 1×1 convolution of the data image is used to detect the contours and compile the features in the image, and then it is input into the convolution layer of the next layer on the one hand, and then input into the E-MHCA or MHCA in the NTB module on the other hand for processing, feature enhancement processing, and feature resolution processing in sequence, and finally the MLP in the NTB module outputs the result; among them, the NTB module is not only good at capturing long-term dependency information, but also acts as a lightweight high- and low-frequency signal mixer to enhance the modeling ability of the model.
[0072] After the Patch Embedding module, NCB module and NTB module repeat the operation, the BN module normalizes the data distribution before the activation function receives the input. The specific calculation is to normalize the mean and normalize the distribution of the data to the standard normal distribution, so that the input value of the activation function falls in the more sensitive area of the function, thereby accelerating the convergence of the network.
[0073] Global pooling operation is an important feature extraction method, which includes global maximum pooling (GlobalAverage Pooling, GAP) and global average pooling (Global Max Pooling, GMP). These two operations are performed after the final BN module outputs the data. They can effectively extract the channel information of the feature map and generate channel identifiers, which helps to improve the generalization ability of the model.
[0074] The FC layer (fully connected layer) is the last layer of the NextViT backbone network, which accurately locates and classifies the target feature points identified in the image data.
[0075] Step 4.2: Input the feature data map of the minimum size output by the backbone network in step 4.1 into the neck feature fusion network for multiple upsampling. The feature data map after multiple upsampling in step 4.2 and the feature map of the same size output by the backbone network in step 4.1 are subjected to multi-scale feature fusion.
[0076] Specifically, the neck feature fusion network mainly includes convolution operation and Concat layer. The convolution operation is performed on the image data to extract the features in the image, and the feature extraction process can be optimized by adjusting the convolution kernel size, step size and other parameters. The Concat layer can splice feature maps of different levels in a certain dimension to achieve feature fusion, so that the model can capture a more comprehensive feature representation.
[0077] In the specific implementation, a shuffle attention mechanism is added to the network part after the first convolution operation of the neck feature fusion network to enhance the model's ability to extract different feature information; the SA attention mechanism module is embedded in the first Concat layer of the backbone part to enhance the feature expression ability of the convolutional neural network. The SA attention mechanism groups the input feature images and uses the Shuffle unit to integrate the channel attention and spatial attention in a small block of each group. All sub-features are then aggregated through the Concat layer, and the channel shuffle calculation is used to communicate information between different sub-features, which enhances the model's ability to recognize information of sub-features of different categories and broadens the generalization of model detection.
[0078] In the specific implementation, DCNv2 is added to replace the C3 module after the original SA attention mechanism module. DCNv2 is set after the SA attention mechanism to increase the model's ability to pay attention to the feature points of the leakage magnetic image information. The DCNv2 module performs feature enhancement processing on the feature information of the leakage magnetic defect detection image data, reduces the parameter calculation of the original C3 module, and outputs the leakage magnetic image processing of the fusion layer processed by the SA attention mechanism to the next layer of convolution of different image scales.
[0079] Step 4.3: Input the size data output in step 4.2 into the detection head network. The detection head network integrates the attention mechanism in three dimensions: feature level, spatial position and output channel. The feature expression of the large target, medium target and small target detection heads for the magnetic leakage image is enhanced to improve the detection performance of the magnetic leakage defect image. The defects in the final magnetic leakage image and the location of the defects are output in the detection image.
[0080] Specifically, the detection head network uses the DyHead detection head, which is mainly composed of scale-aware attention (π L ), spatial perception attention (π s ) and task-level attention (π c ) are composed of several parts, among which scale-aware attention can be dynamically integrated according to the semantic importance of features of different scales, while spatial-aware attention makes attention learning sparse by using deformable convolutions and then aggregates features of different levels at the same spatial position. Task-level attention can dynamically switch feature switch channels to support running different tasks; the DyHead detection head enables the model to significantly improve the performance of target detection without increasing the amount of parameter calculation;
[0081] As a target detection head network, the DyHead detection head is used differently in single-stage or multi-stage target detection deep learning algorithms. Figure 4 As shown in the figure, it is a framework model applied to the single-stage detection model, in which several scale-aware attention (π L ), spatial perception attention (π s ) and task-level attention (π c ) is a three-part module that realizes the representation capabilities of different tasks, such as classification, center box regression, etc.
[0082] like Figure 1As shown in the flow of the DSN-Y0L0v5 network model in this embodiment, in the NextViT backbone network, the magnetic leakage defect image data after the processing in step 2 is input into the first 3×3 convolution through the input end (Input) and then redesigned. After the convolution operation, the Patch Embedding module first segments and extracts features of the image, and then outputs it through the 1×1 convolution of the NCB module; the 1×1 convolution in the NTB module is input to the next convolution layer on the one hand to obtain the first upsampling, and on the other hand, it is output through the Patch Embedding module. The Embedding module performs image segmentation and feature extraction, and the output is output through 1×1 convolution of the NCB module. The 1×1 convolution in the NTB module is input to the next convolution layer on the one hand to obtain the second upsampling, and then the PatchEmbedding module performs image segmentation and feature extraction, and the output is output through 1×1 convolution of the NCB module. The data output by the NTB module is then subjected to mean normalization, global pooling operation and FC layer by the BN module. Finally, the output data is input to the next convolution layer on the one hand to obtain the third upsampling; on the other hand, it is input into the face and neck feature fusion network for operation. The first upsampling, the second upsampling and the third upsampling in the NextViT backbone network are multi-scale feature fused with the feature maps of the same size after multiple upsampling in the face and neck feature fusion network, so that the face and neck feature fusion network outputs data images of three sizes; finally, the data images of three sizes are input into the DyHead network, and the DyHead network integrates the attention mechanism in the three dimensions of feature level, spatial position and output channel, and outputs the final detection result in the detection image.
[0083] Step 5: Load the optimal weight file best.pt in step 4 into the DSN-Y0L0v5 network model for reasoning detection to obtain the defect information status in the image to be detected; use precision and mean average precision (mAP) as evaluation indicators of the detection algorithm. The specific indicators are as follows:
[0084] Step 5.1, upload the produced magnetic flux leakage defect image to be detected to the model file, load the pre-trained weight best.pt into the DSN-Y0L0v5 network model to detect the location and status of the magnetic flux leakage defect data.
[0085] Step 5.2: Use Precision, mAP, FPS, etc. as evaluation indicators for the improved model;
[0086] The specific rating indicators are as follows:
[0087]
[0088] In formula (1), Recall represents the recall rate. The recall rate curve in this embodiment is as follows: Figure 7 As shown; TP represents the number of samples that should be predicted as correct samples and have been determined to be correct samples in the test samples, and FN represents the number of samples that should be correctly predicted samples in the test samples but have not been predicted.
[0089]
[0090] In formula (2), Precision measures the proportion of positive samples predicted by the model that are actually positive samples. The accuracy curve (Precision curve) in this embodiment is as follows: Figure 6 As shown; FP represents the number of samples that are detected by mistake but should not be detected.
[0091]
[0092] In formula (3), the F1 score is the harmonic mean of precision and recall. In this embodiment, the F1 curve is as follows: Figure 8 As shown in Figure 2, it provides a balanced evaluation between the two, taking into account both false positives (FP) and false negatives (FN). A high F1 score means that the model can effectively identify the target (high recall) when detecting objects, while ensuring that most of the identified targets are correct (high precision).
[0093]
[0094] In formula (4), mAP is the average precision of all categories, classes represents the number of categories divided in the data set, P(X) and D(X) represent the average precision of the Xth category, and mAP is obtained by calculating the Average Precision (AP) of each category and then averaging these AP values. AP is the area under the Precision-Recall curve of a category. In the object detection task, mAP measures the comprehensive performance of the model's detection accuracy and recall rate for different object categories.
[0095]
[0096] In formula (5), FPS means frames per second, which represents the processing time of each frame. This means that FPS is a measure of image processing speed, that is, how many frames of images the model can process in one second. The higher the FPS value, the faster the model's processing speed.
[0097] Experimental verification:
[0098] The dataset is used to perform magnetic flux leakage defect detection in the improved DSN-Y0L0v5.
[0099] When training the model, the computer graphics card is RTX 3090, the system memory is 316G, the language is python3.8, the deep learning framework is pytorch 2.0.0, and the prepared magnetic leakage defect dataset is input into the DSN-Y0L0v5 network structure for detection training. The model is trained according to the training set: validation set ratio of 7:3. The epoch is set to 100, the batch size is set to 4, the initial learning rate is set to 0.01, and the IOU threshold is set to 0.5.
[0100] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for detecting magnetic leakage defects in oil pipelines based on DSN-Y0L0v5, characterized in that: The following steps are involved: Step 1, obtaining the image data of magnetic leakage defects of oil pipelines; Step 2, marking and extracting the oil pipeline magnetic leakage defect image data in step 1, and saving the marked data points to prepare a data set; Step 3, construct a DSN-Y0L0v5 network model, which includes: an input end, a backbone network, a neck feature fusion network, and a detection head network. The backbone network adopts the NextViT backbone network, and the neck feature fusion network is provided with an SA attention mechanism module and a deformable convolution. The detection head network adopts the DyHead network. Step 4: input the image data processed in step 2 into the DSN-Y0L0v5 network model in step 3 for training, output the defects and their positions in the data image, and obtain the leakage magnetic curve detection model; Step 4.1, inputting the processed magnetic flux leakage defect image data into the NextViT backbone network through the input end for upsampling to obtain feature data graphs of different sizes; Step 4.2, inputting the minimum size feature data map output in step 4.1 into the neck feature fusion network for multiple upsampling, and performing multi-scale feature fusion on the feature data map after multiple upsampling in step 4.2 and the feature map of the same size output in step 4.1; Step 4.3: Input the data output from step 4.2 into the DyHead network, integrate the attention mechanism through the DyHead network, and output the defects in the final magnetic leakage image and the locations of the defects in the detection image.
2. The method for detecting magnetic flux leakage defects in oil pipelines based on DSN-Y0L0v5 as claimed in claim 1, characterized in that: The NextViT backbone network includes a Patch Embedding module, an NCB module, an NTB module, a BN module, a global pooling operation and a fully connected layer. The image is first segmented and extracted through the Patch Embedding module, and then sequentially through the NCB module and the NTB module; then through the BN module, the global pooling operation is performed after the output of the BN module to extract the channel information of the feature map and generate a channel identifier; finally, the fully connected layer accurately locates and classifies the target feature points identified in the processed data.
3. The method for detecting magnetic flux leakage defects in oil pipelines based on DSN-Y0L0v5 as claimed in claim 2, characterized in that: The Patch Embedding module processes image data including the following steps: Lift the image block and divide the data image into several blocks of fixed size; Linear transformation, each of the blocks is converted into a vector through a linear transformation.
4. The method for detecting magnetic flux leakage defects in oil pipelines based on DSN-Y0L0v5 as claimed in claim 2, characterized in that: The NCB module includes: a multi-head convolutional attention and a multi-layer perception layer. The multi-head convolutional attention groups the data image processed by the PatchEmbedding module for 3×3 convolution. The result is mean-normalized through the BN layer and input into the activation function ReLU. Finally, it is output through 1×1 convolution. The last layer of the NCB module is input into the first multi-layer perception layer, and the complex model of the input image data is captured and learned through the hidden layer, and finally the final prediction result is output.
5. The method for detecting magnetic flux leakage defects in oil pipelines based on DSN-Y0L0v5 as claimed in claim 2, characterized in that: The NTB module includes two 1×1 convolutions that sequentially process image data, respectively combined with efficient multi-head self-attention and multi-head convolutional attention, and a multi-layer perception layer; first, the 1×1 convolution of the data image is used to detect the contours and compile the features in the image, and then it is input into the convolution layer of the next layer on the one hand, and then it is input into the efficient multi-head self-attention or multi-head convolutional attention on the other hand for feature enhancement processing, and the features are distinguished and processed in turn, and finally the result is output by the multi-layer perception layer.
6. The method for detecting magnetic flux leakage defects in oil pipelines based on DSN-Y0L0v5 as claimed in claim 1, characterized in that: The neck feature fusion network includes a convolution operation and a Concat layer. The convolution operation is performed on the image data to extract features in the image. The Concat layer splices feature maps of different levels in a certain dimension to achieve feature fusion, so that the model captures a more comprehensive feature representation.
7. The method for detecting magnetic flux leakage defects in oil pipelines based on DSN-Y0L0v5 as claimed in claim 6, characterized in that: The SA attention mechanism module is arranged after the first convolution operation of the neck feature fusion network, and performs a more comprehensive recognition of the features in the magnetic leakage defect detection image of the Concat layer to transmit them to the following feature processing layer.
8. The method for detecting magnetic flux leakage defects in oil pipelines based on DSN-Y0L0v5 as claimed in claim 1, characterized in that: The deformable convolution is arranged behind the SA attention mechanism module, and the feature information of the leakage magnetic defect detection image data is enhanced, and the leakage magnetic image processing of the fusion layer processed by the SA attention mechanism module is output to the next layer of convolution with different image scales.
9. The method for detecting magnetic flux leakage defects in oil pipelines based on DSN-Y0L0v5 as claimed in claim 1, characterized in that: The data images of three sizes output by the neck feature fusion network are input into the DyHead network. The DyHead network integrates the attention mechanism in three dimensions of feature level, spatial position and output channel, and outputs the final detection result in the detection image.
10. The method for detecting magnetic flux leakage defects in oil pipelines based on DSN-Y0L0v5 as claimed in claim 1, characterized in that: The following steps are also included: Step 5: Load the optimal weight file in step 4 into the DSN-Y0L0v5 network model in step 3 to perform reasoning detection to obtain the defect information status in the image to be detected; Step 5.1, upload the produced magnetic flux leakage defect image to be detected to the model file, load the pre-trained weight file into the DSN-Y0L0v5 network model to detect the location and status of the magnetic flux leakage defect data; Step 5.2: Detect the evaluation indicators of the detection algorithm of the improved model. The specific indicators are as follows: In formula (1), Recall represents the recall rate, TP represents the number of samples that should be predicted as correct samples and have been determined to be correct samples in the test samples, and FN represents the number of samples that should be correctly predicted in the test samples but have not been predicted; In formula (2), Precision measures the proportion of positive samples predicted by the model that are actually positive samples, and FP represents the number of samples that are detected by mistake when they should not be detected. In formula (3), the F1 score is the harmonic mean of precision and recall, which provides a balanced evaluation between the two, taking into account both false positives and false negatives. A high F1 score means that the model can effectively identify the target when detecting objects, and ensure that most of the identified targets are correct. In formula (4), mAP is the average precision of all categories, classes represents the number of categories divided in the data set, P(X) and D(X) represent the average precision of the Xth category, and mAP is obtained by calculating the Average Precision (AP) of each category and then averaging these AP values. AP is the area under the Precision-Recall curve of a category. In the object detection task, mAP measures the comprehensive performance of the model's detection accuracy and recall rate for different object categories. In formula (5), FPS means frames per second, which represents the processing time of each frame. This means that FPS is a measure of image processing speed, that is, how many frames of images the model can process in one second; the higher the FPS value, the faster the processing speed of the model.