Abstract:The quantification of defect size in oil and gas pipelines is a key issue and ultimate goal of pipeline inspection. Traditional defect detection methods often remain in the stage of defect classification, and the lack of detailed data increases the difficulty of subsequent processing; Intelligent recognition methods have higher requirements for the quality of magnetic leakage data however. Therefore, a PSO-RF algorithm combining particle swarm optimization and random forest is proposed to quantify the length, width, and depth of pipeline defects. Firstly, multi-dimensional feature extraction is performed on a set of defect magnetic leakage data, and then the random forest algorithm is used for regression prediction; In view of the difficulty of obtaining the best parameters of random forest algorithm, particle swarm optimization algorithm is used to optimize the hyperparameters, and finally more accurate prediction data of defect length, width and depth are obtained. The PSO-RF algorithm was obtained by combining two algorithms, and compared with classical CNN and PSO-SVR training algorithms. The quantization accuracy of length, width and depth was improved by 28%, 32% and 68% respectively, verifying the effectiveness and superiority of the PSO-RF algorithm. Finally, a set of labeled pipeline defect data was used to validate the algorithm, and the data with quantization errors of length, width and depth within 20% achieved 80.3%, 88.5% and 95.9% respectively.