Pipeline magnetic flux leakage multi-class feature detection method
Patent Information
- Application Number
- CN202611108895.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-24
- Publication Date
- 2026-10-16
AI Technical Summary
[0012]本申请提供一种管路漏磁多类别特征检测方法,以解决现有技术中缺少对管路中不同位置均进行有效且精准的缺陷检测的问题
[0023]As described above, this application provides a multi-category feature detection method for pipeline magnetic flux leakage. The method includes acquiring a target magnetic flux leakage image of the pipeline after circumferential data enhancement; constructing a target improved network model; and using the target improved network model to perform feature detection on the target magnetic flux leakage image to obtain a target detection result. The target improved network model includes a circumferential position encoding module, a multi-scale fusion module, and a hierarchical weakly supervised loss calculation module. The circumferential position encoding module is configured to perform multi-level position encoding on the corresponding features of the target magnetic flux leakage image. The multi-scale fusion module is configured to perform feature fusion based on dynamic weights on multiple features after multi-level position encoding. The hierarchical weakly supervised loss calculation module is configured to perform loss constraint calculation on pipeline metal corrosion using a corrosion category inclusion method during the training process of the target improved network model. This application solves the problem in the prior art of lacking effective and accurate defect detection at different locations in pipelines through the above system.
Smart Images

