Experimental classification of pipeline magnetic leakage defects based on mixed attention mechanism
[Objective]As a country's vital strategic resources,oil and gas play a decisive role in national economic levels and international strategic positions.Pipelines are the most commonly used method for transporting these resources,but they are vulnerable to various defects and damages during transportation,including construction aging,natural wear and tear,internal corrosion,and external impacts.These factors often result in frequent leakage accidents.Therefore,the regular use of magnetic flux leakage detection technology to inspect and evaluate existing oil and gas pipelines is an effective means to ensure their integrity and reliability.However,traditional manual interpretation methods suffer from issues such as missed detections and false alarms.Therefore,the intelligent development of leak magnetic signal identification can be facilitated using deep learning techniques.[Methods]The magnetic leakage image samples in this experiment were collected from an actual long-distance oil and gas pipeline.First,the magnetic leakage images in a dataset were augmented,including rotation,cropping,scaling,mirroring,and other image transformations,to generate six types of magnetic leakage core signal images:flange,metal loss,normal,spiral weld,tee joint,and ring weld.The preprocessed magnetic leakage image samples were then divided into a training set,a validation set,and a test set in certain proportions.This experiment was based on the PyTorch 2.0 deep learning framework and utilized a transfer learning strategy to invoke the pretrained model ResNet50.Meanwhile,keeping the pretrained weights unchanged,different attention mechanism modules(SE,CA,CBAM,and ECA)were added after each stage of the backbone network,and the insertion position and quantity of attention mechanisms were varied to conduct multiple comparative experiments.Finally,a comprehensive evaluation of the model's performance was conducted using multiple evaluation metrics.In addition,to further understand the internal recognition logic of the model,the Grad-CAM++interpretable algorithm was used to generate feature maps.By comparing the feature maps generated by the ResNet50 model and the ECA model at different stages,the recognition differences between them were analyzed,and preliminary localization of the magnetic leakage defects was achieved.[Results]Experimental results showed the following:1)Inserting a single-layer attention mechanism in Stages 1-3 of the backbone network partially improves the model's accuracy,but the improvement was not significant.2)Inserting multiple-layer attention mechanisms in Stages 1-3 of the backbone network greatly improves the model's recognition performance,with an average improvement of 3.15%.Among them,the ECA model performed the best,with an accuracy of 99.7%for its optimal model,and it had a lower complexity and loss value(0.017).3)The feature maps of the ECA attention model were more focused on precise features compared with the ResNet50 model rather than on abstract features.This feature representation was also more consistent with human recognition characteristics.[Conclusions]In summary,the introduction of a multilayer attention mechanism effectively improves the recognition performance of the model and accurately identifies six types of magnetic leakage signal images in the pipeline.Furthermore,by using the Grad-CAM++interpretability algorithm,the internal recognition logic of the model can be visualized,thereby achieving the initial localization of magnetic leakage defects.