Pipeline defect detection method based on self-distillation
Through self-distillation method, combined with Resnet50 and Faster R-CNN networks, the leakage magnetic signal characteristics are extracted and fused, which solves the problem of low accuracy of magnetic leakage detection in complex environments and realizes high-precision pipeline defect detection.
Patent Information
- Application Number
- CN202311506130.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-13
- Publication Date
- 2025-05-13
AI Technical Summary
The existing pipeline defect detection method based on magnetic leakage detection has low detection accuracy in complex environments.
By using the self-distillation method, the position characteristics and attribute characteristics of the leakage magnetic signal are extracted by constructing a labeled defect sample set, and then organically fused and input them into the Resnet50 network. The feature distillation and loss calculation are combined with Faster R-CNN, the network parameters are updated, and the training is repeated to improve the detection accuracy.
In complex pipeline environments, the accuracy of defect detection is significantly improved and pipeline defects can be identified more accurately.
Smart Images

Figure CN119991541A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of pipeline defect detection, and in particular to a pipeline defect detection method based on self-distillation. Background Art
[0002] Pipelines are an indispensable part of industrial transportation. Due to their long service life, pipelines face serious challenges of corrosion. Therefore, in order to ensure the safe operation of pipelines and prevent leakage and explosion accidents, it is necessary to conduct regular inspections of pipelines. The currently recognized effective means of pipeline safety inspection is magnetic flux leakage detection. Magnetic flux leakage detection plays an important role in pipeline safety inspection. The main reasons are: 1) The detection effect is better in complex environments; 2) It can detect internal and external defects without being affected by the transportation medium. At present, the traditional methods for pipeline inspection based on magnetic flux leakage detection mainly include threshold method and shallow machine learning method. However, due to the lack of strong feature extraction capabilities, these traditional methods are limited in effectiveness under complex working conditions and have low detection accuracy.
[0003] Therefore, there is an urgent need for a pipeline defect detection method based on self-distillation to effectively improve the detection accuracy of pipeline defects. Summary of the invention
[0004] The purpose of the present invention is to solve the problem of low detection accuracy of pipeline defect detection methods based on leakage magnetic detection in the prior art under complex environments, and to provide a pipeline defect detection method based on self-distillation.
[0005] In order to achieve the above object, the present invention provides a pipeline defect detection method based on self-distillation, and the pipeline defect detection method based on self-distillation includes: S1. Build a set of labeled defect samples; S2. extracting the position features and attribute features of the magnetic leakage signal based on the constructed defect sample set; S3, organically integrate attribute features and location features to obtain auxiliary knowledge; S4, convert the magnetic leakage signal into a pseudo-color image and input it into the Resnet50 network to obtain the student features, and then fuse the student features with the auxiliary knowledge to obtain the implicit teacher features; S5. Input the student features and teacher features into the head network of Faster R-CNN to obtain the predicted defect location, and calculate the deviation from the actual defect location to obtain the classification and regression loss. S6. Perform feature distillation on teacher features and student features to obtain distillation loss ;
[0006] S7, back-propagation updates network parameters through distillation, classification, and regression losses; S8, repeating steps S4-S7 n times to obtain a student network that can detect defect locations; S9. Input the magnetic leakage signal to be detected into the student network to obtain the specific location of the defect.
[0007] Preferably, in step S1, the step of constructing a defect sample set with labels specifically includes: The labelimg software is used to mark the defects of the magnetic leakage signal, and the magnetic leakage signal with defect marks is used as a training sample to construct a defect sample set.
[0008] Preferably, in step S2, extracting the position features and attribute features of the magnetic leakage signal based on the constructed defect sample set specifically includes: The position information of the target corresponding to each defect-marked magnetic leakage signal is recorded as , and the four coordinates of the target position information corresponding to each defect-marked magnetic leakage signal and the center point of the target ,length ,width , aspect ratio ,area The position features of the leakage magnetic signal are obtained by mapping it to a high-dimensional space through an encoder, and the brightness value, texture features, average gradient and color moment of the target defect area are calculated at the same time. The attribute features of the leakage magnetic signal are obtained by mapping it to a high-dimensional space through an encoder, where: is the coordinate of the upper left corner of the target in the image, is the coordinate of the lower right corner of the target in the image.
[0009] Preferably, the brightness value, texture feature, average gradient and color moment of the target defect area are calculated, and mapped to a high-dimensional space through an encoder to obtain the attribute features of the magnetic leakage signal, specifically including: a. Sort the brightness matrix values in a magnetic leakage defect, and let the sorted brightness matrix be ,in , use formula (1) to calculate the brightness value of the defect area;
[0010] (1)
[0011] in, represents the average brightness of the defect in the ith area, and Hyperparameters representing upper and lower bounds on defects;
[0012] b. Use gray-level co-occurrence matrix to extract the texture features of defects and weight them according to the peak signal-to-noise ratio of pixels; c. Use formula (2) to calculate the average gradient of the defect as the physical feature: (2)
[0013] in, represents the average gradient of the defect area, M represents the number of rows of the defect area, and N represents the number of columns of the defect area. and Represent the gradients in the horizontal and vertical directions of the defect area respectively;
[0014] d. Use the two-dimensional color moment of the defect area to reflect the color distribution of the defect area; e. Concatenate the brightness value, texture features, average gradient and color moment into a feature vector and input it into the encoder to map it to a high-dimensional space to obtain attribute features.
[0015] Preferably, in step S3, the organic fusion of attribute features and location features to obtain auxiliary knowledge specifically includes: Two PointNets with the same structure but different weights are used to map the location features and attribute features of the magnetic leakage signal into the same dimension, and auxiliary knowledge is obtained based on the feature alignment and fusion of the attribute features and location features.
[0016] Preferably, in step S4, the magnetic leakage signal is converted into a pseudo-color image and input into the Resnet50 network to obtain student features, and then the student features are integrated with the auxiliary knowledge to obtain implicit teacher features, specifically including: Stepwise compression is used to convert the leakage magnetic signal into a pseudo-color image, and the image features are input into the Resnet50 network. The student features are obtained by feature fusion through FPN, and then the features with defect locations are obtained based on the student features and the true labels. The features are organically integrated with the auxiliary knowledge to obtain implicit teacher features.
[0017] Preferably, the stepwise compression is used to convert the magnetic leakage signal into a pseudo-color image, specifically comprising: The magnetic flux leakage signal conforms to the Gaussian distribution of formula (3): (3)
[0018] in, represents the average difference of the leakage magnetic signal, Represents the standard deviation of the magnetic flux leakage signal;
[0019] Compress the leakage magnetic signal to the upper and lower bounds of formula (4): (4)
[0020] in, represents the compression factor, Represents the minimum value of the leakage magnetic signal, Represents the maximum value of the leakage magnetic signal;
[0021] The compressed magnetic flux leakage signal is converted into a pseudo-color image using formula (5): (5)
[0022] The features with defect locations are obtained based on the student features and the true labels, and the features are organically integrated with the auxiliary knowledge to obtain implicit teacher features, specifically including: The student features are cut into 1×1 blocks to calculate the distance between the target area and the surrounding blocks. When the distance is less than the set threshold, the block is masked as 1, otherwise it is marked as 0. The generated mask matrix is compared with Multiply them together to get the features with the defect position, and dot-multiply the features with the defect position with the auxiliary knowledge to get the implicit teacher features.
[0023] Preferably, in step S5, the inputting of the student features and the teacher features into the head network of Faster R-CNN to obtain the predicted defect location, and calculating the deviation from the actual defect location to obtain the classification and regression loss specifically includes: The teacher features and student features are first input into the RPN layer to generate candidate boxes to preliminarily mark potential targets. Then the candidate boxes are fused with the features to obtain features with candidate regions, which are input into the ROI layer for pooling into 7×7 features and calculating classification loss and regression loss. The loss calculation formula of Faster R-CNN is:
[0024] in, Represents the total loss function of the Faster R-CNN network model; Indicates the number of anchors used in the process of training the RPN network; represents the classification loss function; represents the normalized weight; Indicates the size of the feature map; represents the position regression loss function; Represents the true label, which takes values of 0 and 1. It is 1 when the label is a positive sample and 0 when the label is a negative sample. Indicates the probability that the anchor is predicted as a target; represents the parameterized coordinates of the predicted location; The parameterized coordinates representing the actual dimension location.
[0025] Preferably, in step S6, the teacher features and the student features are subjected to feature distillation to obtain a distillation loss , specifically including:
[0026] The mean square error is used to calculate the distillation loss of teacher features and student features, where the calculation formula of distillation loss is:
[0027] in, represents the feature map of the i-th stage of the student network, represents the feature map of the i-th stage of the teacher network, Represents the number of stages of the network.
[0028] Preferably, in step S7, the updating of network parameters by back propagation through distillation, classification and regression loss specifically includes: By calculating the classification and regression loss and the distillation loss as the total loss of the network, the total loss is back-propagated to update the overall parameters of the network. The total loss is calculated as: .
[0029] According to the above technical scheme, based on the pipeline defect detection method based on self-distillation, through S1, constructing a defect sample set with labels; S2, extracting the position features and attribute features of the leakage magnetic signal based on the constructed defect sample set; S3, organically integrating the attribute features and the position features to obtain auxiliary knowledge; S4, converting the leakage magnetic signal into a pseudo-color image and inputting it into the Resnet50 network to obtain the student features, and then integrating the student features with the auxiliary knowledge to obtain the implicit teacher features; S5, inputting the student features and the teacher features into the head network of Faster R-CNN to obtain the predicted defect position, and calculating the deviation from the actual defect position to obtain the classification and regression loss; S6, performing feature distillation on the teacher features and the student features to obtain the distillation loss ; S7, update the network parameters through back propagation through distillation, classification and regression loss; S8, repeat steps S4-S7 n times to obtain the student network that can detect the defect location; S9, input the leakage magnetic signal to be detected into the student network to obtain the specific location of the defect. In the actual application process, it can effectively improve the detection accuracy of pipeline defects in complex pipeline environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 is a flow chart of a pipeline defect detection method based on self-distillation; Figure 2 It is a schematic diagram of the pipeline defect detection method based on self-distillation; Figure 3 This is a diagram showing the detection effect of pipeline defects based on the pipeline defect detection method of the present invention which is self-distilled; Figure 4 The figure is a detection effect diagram of pipeline defects based on an existing detection method. DETAILED DESCRIPTION
[0031] The specific implementation of the embodiment of the present invention is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described here is only used to illustrate and explain the embodiment of the present invention, and is not used to limit the embodiment of the present invention.
[0032] The present invention provides a pipeline defect detection method based on self-distillation, such as Figure 1-2 As shown, the pipeline defect detection method based on self-distillation includes: S1. Build a set of labeled defect samples; S2. extracting the position features and attribute features of the magnetic leakage signal based on the constructed defect sample set; S3, organically integrate attribute features and location features to obtain auxiliary knowledge; S4, convert the magnetic leakage signal into a pseudo-color image and input it into the Resnet50 network to obtain the student features, and then fuse the student features with the auxiliary knowledge to obtain the implicit teacher features; S5. Input the student features and teacher features into the head network of Faster R-CNN to obtain the predicted defect location, and calculate the deviation from the actual defect location to obtain the classification and regression loss. S6. Perform feature distillation on teacher features and student features to obtain distillation loss ;
[0033] S7, back-propagation updates network parameters through distillation, classification, and regression losses; S8, repeating steps S4-S7 n times to obtain a student network that can detect defect locations; S9. Input the magnetic leakage signal to be detected into the student network to obtain the specific location of the defect.
[0034] According to the above technical solution, based on the pipeline defect detection method based on self-distillation, in actual application, the detection accuracy of pipeline defects can be effectively improved in a complex pipeline environment.
[0035] In the pipeline defect detection method based on self-distillation of the present invention, in order to further improve the detection accuracy of pipeline defects, preferably, in step S1, the step of constructing a defect sample set with a label specifically includes: The labelimg software is used to mark the defects of the magnetic leakage signal, and the magnetic leakage signal with defect marks is used as a training sample to construct a defect sample set.
[0036] In the pipeline defect detection method based on self-distillation of the present invention, in order to further improve the detection accuracy of pipeline defects, preferably, in step S2, the position features and attribute features of the leakage magnetic signal are extracted based on the constructed defect sample set, specifically including: The position information of the target corresponding to each defect-marked magnetic leakage signal is recorded as , and the four coordinates of the target position information corresponding to each defect-marked magnetic leakage signal and the center point of the target ,length ,width , aspect ratio ,area The position features of the leakage magnetic signal are obtained by mapping it to a high-dimensional space through an encoder, and the brightness value, texture features, average gradient and color moment of the target defect area are calculated at the same time. The attribute features of the leakage magnetic signal are obtained by mapping it to a high-dimensional space through an encoder, where: is the coordinate of the upper left corner of the target in the image, is the coordinate of the lower right corner of the target in the image.
[0037] In the pipeline defect detection method based on self-distillation of the present invention, in order to further improve the detection accuracy of pipeline defects, preferably, the brightness value, texture features, average gradient and color moment of the target defect area are calculated, and the attribute features of the leakage magnetic signal are obtained by mapping them to a high-dimensional space through an encoder, specifically including: a. Sort the brightness matrix values in a magnetic leakage defect, and let the sorted brightness matrix be ,in , use formula (1) to calculate the brightness value of the defect area;
[0038] (1)
[0039] in, represents the average brightness of the defect in the ith area, and Hyperparameters representing upper and lower bounds on defects;
[0040] b. Use gray-level co-occurrence matrix to extract the texture features of defects and weight them according to the peak signal-to-noise ratio of pixels; c. Use formula (2) to calculate the average gradient of the defect as the physical feature: (2)
[0041] in, represents the average gradient of the defect area, M represents the number of rows of the defect area, and N represents the number of columns of the defect area. and Represent the gradients in the horizontal and vertical directions of the defect area respectively;
[0042] d. Use the two-dimensional color moment of the defect area to reflect the color distribution of the defect area; e. Concatenate the brightness value, texture features, average gradient and color moment into a feature vector and input it into the encoder to map it to a high-dimensional space to obtain attribute features.
[0043] In the pipeline defect detection method based on self-distillation of the present invention, in order to further improve the detection accuracy of pipeline defects, preferably, in step S3, the attribute features and the position features are organically integrated to obtain auxiliary knowledge, which specifically includes: Two PointNets with the same structure but different weights are used to map the location features and attribute features of the magnetic leakage signal into the same dimension, and auxiliary knowledge is obtained based on the feature alignment and fusion of the attribute features and location features.
[0044] In the pipeline defect detection method based on self-distillation of the present invention, in order to further improve the detection accuracy of pipeline defects, preferably, in step S4, the leakage magnetic signal is converted into a pseudo-color picture and input into the Resnet50 network to obtain student features, and then the student features are integrated with auxiliary knowledge to obtain implicit teacher features, which specifically include: Stepwise compression is used to convert the leakage magnetic signal into a pseudo-color image, and the image features are input into the Resnet50 network. The student features are obtained by feature fusion through FPN, and then the features with defect locations are obtained based on the student features and the true labels. The features are organically integrated with the auxiliary knowledge to obtain implicit teacher features.
[0045] In the pipeline defect detection method based on self-distillation of the present invention, in order to further improve the detection accuracy of pipeline defects, preferably, the stepwise compression is used to convert the magnetic leakage signal into a pseudo-color image, which specifically includes: The magnetic flux leakage signal conforms to the Gaussian distribution of formula (3): (3)
[0046] in, represents the average difference of the leakage magnetic signal, Represents the standard deviation of the magnetic flux leakage signal;
[0047] Compress the leakage magnetic signal to the upper and lower bounds of formula (4): (4)
[0048] in, represents the compression factor, Represents the minimum value of the leakage magnetic signal, Represents the maximum value of the leakage magnetic signal;
[0049] The compressed magnetic flux leakage signal is converted into a pseudo-color image using formula (5): (5)
[0050] The features with defect locations are obtained based on the student features and the true labels, and the features are organically integrated with the auxiliary knowledge to obtain implicit teacher features, specifically including: The student features are cut into 1×1 blocks to calculate the distance between the target area and the surrounding blocks. When the distance is less than the set threshold, the block is masked as 1, otherwise it is marked as 0. The generated mask matrix is compared with Multiply them together to get the features with the defect position, and dot-multiply the features with the defect position with the auxiliary knowledge to get the implicit teacher features.
[0051] In the pipeline defect detection method based on self-distillation of the present invention, in order to further improve the detection accuracy of pipeline defects, preferably, in step S5, the student features and the teacher features are input into the head network of Faster R-CNN to obtain the predicted defect position, and the deviation from the actual position of the defect is calculated to obtain the classification and regression loss, which specifically includes: The teacher features and student features are first input into the RPN layer to generate candidate boxes to preliminarily mark potential targets. Then the candidate boxes are fused with the features to obtain features with candidate regions, which are input into the ROI layer for pooling into 7×7 features and calculating classification loss and regression loss. The loss calculation formula of Faster R-CNN is:
[0052] in, Represents the total loss function of the Faster R-CNN network model; Indicates the number of anchors used in the process of training the RPN network; represents the classification loss function; represents the normalized weight; Indicates the size of the feature map; represents the position regression loss function; Represents the true label, which takes values of 0 and 1. It is 1 when the label is a positive sample and 0 when the label is a negative sample. Indicates the probability that the anchor is predicted as a target; represents the parameterized coordinates of the predicted location; The parameterized coordinates representing the actual dimension location.
[0053] In the pipeline defect detection method based on self-distillation of the present invention, in order to further improve the detection accuracy of pipeline defects, preferably, in step S6, the teacher features and the student features are subjected to feature distillation to obtain the distillation loss , specifically including:
[0054] The mean square error is used to calculate the distillation loss of teacher features and student features, where the calculation formula of distillation loss is:
[0055] in, represents the feature map of the i-th stage of the student network, represents the feature map of the i-th stage of the teacher network, Represents the number of stages of the network.
[0056] In the pipeline defect detection method based on self-distillation of the present invention, in order to further improve the detection accuracy of pipeline defects, preferably, in step S7, back propagation is performed to update network parameters through distillation, classification and regression loss, specifically including: By calculating the classification and regression loss and the distillation loss as the total loss of the network, the total loss is back-propagated to update the overall parameters of the network. The total loss is calculated as: .
[0057] The present invention will be described in detail below through examples, but the protection scope of the present invention is not limited thereto.
[0058] Example 1 Use Figure 1 The pipeline defect detection method based on self-distillation is implemented for pipeline defect detection. Specifically, the pipeline defect detection method based on self-distillation includes: S1. Build a set of labeled defect samples; S2. extracting the position features and attribute features of the magnetic leakage signal based on the constructed defect sample set; S3, organically integrate attribute features and location features to obtain auxiliary knowledge; S4, convert the magnetic leakage signal into a pseudo-color image and input it into the Resnet50 network to obtain the student features, and then fuse the student features with the auxiliary knowledge to obtain the implicit teacher features; S5. Input the student features and teacher features into the head network of Faster R-CNN to obtain the predicted defect location, and calculate the deviation from the actual defect location to obtain the classification and regression loss. S6. Perform feature distillation on teacher features and student features to obtain distillation loss ;
[0059] S7, back-propagation updates network parameters through distillation, classification, and regression losses; S8, repeating steps S4-S7 n times to obtain a student network that can detect defect locations; S9, input the magnetic leakage signal to be detected into the student network to obtain the specific location of the defect; Wherein, in step S1, the step of constructing a defect sample set with labels specifically includes: The labelimg software is used to mark the defects of the magnetic leakage signal, and the magnetic leakage signal with defect marks is used as a training sample to construct a defect sample set;
[0060] In step S2, extracting the position features and attribute features of the magnetic leakage signal based on the constructed defect sample set specifically includes: The position information of the target corresponding to each defect-marked magnetic leakage signal is recorded as , and the four coordinates of the target position information corresponding to each defect-marked magnetic leakage signal and the center point of the target ,length ,width , aspect ratio ,area The position features of the leakage magnetic signal are obtained by mapping it to a high-dimensional space through an encoder, and the brightness value, texture features, average gradient and color moment of the target defect area are calculated at the same time. The attribute features of the leakage magnetic signal are obtained by mapping it to a high-dimensional space through an encoder, where: is the coordinate of the upper left corner of the target in the image, is the coordinate of the lower right corner of the target in the image;
[0061] The brightness value, texture feature, average gradient and color moment of the target defect area are calculated, and the attribute features of the magnetic leakage signal are obtained by mapping them to a high-dimensional space through an encoder, specifically including: a. Sort the brightness matrix values in a magnetic leakage defect, and let the sorted brightness matrix be ,in , use formula (1) to calculate the brightness value of the defect area;
[0062] (1)
[0063] in, represents the average brightness of the defect in the ith area, and Hyperparameters representing upper and lower bounds on defects;
[0064] b. Use gray-level co-occurrence matrix to extract the texture features of defects and weight them according to the peak signal-to-noise ratio of pixels; c. Use formula (2) to calculate the average gradient of the defect as the physical feature: (2)
[0065] in, represents the average gradient of the defect area, M represents the number of rows of the defect area, and N represents the number of columns of the defect area. and Represent the gradients in the horizontal and vertical directions of the defect area respectively;
[0066] d. Use the two-dimensional color moment of the defect area to reflect the color distribution of the defect area; e. Concatenate the brightness value, texture features, average gradient and color moment into a feature vector and input it into the encoder to map it into a high-dimensional space to obtain attribute features; In step S3, the attribute features and the position features are organically integrated to obtain auxiliary knowledge, which specifically includes: Two PointNets with the same structure but different weights are used to map the position features and attribute features of the magnetic leakage signal into the same dimension, and auxiliary knowledge is obtained based on the feature alignment and fusion of the attribute features and position features. In step S4, the magnetic leakage signal is converted into a pseudo-color image and input into the Resnet50 network to obtain student features, and then the student features are integrated with the auxiliary knowledge to obtain implicit teacher features, specifically including: The magnetic flux leakage signal is converted into a pseudo-color image using step compression and input into the Resnet50 network to obtain image features. The student features are obtained by feature fusion through FPN. The features with defect locations are then obtained based on the student features and the true labels. The features are then organically integrated with auxiliary knowledge to obtain implicit teacher features. The stepwise compression is used to convert the magnetic leakage signal into a pseudo-color image, specifically including: The magnetic flux leakage signal conforms to the Gaussian distribution of formula (3): (3)
[0067] in, represents the average difference of the leakage magnetic signal, Represents the standard deviation of the magnetic flux leakage signal;
[0068] Compress the leakage magnetic signal to the upper and lower bounds of formula (4): (4)
[0069] in, represents the compression factor, Represents the minimum value of the leakage magnetic signal, Represents the maximum value of the leakage magnetic signal;
[0070] The compressed magnetic flux leakage signal is converted into a pseudo-color image using formula (5): (5)
[0071] The features with defect locations are obtained based on the student features and the true labels, and the features are organically integrated with the auxiliary knowledge to obtain implicit teacher features, specifically including: The student features are cut into 1×1 blocks to calculate the distance between the target area and the surrounding blocks. When the distance is less than the set threshold, the block is masked as 1, otherwise it is marked as 0. The generated mask matrix is compared with Multiply to get the feature with defect position, and dot-multiply the feature with defect position with auxiliary knowledge to get implicit teacher feature;
[0072] In step S5, the student features and the teacher features are input into the head network of Faster R-CNN to obtain the predicted defect location, and the deviation from the actual defect location is calculated to obtain the classification and regression loss, specifically including: The teacher features and student features are first input into the RPN layer to generate candidate boxes to preliminarily mark potential targets. Then the candidate boxes are fused with the features to obtain features with candidate regions, which are input into the ROI layer for pooling into 7×7 features and calculating classification loss and regression loss. The loss calculation formula of Faster R-CNN is:
[0073] in, Represents the total loss function of the Faster R-CNN network model; Indicates the number of anchors used in the process of training the RPN network; represents the classification loss function; represents the normalized weight; Indicates the size of the feature map; represents the position regression loss function; Represents the true label, which takes values of 0 and 1. It is 1 when the label is a positive sample and 0 when the label is a negative sample. Indicates the probability that the anchor is predicted as a target; represents the parameterized coordinates of the predicted location; The parameterized coordinates representing the actual annotation location;
[0074] In step S6, the teacher features and the student features are subjected to feature distillation to obtain a distillation loss , specifically including:
[0075] The mean square error is used to calculate the distillation loss of teacher features and student features, where the calculation formula of distillation loss is:
[0076] in, represents the feature map of the i-th stage of the student network, represents the feature map of the i-th stage of the teacher network, represents the number of stages of the network;
[0077] In step S7, back propagation is performed to update network parameters through distillation, classification and regression losses, specifically including: By calculating the classification and regression loss and the distillation loss as the total loss of the network, the total loss is back-propagated to update the overall parameters of the network. The total loss is calculated as: .
[0078] After testing, the pipeline defect detection method based on self-distillation of the present invention is used to detect pipeline defects. Figure 3 As shown in FIG. 1 , the detection effect diagram of pipeline defects based on a prior art detection method is as follows Figure 4 As shown, by comparison, the present invention can detect more defects with a low defect overlap rate.
[0079] The pipeline defect detection method based on self-distillation provided by the present invention can effectively improve the detection accuracy of pipeline defects in a complex pipeline environment during actual application.
[0080] The preferred embodiments of the present invention are described in detail above with reference to the accompanying drawings, but the present invention is not limited thereto. Within the technical concept of the present invention, the technical solution of the present invention can be subjected to a variety of simple modifications. In order to avoid unnecessary repetition, the present invention will not further describe various possible combinations. However, these simple modifications and combinations should also be regarded as the contents disclosed by the present invention and belong to the protection scope of the present invention.
Claims
1. A pipeline defect detection method based on self-distillation, characterized in that: The pipeline defect detection method based on self-distillation includes: S1. Build a set of labeled defect samples; S2. extracting the position features and attribute features of the magnetic leakage signal based on the constructed defect sample set; S3, organically integrate attribute features and location features to obtain auxiliary knowledge; S4, convert the magnetic leakage signal into a pseudo-color image and input it into the Resnet50 network to obtain the student features, and then fuse the student features with the auxiliary knowledge to obtain the implicit teacher features; S5. Input the student features and teacher features into the head network of Faster R-CNN to obtain the predicted defect location, and calculate the deviation from the actual defect location to obtain the classification and regression loss. S6. Perform feature distillation on teacher features and student features to obtain distillation loss ; S7, back-propagation updates network parameters through distillation, classification, and regression losses; S8, repeating steps S4-S7 n times to obtain a student network that can detect defect locations; S9. Input the magnetic leakage signal to be detected into the student network to obtain the specific location of the defect.
2. The pipeline defect detection method based on self-distillation according to claim 1, characterized in that: In step S1, the step of constructing a defect sample set with labels specifically includes: The labelimg software is used to mark the defects of the magnetic leakage signal, and the magnetic leakage signal with defect marks is used as a training sample to construct a defect sample set.
3. The pipeline defect detection method based on self-distillation according to claim 2, characterized in that: In step S2, extracting the position features and attribute features of the magnetic leakage signal based on the constructed defect sample set specifically includes: The position information of the target corresponding to each defect-marked magnetic flux leakage signal is recorded as , and the four coordinates of the target position information corresponding to each defect-marked magnetic leakage signal and the center point of the target ,length ,width , aspect ratio ,area The position features of the leakage magnetic signal are obtained by mapping it to a high-dimensional space through an encoder, and the brightness value, texture features, average gradient and color moment of the target defect area are calculated at the same time. The attribute features of the leakage magnetic signal are obtained by mapping it to a high-dimensional space through an encoder, where: is the coordinate of the upper left corner of the target in the image, is the coordinate of the lower right corner of the target in the image.
4. The pipeline defect detection method based on self-distillation according to claim 3 is characterized in that: The brightness value, texture feature, average gradient and color moment of the target defect area are calculated, and the attribute features of the magnetic leakage signal are obtained by mapping them to a high-dimensional space through an encoder, specifically including: a. Sort the brightness matrix values in a magnetic leakage defect, and let the sorted brightness matrix be ,in , use formula (1) to calculate the brightness value of the defect area; (1) in, represents the average brightness of the defect in the ith area, and Hyperparameters representing upper and lower bounds on defects; b. Use gray-level co-occurrence matrix to extract the texture features of defects and weight them according to the peak signal-to-noise ratio of pixels; c. Use formula (2) to calculate the average gradient of the defect as the physical feature: (2) in, represents the average gradient of the defect area, M represents the number of rows of the defect area, and N represents the number of columns of the defect area. and Represent the gradients in the horizontal and vertical directions of the defect area respectively; d. Use the two-dimensional color moment of the defect area to reflect the color distribution of the defect area; e. Concatenate the brightness value, texture features, average gradient and color moment into a feature vector and input it into the encoder to map it to a high-dimensional space to obtain attribute features.
5. The pipeline defect detection method based on self-distillation according to claim 1, characterized in that: In step S3, the attribute features and the position features are organically integrated to obtain auxiliary knowledge, which specifically includes: Two PointNets with the same structure but different weights are used to map the location features and attribute features of the magnetic leakage signal into the same dimension, and auxiliary knowledge is obtained based on the feature alignment and fusion of the attribute features and location features.
6. The pipeline defect detection method based on self-distillation according to any one of claims 1 to 5, characterized in that: In step S4, the magnetic leakage signal is converted into a pseudo-color image and input into the Resnet50 network to obtain student features, and then the student features are integrated with the auxiliary knowledge to obtain implicit teacher features, which specifically includes: Stepwise compression is used to convert the leakage magnetic signal into a pseudo-color image, and the image features are input into the Resnet50 network. The student features are obtained by feature fusion through FPN, and then the features with defect locations are obtained based on the student features and the true labels. The features are organically integrated with the auxiliary knowledge to obtain implicit teacher features.
7. The pipeline defect detection method based on self-distillation according to claim 6, characterized in that: The stepwise compression is used to convert the magnetic leakage signal into a pseudo-color image, specifically including: The magnetic flux leakage signal conforms to the Gaussian distribution of formula (3): (3) in, represents the average difference of the leakage magnetic signal, Represents the standard deviation of the magnetic flux leakage signal; Compress the leakage magnetic signal to the upper and lower bounds of formula (4): (4) in, represents the compression factor, Represents the minimum value of the leakage magnetic signal, Represents the maximum value of the leakage magnetic signal; The compressed magnetic flux leakage signal is converted into a pseudo-color image using formula (5): (5) The features with defect locations are obtained based on the student features and the true labels, and the features are organically integrated with the auxiliary knowledge to obtain implicit teacher features, specifically including: The student features are cut into 1×1 blocks to calculate the distance between the target area and the surrounding blocks. When the distance is less than the set threshold, the block is masked as 1, otherwise it is marked as 0. The generated mask matrix is compared with Multiply them together to get the features with the defect position, and dot-multiply the features with the defect position with the auxiliary knowledge to get the implicit teacher features.
8. The pipeline defect detection method based on self-distillation according to claim 1 or 7, characterized in that: In step S5, the student features and the teacher features are input into the head network of Faster R-CNN to obtain the predicted defect location, and the deviation from the actual defect location is calculated to obtain the classification and regression loss, specifically including: The teacher features and student features are first input into the RPN layer to generate candidate boxes to preliminarily mark potential targets. Then the candidate boxes are fused with the features to obtain features with candidate regions, which are input into the ROI layer for pooling into 7×7 features and calculating classification loss and regression loss. The loss calculation formula of Faster R-CNN is: in, Represents the total loss function of the Faster R-CNN network model; Indicates the number of anchors used in the process of training the RPN network; represents the classification loss function; represents the normalized weight; Indicates the size of the feature map; represents the position regression loss function; Represents the true label, which takes values of 0 and 1. It is 1 when the label is a positive sample and 0 when the label is a negative sample. Indicates the probability that the anchor is predicted as a target; represents the parameterized coordinates of the predicted location; The parameterized coordinates representing the actual dimension location.
9. The pipeline defect detection method based on self-distillation according to claim 8, characterized in that: In step S6, the teacher features and the student features are subjected to feature distillation to obtain a distillation loss , including: The mean square error is used to calculate the distillation loss of teacher features and student features, where the calculation formula of distillation loss is: in, represents the feature map of the i-th stage of the student network, represents the feature map of the i-th stage of the teacher network, Represents the number of stages of the network.
10. The pipeline defect detection method based on self-distillation according to claim 9, characterized in that: In step S7, back propagation is performed to update network parameters through distillation, classification and regression losses, specifically including: By calculating the classification and regression loss and the distillation loss as the total loss of the network, the total loss is back-propagated to update the overall parameters of the network. The total loss is calculated as: 。