Figure CN122926205A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of pipeline magnetic flux leakage detection technology, and in particular to a method for detecting multiple types of pipeline magnetic flux leakage characteristics. Background Technology
[0002] As the lifeline of energy transmission, pipelines' structural integrity and operational safety directly impact environmental protection and the stability of energy supply. In the field of industrial non-destructive testing, magnetic flux leakage (MFL) testing technology has become a core method for assessing pipeline condition due to its strong adaptability and high testing efficiency. The basic principle of this technology is to saturate the pipe wall with permanent magnets or electromagnets. When there are variations in pipe wall thickness or geometric discontinuities, the magnetic field lines will distort and leak out of the pipe. A high-precision sensor array arranged in the magnetic circuit can collect these distorted signals, forming MFL data reflecting the pipeline's health status. By visualizing these signals (such as pseudo-color mapping), the recognizability of pipeline features in terms of color distribution and morphological characteristics can be further enhanced, providing a data foundation for subsequent intelligent identification.
[0003] A complete long-distance pipeline contains complex structural features and defect types. Broadly defined, pipeline features include both damage-related features that threaten pipeline safety (such as metal loss and weld abnormalities) and features of key components used for mileage location and risk warning (such as elbows, valves, tees, sleeves, flanges, and various welds). These features exhibit complex manifestations in magnetic flux leakage signal images, making AI-based automated identification an inevitable trend in the industry.
[0004] However, the inherent properties of multi-class features of pipelines pose a serious challenge to deep learning-based visual detection methods, mainly in the following three aspects: Extreme imbalance in data distribution: In real pipeline data, damage features (especially minor corrosion) are overwhelmingly dominant in number, exhibiting a "long-tail distribution" characteristic. Although the number of key component features at the tail end is sparse, their importance for location and safety assessment is extremely high, and conventional data balancing strategies often fail to work.
[0005] The vast range of feature scales: The scale differences between different target categories are significant. Damage features are typically small targets at the pixel level, while critical components (such as large valves and tees) may occupy most of the entire image. This huge scale difference places extremely high demands on the receptive field design of the detection model.
[0006] The challenge of detecting small and dense targets: Damage features are not only small in scale and weak in signal, but also often exhibit a dense distribution (such as corrosion clusters). This not only makes manual annotation extremely difficult, easily leading to annotation errors or fuzzy annotations, but also makes it difficult for the model to distinguish individual boundaries during the learning process, resulting in missed or false detections.
[0007] To address the aforementioned challenges, existing technologies typically employ the following technical approaches, but significant limitations still exist: 1. Location coding and feature enhancement techniques Existing position-aware methods largely rely on introducing global self-attention mechanisms or simple two-dimensional coordinate mappings, attempting to enhance feature representation through implicit height and width information. However, these methods fail to fully incorporate the inherent physical characteristics of magnetic flux leakage images. Magnetic flux leakage signals exhibit specific physical distribution patterns along the circumferential and axial directions of the pipe. Simply relying on general position encoding strategies cannot explicitly utilize this prior knowledge, resulting in insufficient robustness of the model when handling overlapping or adjacent features. Furthermore, employing a single position encoding strategy for feature maps at different levels makes it difficult to simultaneously address the positional information requirements of both deep semantics and shallow details.
[0008] 2. Supervision Paradigm Based on YOLO Architecture Current mainstream object detection frameworks mostly employ a fully supervised learning paradigm, heavily relying on large-scale, high-quality, and accurately labeled data. To alleviate the labeling pressure, some techniques attempt to introduce weak or semi-supervised mechanisms, such as using class activation heatmaps for iterative optimization. However, these methods are still limited by "label-level" supervision signals. In pipeline scenarios, due to the lack of accurate bounding box annotations for many damage features (only image-level or blurry region-level annotations), traditional supervised paradigms cannot effectively utilize this massive but coarsely labeled data, resulting in limited model generalization ability.
[0009] 3. Utilization of prior knowledge of pipeline characteristics Although existing research has attempted to mine the statistical distribution of pipeline features in terms of location and size, misconceptions still exist in practical applications. For example, current techniques often model "metal corrosion" and "corrosion clusters" as two separate categories. From the perspective of feature space, corrosion clusters are essentially aggregations of multiple minute corrosion features, and the two are highly similar in semantic features. Forcibly separating them into independent categories will artificially increase the distance in the feature space, causing confusion in the classifier and reducing the recognition accuracy of head features (high-frequency features).
[0010] 4. Efficiency bottleneck of serial processing of multiple models Given the significant scale gap between damage characteristics and component characteristics, current engineering practices often necessitate the design of two independent detection models: one specifically for small-target damage detection and the other for large-scale component identification. In actual data analysis workflows, these two models must be run sequentially. This separate architecture not only increases system complexity but also drastically reduces data processing efficiency, making it difficult to meet the real-time analysis requirements of massive amounts of data from long-distance pipelines.
[0011] 5. Lack of prior knowledge of spatial location More importantly, existing deep learning methods often overlook the physical distribution patterns of pipe features in the spatial dimension. In reality, different types of pipe features exhibit significant clustering characteristics in the vertical direction of the image (corresponding to the circumferential direction of the pipe). For example, due to gravity, external supports and depositional damage are mostly concentrated at the bottom of the pipe; while structural features such as branches and tees are specifically distributed at the top or sides of the pipe. Most current detection algorithms treat these features as randomly distributed, failing to incorporate this highly discriminative spatial prior information into the model design, thus limiting further improvements in recognition accuracy. Summary of the Invention
[0012] This application provides a method for detecting multiple categories of magnetic flux leakage characteristics in pipelines, in order to solve the problem that existing technologies lack effective and accurate defect detection at different locations in pipelines.
[0013] The system includes: Acquire a target magnetic flux leakage image of the pipeline through circumferential data enhancement; An improved target network model is constructed, and the improved target network model is used to perform feature detection on the target magnetic flux leakage image to obtain the target detection result. The improved target network model includes a circumferential position encoding module, a multi-scale fusion module, and a hierarchical weakly supervised loss calculation module. The circumferential position encoding module is configured to perform multi-level position encoding on the corresponding features of the target magnetic flux leakage image. The multi-scale fusion module is configured to perform feature fusion based on dynamic weights on multiple features after multi-level position encoding. The hierarchical weakly supervised loss calculation module is configured to perform loss constraint calculation on pipeline metal corrosion using a corrosion category inclusion method during the training process of the improved target network model.
[0014] In some embodiments, the step of acquiring a target magnetic flux leakage image of the pipeline after circumferential data enhancement includes: Obtain the original magnetic flux leakage image inside the pipeline; The original magnetic flux leakage image is subjected to circumferential data augmentation to obtain the target magnetic flux leakage image.
[0015] In some embodiments, the step of performing circumferential data augmentation on the original magnetic flux leakage image includes: Extract the top position region, bottom position region, and effective position region from the original magnetic flux leakage image; the effective position region is located between the top position region and the bottom position region; The positions of the top and bottom regions are swapped, and the original magnetic flux leakage image is used to replace the effective region to obtain the target magnetic flux leakage image.
[0016] In some implementations, the construction of the target improved network model further includes a backbone network module, a feature fusion mesh module, and a detection head network module; the circumferential position encoding module is disposed between the backbone network module and the feature fusion mesh module; the multi-scale fusion module is disposed between the feature fusion mesh module and the detection head network module; and the hierarchical weak supervision loss calculation module is disposed after the detection head network module.
[0017] In some implementations, the backbone network module includes several conventional convolutional layers, several gradient residual layers, and pooling layers; The feature fusion mesh module includes several regular convolutional layers, several gradient residual layers, several splicing layers, and several upsampling layers; The detection head network module includes a small target detection head, a medium target detection head, and a large target detection head; each of the small target detection head, the medium target detection head, and the large target detection head includes several one-dimensional convolutional units, two-dimensional convolutional units, rectangular box loss calculation units, and classification loss calculation units.
[0018] In some implementations, the conventional convolutional layer includes a one-dimensional convolutional unit, a batch processing unit, and an activation function unit; The gradient residual layer includes a one-dimensional convolutional unit, a slicing unit, several partial convolutional units, and a splicing unit; The pooling layer includes a one-dimensional convolutional unit, several max pooling units, and splicing units.
[0019] In some implementations, the partial convolutional unit includes several one-dimensional convolutional units, a residual connection determination unit, and a stacking unit.
[0020] In some embodiments, the circumferential position encoding module includes: The small target circumferential position encoding module is configured to perform position encoding on the pipeline, including metal corrosion and corrosion clusters, based on circumferential position, clock position and reserved position. The target circumferential position encoding module is configured to perform position encoding on the pipeline, including branch pipes, tees and sleeves, based on clock position and reserved position. A large target circumferential position encoding module is configured to perform position encoding on pipelines, including elbows, tees, and periodic welds, based on clock position and mileage position.
[0021] In some implementations, the hierarchical weak supervision loss calculation module is further configured to: During the training of the target improved network model, the location information of the corrosion cluster and the quantity of metal corrosion are used to design a loss function to constrain the training of the target improved network model in real time; the metal corrosion is included in the corrosion cluster; the training status includes the current positioning accuracy of the metal corrosion area and the predicted quantity of metal corrosion in the area.
[0022] In some implementations, the multi-scale fusion module includes a global feature aggregation layer, a lightweight category embedding layer, a dynamic weight feature layer, and a splicing layer; The multi-scale fusion module is configured as follows: The global feature aggregation layer performs global average pooling on the features output by the small target circumferential position encoding module, the medium target circumferential position encoding module, and the large target circumferential position encoding module to extract semantic statistics. The semantic statistics are concatenated into a global feature vector through the concatenation layer, and the scale preference is embedded in each category learning using the lightweight category embedding layer. The dynamic weight feature layer generates several category dynamic weights based on the scale preference and the global feature vector, and performs weighted fusion and upsampling alignment based on the category weights to generate dedicated scale prior features. The corresponding dedicated scale prior features are then input into the small target circumferential position encoding module, the medium target circumferential position encoding module, and the large target circumferential position encoding module.
[0023] As described above, this application provides a multi-category feature detection method for pipeline magnetic flux leakage. The method includes acquiring a target magnetic flux leakage image of the pipeline after circumferential data enhancement; constructing a target improved network model; and using the target improved network model to perform feature detection on the target magnetic flux leakage image to obtain a target detection result. The target improved network model includes a circumferential position encoding module, a multi-scale fusion module, and a hierarchical weakly supervised loss calculation module. The circumferential position encoding module is configured to perform multi-level position encoding on the corresponding features of the target magnetic flux leakage image. The multi-scale fusion module is configured to perform feature fusion based on dynamic weights on multiple features after multi-level position encoding. The hierarchical weakly supervised loss calculation module is configured to perform loss constraint calculation on pipeline metal corrosion using a corrosion category inclusion method during the training process of the target improved network model. This application solves the problem in the prior art of lacking effective and accurate defect detection at different locations in pipelines through the above system. Attached Figure Description
[0024] To more clearly illustrate the technical solution of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is a flowchart of a pipeline leakage magnetic flux multi-category feature detection method according to this application; Figure 2 This is a flowchart of the method for obtaining target magnetic flux leakage images in a pipeline magnetic flux leakage multi-category feature detection method of this application; Figure 3 This is a flowchart illustrating circumferential data augmentation in a pipeline leakage magnetic flux multi-category feature detection method according to this application; Figure 4 This is a schematic diagram of the target improved network model in the pipeline leakage magnetic flux multi-category feature detection method of this application; Figure 5 This is a schematic diagram of the gradient residual layer in the pipeline leakage magnetic flux multi-category feature detection method of this application; Figure 6 This is a schematic diagram of a conventional convolutional layer in a pipeline leakage magnetic flux multi-category feature detection method of this application; Figure 7 This is a schematic diagram of the pooling layer in the pipeline leakage magnetic flux multi-category feature detection method of this application; Figure 8 This is a schematic diagram of the target detection head in a pipeline leakage magnetic flux multi-category feature detection method of this application; Figure 9 This is a schematic diagram of some convolutional layers in a pipeline leakage magnetic flux multi-category feature detection method of this application; Figure 10 This is a schematic diagram of the small target circumferential position encoding module in the pipeline leakage magnetic flux multi-category feature detection method of this application; Figure 11 This is a schematic diagram of the target circumferential position encoding module in the pipeline leakage magnetic flux multi-category feature detection method of this application; Figure 12 This is a schematic diagram of the circumferential position encoding module of a pipeline leakage magnetic flux multi-category feature detection method of this application; Figure 13 This is a schematic diagram of the multi-scale fusion module in the pipeline leakage magnetic flux multi-category feature detection method of this application; Figure 14 This is a schematic diagram of the circumferential data enhancement principle in the pipeline leakage magnetic flux multi-category feature detection method of this application. Detailed Implementation
[0026] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0027] It should be noted that the brief descriptions of terms in this application are only for the convenience of understanding the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise stated, these terms should be understood in their ordinary and common meaning.
[0028] It should be noted that, in this application, the terms "exemplary" or "for example" are used to indicate that something is being described as an example, illustration, or illustration. Any embodiment or design described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0029] See Figure 1 As can be seen, this embodiment provides a method for detecting multiple categories of pipeline leakage magnetic flux characteristics, the method comprising: S110, acquire the target magnetic flux leakage image of the pipeline through circumferential data enhancement.
[0030] Specifically, in this embodiment, the target magnetic flux leakage image is pre-acquired for feature detection.
[0031] The target magnetic flux leakage image is an image enhanced with circumferential data.
[0032] See Figure 2It can be seen that, further, in some embodiments, the step of acquiring the target magnetic flux leakage image of the pipeline after circumferential data enhancement includes: S210, Obtain the original magnetic flux leakage image inside the pipeline; S220, perform circumferential data enhancement on the original magnetic flux leakage image to obtain the target magnetic flux leakage image.
[0033] Specifically, in this embodiment, the original magnetic flux leakage image inside the pipeline is first acquired, and the original magnetic flux leakage image is then subjected to circumferential data enhancement to obtain the target magnetic flux leakage image.
[0034] See Figure 3 It is understood that, further, in some embodiments, the step of performing circumferential data enhancement on the original magnetic flux leakage image includes: S310, the top position region, bottom position region, and effective position region in the original magnetic flux leakage image are extracted by the circumferential data enhancement module; the effective position region is located between the top position region and the bottom position region; S320, the top position region and the bottom position region are swapped by the circumferential data enhancement module, and the original magnetic flux leakage image is used to replace the effective position region to obtain the target magnetic flux leakage image.
[0035] Specifically, in this embodiment, before the original image enters the detection network, circumferential enhancement is performed on the image to simulate the natural circumferential structure of the pipe, preventing incomplete or broken features at the 0 o'clock and 12 o'clock positions. This is represented in the image as the upper and lower boundaries being physically connected. Using this prior knowledge, the image is supplemented, and the specific operation is as follows: Figure 14 As shown.
[0036] The method also includes S120, Construct a target improvement network model, and use the target improvement network model to perform feature detection on the target magnetic flux leakage image to obtain target detection results; the target improvement network model includes a circumferential position encoding module, a multi-scale fusion module, and a hierarchical weakly supervised loss calculation module; the circumferential position encoding module is configured to perform multi-level position encoding on the corresponding features of the target magnetic flux leakage image; the multi-scale fusion module is configured to perform feature fusion based on dynamic weights on multiple features after multi-level position encoding; the hierarchical weakly supervised loss calculation module is configured to perform loss constraint calculation on pipeline metal corrosion by using corrosion category inclusion during the training process of the target improvement network model.
[0037] Specifically, in this embodiment, the magnetic flux leakage defects in the target magnetic flux leakage image are detected by constructing the target improved network model.
[0038] In this embodiment, the target improved network model is supplemented with the circumferential position encoding module, the multi-scale fusion module, and the hierarchical weak supervision loss calculation module.
[0039] The circumferential position encoding module assigns unique position information to each category feature, which is then fused with the original features to guide the model to learn "where to look".
[0040] The multi-scale fusion module uses prior knowledge of feature size to guide the model to learn "how big" and improve the recognition accuracy of multi-category features of pipeline leakage magnetic signals.
[0041] To address the inherent problem of extremely long-tailed distribution of pipeline features (with corrosion features dominating) and dense head features, making annotation difficult, the hierarchical weakly supervised loss calculation module classifies corrosion into two categories: independent gold labels with precise detection boxes, and large-scale corrosion cluster regions containing a large amount of metal corrosion. The location and number of corrosion clusters within these large regions are statistically analyzed to serve as imprecise silver labels. The network weights are updated by combining the predicted location and number of silver labels, thus utilizing the imprecise label information to optimize the prediction accuracy of the precise label information.
[0042] See Figure 4 Furthermore, in some embodiments, the construction of the target improved network model further includes a backbone network module, a feature fusion mesh module, and a detection head network module; the circumferential position encoding module is disposed between the backbone network module and the feature fusion mesh module; the multi-scale fusion module is disposed between the feature fusion mesh module and the detection head network module; and the hierarchical weak supervision loss calculation module is disposed after the detection head network module.
[0043] Specifically, in this embodiment, the specific location of each newly added module in the target improved network model is defined.
[0044] Among them, see Figures 5 to 9 It can be known that: The backbone network module includes several regular convolutional layers, several gradient residual layers, and pooling layers.
[0045] The feature fusion mesh module includes several regular convolutional layers, several gradient residual layers, several splicing layers, and several upsampling layers.
[0046] The detection head network module includes a small target detection head, a medium target detection head, and a large target detection head; each of the small target detection head, the medium target detection head, and the large target detection head includes several one-dimensional convolutional units, two-dimensional convolutional units, rectangular box loss calculation units, and classification loss calculation units.
[0047] The conventional convolutional layer includes two-dimensional convolutional units, batch processing units, and activation function units.
[0048] The gradient residual layer includes a one-dimensional convolutional unit, a slicing unit, several partial convolutional units, and a splicing unit.
[0049] The pooling layer includes a one-dimensional convolutional unit, several max pooling units, and splicing units.
[0050] The convolutional unit includes several one-dimensional convolutional units, residual connection judgment units, and stacking units.
[0051] See Figures 10 to 12 Furthermore, in some embodiments, the circumferential position encoding module includes: The small target circumferential position encoding module is configured to perform position encoding on the pipeline, including metal corrosion and corrosion clusters, based on circumferential position, clock position and reserved position.
[0052] Specifically, in this embodiment, the backbone network module obtains three layers, P3, P4, and P5, through multiple downsampling. These layers are used to identify small, medium, and large-sized targets, respectively, corresponding to corrosion in the magnetic flux leakage image, medium-sized components such as branch pipe tees, and large-sized components such as valve flange welds. Corrosion features are concentrated at the bottom of the pipe, corresponding to the 6 o'clock center position in the image. Branch pipe tees are only distributed at the 0, 3, and 9 o'clock positions. Welds appear repeatedly on each pipe section in the horizontal direction. Different features have positional differences in the vertical and horizontal directions. Three positional encoding strategies are designed: vertical circumferential continuous encoding, vertical clock discrete encoding, and horizontal mileage continuous encoding. Using positional encoding can significantly improve the recognition accuracy of multiple feature categories by utilizing positional priors.
[0053] The small target circumferential position encoding module is responsible for detecting small targets (<32×32 pixels) such as metal corrosion (MTL) and corrosion clusters (CRC); it requires pixel-level positioning accuracy, using both coarse clock information and fine circumferential information (simulating the coarse to fine paradigm).
[0054] The corrosion distribution is systematically offset by pipe diameter, wall thickness, and sensor, so a reserved location code (PE_residual) is used.
[0055] The composition of the small target circumferential position encoding module (P3) is shown in Table 1.
[0056] Table 1. Composition of the small target circumferential position encoding module (32 dimensions in total)
[0057] In Table 1, PE_circ is the circumferential position code, PE_clock is the clock position code, and PE_residual is the reserved position code.
[0058] The circumferential position encoding module further includes: The central target circumferential position encoding module is configured to perform position encoding on the pipeline, including branch pipes, tees and bushings, based on clock position and reserved position.
[0059] Specifically, in this embodiment, the target circumferential position encoding module is responsible for detecting medium-sized components (such as branch pipes, tees, and bushings). For components requiring regional-level positioning (approximate location is sufficient), PE_clock is used. For components with slight offsets in their installation positions (non-standard clock positions), PE_residual is used.
[0060] The composition of the target circumferential position encoding module (P4) is shown in Table 2.
[0061] Table 2 shows the composition of the target circumferential position encoding module (32 dimensions in total).
[0062] The circumferential position encoding module further includes: A large target circumferential position encoding module is configured to perform position encoding on pipelines, including elbows, tees, and periodic welds, based on clock position and mileage position.
[0063] Specifically, in this embodiment, the large target circumferential position encoding module is responsible for detecting large components (elbows, tees) and periodic welds using PE_clock. The component positions are clear (standard clock positions), so no fine offset is required. However, it is necessary to model long-range periodicity (circumferential welds appear every X meters) using mileage position encoding (PE_mile).
[0064] The composition of the large target circumferential position encoding module (P5) is shown in Table 3.
[0065] Table 3. Composition of the Circumferential Position Encoding Module for Large Targets (32 Dimensions in Total)
[0066] The P3, P4, and P5 position encodings all use a common encoding method, PE_clock, which serves to partially align features. The internal structure of the circumferential position encoding module and its fusion method with the feature map are shown in the following example.
[0067] Taking P3 location code (CPE) as an example: P3 features: (Batch, 256, 80, 80); P3-encoding: (Batch, 32, 80, 80); Performing concat yields (Batch, 282, 80, 80); Performing a 1x1 convolution yields (Batch, 256, 80, 80), which is the fused feature map containing location information.
[0068] Furthermore, in some embodiments, the hierarchical weak supervision loss calculation module is further configured to: During the training of the target improved network model, the location information of the corrosion cluster and the quantity of metal corrosion are used to design a loss function to constrain the training of the target improved network model in real time; the metal corrosion is included in the corrosion cluster; the training status includes the current positioning accuracy of the metal corrosion area and the predicted quantity of metal corrosion in the area.
[0069] Specifically, in this embodiment, the hierarchical weakly supervised loss primarily addresses the limitation of the dataset classifying head features such as metal corrosion and corrosion clusters into independent categories. In the feature space, corrosion clusters should be the parent class of metal corrosion. To further improve the recognition accuracy of metal corrosion, a weakly supervised learning strategy is designed, treating corrosion clusters as imprecise "silver labels" containing metal corrosion regions, and individual metal corrosions as "gold labels" with precise location information. Utilizing the location information of the silver labels and the approximate number of internal metal corrosions, a loss function is designed to constrain the training situation in real time (the current positioning accuracy in the silver-labeled region and the approximation of the predicted number), thereby improving the accuracy of metal corrosion recognition.
[0070] Therefore, module P3 contains three parts of the loss function, as shown in formula (1): For P4, P5 only calculates... , and P3 Superimpose them.
[0071] (1) For more details, see formula (2):
[0072]
[0073] (2) in It is the gold standard for detection loss, consistent with the original YOLOv8 loss function. It is the standard position constraint loss of silver. It is the silver standard quantity calibration loss. and It is the weighting coefficient.
[0074] Table 4. Formula Symbol Reference Table
[0075] Gold Standard for Loss Detection : (3)
[0076] Network predictions: (1) Predicting bounding boxes : (4) (2) Class probability (after Softmax) (5) (3) Target confidence (after Sigmoid) (6) Real label value: (1) Truth bounding box: (7) (2) Real category labels: (8) (3) The target has a label: (9) Bounding box regression loss : The CIoU loss is adopted, which consists of three parts: IoU (Intersection over Union), centroid distance penalty, and aspect ratio consistency. (10) (11) IoU intersection-union ratio: (12) Center point distance penalty: (13) (14) in and These are the center points of the predicted bounding box and the ground truth label bounding box, respectively. This represents the width and height of the smallest bounding box.
[0077] Aspect ratio consistency: (15) (16) Classification loss
[0078] (17) in This indicates a focusing parameter that reduces the weight of easily classified samples. This indicates the weighting of positive and negative samples. , Represents the original probability values of the classification, logits. Confidence loss Using BCE With Logits Loss: (18) Positive samples: Anchors that match the ground truth (GT) with a target value of 1; Negative samples: unmatched anchors with a target of 0; Negative sample weights (to reduce background influence); Silver-marked position constraint loss .
[0079] Network predictions: Silver Standard Center Point Heatmap (after Sigmoid): (19) Real label value: Silver-labeled corrosion cluster annotation: (20) : Coordinates of the center point of the kth erosion cluster rk: pixel radius; nk: Approximate quantity of internal gold markings; Generating a heatmap of the center point of the real-label silver standard; Based on Gaussian distribution and the radius of the silver-marked region: (twenty one) in The Gaussian radius is proportional to the radius of the silver-marked area.
[0080] Loss function form: (twenty two) in Indicates the focus parameter; Indicates the threshold for positive samples; Indicates the weight of negative samples; Indicates the number of pixels in the silver-marked area Silver standard quantity calibration loss : Network predictions: This indicates the number of gold-labeled independent bounding boxes predicted by the network in each silver-labeled region: (twenty three) Real label value: This indicates the actual number of independent gold-marked boxes in each silver-marked area: (twenty four) Differentiable network predictions: (25) R k The k-th silver-marked region, with A circular region centered at a radius of rk; : Confidence of the i-th prediction box; wi: Spatial weight (the closer to the center, the higher the weight): (26) Loss function form: (27) (28) |x|<1 (small error): L2 loss, fine-tuning optimization; |x|≥1 (large error): L1 loss, to avoid the influence of outliers.
[0081] See Figure 13 It can be seen that, furthermore, in some embodiments, The multi-scale fusion module includes a global feature aggregation layer, a lightweight category embedding layer, a dynamic weight feature layer, and a splicing layer. The multi-scale fusion module is configured as follows: The global feature aggregation layer performs global average pooling on the features output by the small target circumferential position encoding module, the medium target circumferential position encoding module, and the large target circumferential position encoding module to extract semantic statistics. The semantic statistics are concatenated into a global feature vector through the concatenation layer, and the scale preference is embedded in each category learning using the lightweight category embedding layer. The dynamic weight feature layer generates several category dynamic weights based on the scale preference and the global feature vector, and performs weighted fusion and upsampling alignment based on the category weights to generate dedicated scale prior features. The corresponding dedicated scale prior features are then input into the small target circumferential position encoding module, the medium target circumferential position encoding module, and the large target circumferential position encoding module.
[0082] Specifically, in this embodiment, the main layers of the multi-scale fusion module include a global feature aggregation layer (GAP), a lightweight category embedding layer (MIP), and a dynamic weight feature layer. The multi-scale fusion module is used to fuse position encoding information. After the multi-scale feature maps P3', P4', P5' are processed by the feature fusion mesh module, optimized features P3'', P4'', P5'' with category scale awareness are obtained.
[0083] The global feature aggregation layer is used to perform global average pooling on each scale feature, extract semantic statistics, and concatenate them into a global feature vector.
[0084]
[0085]
[0086] (29) The lightweight category embedding layer learns a scale preference embedding for each category c. : (30) The dynamic weighted feature layer is used to generate basic weights based on a lightweight MLP: (31) Dynamic weight generation:
[0087] (32) Where α = 0.5 is the fusion coefficient. represents the scale weight for category c.
[0088] Generate specific scale prior features for each category c, input them into the corresponding detection head, and output the final detection result: (33).
[0089] This embodiment has the following advantages: This embodiment provides a multi-category feature detection method for pipeline magnetic flux leakage, which utilizes prior knowledge of the strong correlation between feature distribution, location, and scale to solve the problem of pseudo-color images in pipeline magnetic flux leakage imaging: 1) The feature categories have large differences in scale, making it difficult for the network to learn; 2) The challenge of long-tailed feature distribution and dense head feature distribution, making annotation difficult.
[0090] By leveraging prior features of feature space location distribution and introducing a location encoding module, each category feature is given unique location information, which is then fused with the original features to guide the model to learn "where to look". By leveraging prior knowledge of feature size, a multi-scale fusion module is introduced to guide the model to learn "how big" and improve the recognition accuracy of multi-category features of pipeline leakage magnetic signals.
[0091] Furthermore, addressing the inherently extreme long-tail distribution of pipeline features (with corrosion features dominating) and the difficulty in labeling densely distributed head features, a weakly supervised training method employing a multi-level distribution strategy is introduced, specifically reflected in the design of the loss function. Corrosion is categorized into independent gold labels with precise detection boxes, and large-scale corrosion cluster regions containing numerous metal corrosion areas. The location and number of corrosion clusters within these regions are statistically analyzed to serve as imprecise silver labels. The network weights are updated by combining the predicted location and number of silver labels, utilizing the imprecise label information to optimize the prediction accuracy of the precise label information. This approach, while maintaining prediction accuracy across multiple scales, improves upon dense head features, addressing the current shortcomings in the accuracy of pipeline magnetic flux leakage detection features.
[0092] For ease of explanation, the above description has been provided in conjunction with specific embodiments. However, the discussion in some embodiments is not intended to be exhaustive or to limit the embodiments to the specific forms disclosed above. Various modifications and variations can be obtained based on the above teachings. The selection and description of the above embodiments are for the purpose of better explaining the contents of this disclosure, thereby enabling those skilled in the art to better utilize the embodiments.
Claims
1. A method for detecting multiple categories of characteristics of pipeline leakage magnetic flux, characterized in that, The method includes: Acquire a target magnetic flux leakage image of the pipeline through circumferential data enhancement; An improved target network model is constructed, and the improved target network model is used to perform feature detection on the target magnetic flux leakage image to obtain the target detection result. The improved target network model includes a circumferential position encoding module, a multi-scale fusion module, and a hierarchical weakly supervised loss calculation module. The circumferential position encoding module is configured to perform multi-level position encoding on the corresponding features of the target magnetic flux leakage image. The multi-scale fusion module is configured to perform feature fusion based on dynamic weights on multiple features after multi-level position encoding. The hierarchical weakly supervised loss calculation module is configured to perform loss constraint calculation on pipeline metal corrosion using a corrosion category inclusion method during the training process of the improved target network model.
2. The method for detecting multiple types of pipeline leakage magnetic flux according to claim 1, characterized in that, The step of acquiring the target magnetic flux leakage image of the pipeline after circumferential data enhancement includes: Obtain the original magnetic flux leakage image inside the pipeline; The original magnetic flux leakage image is subjected to circumferential data augmentation to obtain the target magnetic flux leakage image.
3. The method for detecting multiple types of pipeline leakage magnetic flux according to claim 2, characterized in that, The step of performing circumferential data augmentation on the original magnetic flux leakage image includes: The top position region, bottom position region, and effective position region are extracted from the original magnetic flux leakage image using a circumferential data enhancement module; the effective position region is located between the top position region and the bottom position region. The top and bottom position regions are swapped using a circumferential data augmentation module, and the original magnetic flux leakage image is used to replace the effective position region to obtain the target magnetic flux leakage image.
4. The method for detecting multiple types of pipeline leakage magnetic flux according to claim 1, characterized in that, The constructed target improved network model further includes a backbone network module, a feature fusion mesh module, and a detection head network module; the circumferential position encoding module is located between the backbone network module and the feature fusion mesh module; the multi-scale fusion module is located between the feature fusion mesh module and the detection head network module; and the hierarchical weak supervision loss calculation module is located after the detection head network module.
5. The method for detecting multiple types of pipeline leakage magnetic flux according to claim 4, characterized in that, The backbone network module includes several regular convolutional layers, several gradient residual layers, and pooling layers; The feature fusion mesh module includes several regular convolutional layers, several gradient residual layers, several splicing layers, and several upsampling layers; The detection head network module includes a small target detection head, a medium target detection head, and a large target detection head; each of the small target detection head, the medium target detection head, and the large target detection head includes several one-dimensional convolutional units, two-dimensional convolutional units, rectangular box loss calculation units, and classification loss calculation units.
6. The method for detecting multiple types of pipeline leakage magnetic flux according to claim 5, characterized in that, The conventional convolutional layer includes a two-dimensional convolutional unit, a batch processing unit, and an activation function unit; The gradient residual layer includes a one-dimensional convolutional unit, a slicing unit, several partial convolutional units, and a splicing unit; The pooling layer includes a one-dimensional convolutional unit, several max pooling units, and splicing units.
7. The method for detecting multiple categories of pipeline leakage magnetic flux according to claim 6, characterized in that, The convolutional unit includes several one-dimensional convolutional units, residual connection judgment units, and stacking units.
8. The method for detecting multiple types of pipeline leakage magnetic flux according to claim 4, characterized in that, The circumferential position encoding module includes: The small target circumferential position encoding module is configured to perform position encoding on the pipeline, including metal corrosion and corrosion clusters, based on circumferential position, clock position and reserved position. The target circumferential position encoding module is configured to perform position encoding on the pipeline, including branch pipes, tees and sleeves, based on clock position and reserved position. A large target circumferential position encoding module is configured to perform position encoding on pipelines, including elbows, tees, and periodic welds, based on clock position and mileage position.
9. A method for detecting multiple types of pipeline leakage magnetic flux according to claim 8, characterized in that, The hierarchical weak supervision loss calculation module is also configured as follows: During the training of the target improved network model, the location information of the corrosion cluster and the quantity of metal corrosion are used to design a loss function to constrain the training of the target improved network model in real time; the metal corrosion is included in the corrosion cluster; the training status includes the current positioning accuracy of the metal corrosion area and the predicted quantity of metal corrosion in the area.
10. A method for detecting multiple categories of pipeline leakage magnetic flux as described in claim 8, characterized in that, The multi-scale fusion module includes a global feature aggregation layer, a lightweight category embedding layer, a dynamic weight feature layer, and a splicing layer. The multi-scale fusion module is configured as follows: The global feature aggregation layer performs global average pooling on the features output by the small target circumferential position encoding module, the medium target circumferential position encoding module, and the large target circumferential position encoding module to extract semantic statistics. The semantic statistics are concatenated into a global feature vector through the concatenation layer, and the scale preference is embedded in each category learning using the lightweight category embedding layer. The dynamic weight feature layer generates several category dynamic weights based on the scale preference and the global feature vector, and performs weighted fusion and upsampling alignment based on the category weights to generate dedicated scale prior features. The corresponding dedicated scale prior features are then input into the small target circumferential position encoding module, the medium target circumferential position encoding module, and the large target circumferential position encoding module.