Abstract:Magnetic flux leakage detection in oil and gas pipelines is a crucial method for evaluating pipeline integrity. However, traditional manual analysis methods suffer from low efficiency and high false detection rates. This study proposes an intelligent recognition method for pipeline magnetic flux leakage detection based on the YOLOv8 deep learning algorithm, achieving automated detection of pipeline defects. The research innovatively constructs an automated training dataset generation method based on manual annotation experience, effectively inheriting expert domain knowledge, and significantly improving dataset construction efficiency. Through preprocessing and image enhancement of magnetic flux leakage signals, raw data are converted into standardized grayscale images, and an adaptive image enhancement strategy is adopted to effectively improve image quality and feature distinguishability. In this study, a dataset of 36,098 high-quality magnetic flux leakage images is collected and generated from real-world engineering projects, including 3,403 defect-containing images used as the training set. The defects exhibit a relatively uniform distribution in the axial-circumferential plane of the pipeline, with localized high-density regions near weld seams. The defect sizes are predominantly within a smaller range, exhibiting a long-tailed distribution, providing a solid data foundation for model training. During training, the model′s precision and recall metrics stabilized at 0.66 and 0.60, respectively, with an mAP@0.5 of 0.57 and an mAP@[0.5:0.95] of 0.27. Testing on real-world engineering data achieves a precision of 63.17%, recall of 65.24%, and an F1 score of 64.19%. The feasibility and excellent detection performance of the YOLOv8 model for pipeline inspection tasks are verified. This method not only significantly improves detection efficiency and reduces manual costs but also effectively avoids judgment bias caused by human factors. The results show that deep learning-based intelligent recognition methods have broad application prospects in pipeline magnetic flux leakage detection.