Railway steel rail surface defect detection method based on generative adversarial network and multi-scale feature fusion

By combining generative adversarial networks with multi-scale feature fusion, the structure of the YOLOv8 network was improved, solving the problems of low efficiency and insufficient accuracy in rail surface defect detection, achieving more efficient defect detection results, and improving the robustness and accuracy of the detection model.

CN120598845AActive Publication Date: 2025-09-05LANZHOU JIAOTONG UNIV
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510541003.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-27
Publication Date
2025-09-05
Estimated Expiration
2045-04-27

AI Technical Summary

Technical Problem

Existing technologies for rail surface defect detection suffer from low detection efficiency and insufficient accuracy. In particular, it is difficult to effectively extract discriminative feature information in complex backgrounds, resulting in errors or omissions in the detection of small targets. The scarcity of defect images also increases the difficulty of detection.

Method used

The method of generative adversarial network and multi-scale feature fusion is adopted to construct a domain adaptation enhanced dataset through the StyleGAN3 model. The Backbone, Neck and Head parts of the YOLOv8 network are improved. A hybrid local channel attention mechanism and a lightweight adaptive weight downsampling module are introduced. Combined with the DetectAux auxiliary detection head, the feature extraction and detection process are optimized.

Benefits of technology

It significantly improves the accuracy and robustness of rail surface defect detection, enhances the generalization ability and detection performance of the model, can more effectively process complex images, and solves the accuracy and reliability problems of rail crack detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120598845A_ABST
    Figure CN120598845A_ABST
Patent Text Reader

Abstract

The invention discloses a railway steel rail surface defect detection method based on a generative adversarial network and multi-scale feature fusion, which comprises the following steps: firstly, inputting an acquired steel rail defect image into a StyleGAN3 model based on a transfer learning strategy to carry out domain adaptation enhancement, and constructing an enhanced data set; then, a railway steel rail surface defect detection model YOLOv8-GLCA is constructed on the basis of the YOLOv8n network, a C2fMLCA module is constructed, the C2fMLCA module is introduced into the sixth layer to the seventh layer of the Backbone network, and the C2fMLCA module and an LAWDS module are fused in the eighteenth layer to the nineteenth layer of the Neck network; the Head part adopts a DetectAux auxiliary detection head; a detection model YOLOv8-GLCA is obtained; the YOLOv8-GLCA is trained by using the enhanced data set, and a trained detection model is obtained; and finally, inputting a to-be-detected data set into the trained detection model for defect detection, and outputting a detection result. According to the method, the steel rail defects can be automatically identified, the positions of the steel rail defects can be marked, the accuracy and robustness of detection are remarkably improved, meanwhile, confidence scores are provided, and visual and accurate defect information is provided for railway maintenance personnel.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of rail surface defect detection, and specifically relates to a railway rail surface defect detection method based on a generative adversarial network and multi-scale feature fusion. Background Art

[0002] With the increasing frequency and heavier loads of rail transit operations, rail surface defects are becoming increasingly prominent. Traditional manual inspection methods, while cost-effective, are inefficient. Furthermore, methods such as laser ultrasonic and eddy current testing are limited in efficiency and environmental adaptability, making them inadequate for the inspection needs of modern railways, which cover tens of thousands of kilometers daily.

[0003] Machine vision-based inspection technology has become a research hotspot due to its advantages such as non-contact and high efficiency, but it faces multiple challenges in practical applications: the reflective effect on the rail surface weakens the defect characteristics, and the defect characteristics of irregular geometric boundaries and small target areas (common block damage, abrasions and microcracks, etc.) and sample scarcity restrict detection accuracy; heavy-duty railways are more prone to cross-sectional wear due to their large axle weight and high transportation volume. In addition, rail rust and stain pollution caused by harsh environments such as ports and mining areas significantly increase the complexity of the image background.

[0004] In recent years, domestic and foreign scholars have made significant progress in the field of rail surface defect detection. By integrating traditional image processing and deep learning technologies, they have proposed a number of innovative solutions to key problems in practical engineering. Related research mainly focuses on lightweight detection models, small target recognition, and multi-scale feature processing. In the development of lightweight detection systems, to address the problem that fully supervised methods rely on a large number of pixel-level annotations and the high cost of manual annotation, some studies have achieved accurate defect positioning using only 20% of the labeled data through a semi-supervised consistency training framework and a depth-assisted multi-scale cross-modal fusion module (DMCFM). To improve detection accuracy in complex scenarios, some studies have improved the YOLOv4 framework and enhanced the learning ability of rail defect edge features through a feature enhancement module, effectively overcoming detection bottlenecks such as small defect size and background texture interference. To address the problems of small targets and dense occlusion, some studies have introduced a multi-scale attention mechanism based on YOLOv8 to improve the positioning accuracy of small defects and occluded targets on the track surface.

[0005] Although convolutional neural network-based methods have made some progress in rail surface defect detection, achieving significant improvements in detection accuracy and ensuring efficient model operation through multi-faceted algorithm optimization, in-depth research on rail defects remains relatively insufficient. The scarcity of rail defect images poses numerous challenges for algorithmic detection. Furthermore, the small proportion of pixels occupied by defect targets in the image and their lack of distinct features make detection extremely challenging. Furthermore, some subtle defects are highly similar to the rail background, making it difficult for the network to effectively extract discriminative feature information, severely impacting detection accuracy. In such cases, the network may misidentify small cracks or even miss them entirely. Therefore, there is an urgent need to develop more sophisticated and efficient detection algorithms to address these challenges and improve the accuracy and reliability of rail crack detection. Summary of the Invention

[0006] In view of the problems existing in the above-mentioned background technology, the purpose of the present invention is to provide a railway rail surface defect detection method based on generative adversarial network and multi-scale feature fusion.

[0007] In order to achieve the above object, the present invention adopts the following technical solutions:

[0008] The railway rail surface defect detection method based on generative adversarial network and multi-scale feature fusion includes the following steps:

[0009] S1. Input the collected rail defect images into the StyleGAN3 model based on the transfer learning strategy for domain adaptation enhancement to construct an enhanced dataset;

[0010] S2. Build a railway rail surface defect detection model YOLOv8-GLCA

[0011] Based on the YOLOv8n network, the Bottleneck structure in the C2f module of the Backbone network in the YOLOv8 network is replaced with a hybrid local channel attention mechanism (MLCA) module to construct a C2f_MLCA ​​module. The C2f_MLCA ​​module constructs a cross-channel feature interaction matrix through the MLCA module and uses deformable convolution kernels to achieve dynamic receptive field adjustment. The C2f_MLCA ​​module is introduced into the 6th and 7th layers of the Backbone network in the YOLOv8 network, and the C2f_MLCA ​​module is fused with the lightweight adaptive weight downsampling (LAWDS) module in the 18th and 19th layers of the Neck network in the YOLOv8 network. The DetectAux auxiliary detection head is used in the Head part of the YOLOv8 network. The railway rail surface defect detection model YOLOv8-GLCA based on the generative adversarial network and multi-scale feature fusion is obtained.

[0012] S3. Using the enhanced data set, train the railway rail surface defect detection model YOLOv8-GLCA to obtain a trained railway rail surface defect detection model;

[0013] S4. Input the data set to be tested into the trained railway rail surface defect detection model to perform defect detection and output the detection results.

[0014] Furthermore, in S1, in the StyleGAN3 model based on the transfer learning strategy, the StyleGAN3 model uses an exponential moving average (EMA) for standardization to replace the skip connection structure, uses a low-pass upsampling filter to replace the bilinear 2x upsampling filter, and replaces the 3×3 convolution kernel with a 1×1 convolution kernel; removes the pixel noise input layer of the StyleGAN3 model and introduces a learning affine transformation module; and encapsulates the Leaky ReLU between upsampling and downsampling.

[0015] Furthermore, the method for constructing the enhanced dataset is:

[0016] First, the latent encoding vector z of the collected rail defect image is transformed into a style vector w through the mapping network;

[0017] Secondly, Fourier features are used to replace the traditional input constant, and a 1×1 convolution kernel and a low-pass upsampling filter are combined to process rail defect images.

[0018] Finally, the rail defect images are further processed by learning the affine transformation module, and the generated rail defect images are constructed as an enhanced dataset.

[0019] Furthermore, in S2, the DetectAux auxiliary detection head models label allocation as an optimal transmission problem by constructing a cost matrix, preferentially screening candidate boxes with high classification confidence and small positioning error as positive samples, and dynamically adjusts the weights of negative samples to suppress interference from ballast areas similar to rail features, and generates prediction boxes based on feature points.

[0020] Compared with the shortcomings and deficiencies of the prior art, the present invention has the following beneficial effects:

[0021] 1. In order to expand the collected image dataset through StyleGAN3, the present invention enriches the training samples of the detection model and enhances the generalization ability and robustness of the detection model;

[0022] 2. The detection model of the present invention is based on the YOLOv8n network. The MLCA model is added to the C2f module of the Backbone network to construct the C2f_MLCA ​​module, which enhances the interaction and fusion capabilities of the model in the feature extraction process, so that the detection model can more effectively integrate feature information of different levels and scales, thereby improving the understanding and analysis capabilities of complex images. The C2f_MLCA ​​module and the LAWDS module are integrated in the Neck network, and the accuracy and robustness of rail surface defect detection are effectively improved through the coordinated optimization of the dual-path attention mechanism and the dynamic feature selection strategy. The Head part uses the DetectAux auxiliary detection head, which helps the model to learn the characteristics and distribution patterns of defects more deeply by providing additional supervision information or optimization targets, thereby significantly improving the accuracy and robustness of detection, and further improving the detection performance of the detection model.

[0023] 3. The detection method of the present invention not only solves the problem of scarce rail crack image data, but also achieves breakthrough progress in the accuracy of rail defect detection. Compared with the detection methods of YOLOv5, YOLOv8, GD-YOLOv8, and YOLOv10, the detection accuracy of the detection method of the present invention is significantly improved, and its detection effect meets the standards and requirements of practical applications. It has significant superiority and practicality in the field of rail defect detection, and provides a strong guarantee for the safe operation and maintenance of rails. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 is a flow chart of a method for detecting surface defects of railway rails provided by an embodiment of the present invention;

[0025] Figure 2 is a structural diagram of the StyleGAN3 model based on the transfer learning strategy provided by an embodiment of the present invention;

[0026] Figure 3 This is a comparison diagram of the original rail defect image provided by an embodiment of the present invention and the rail defect image generated by the StyleGAN3 model based on the transfer learning strategy. In the figure, (a) is the original rail defect image, and (b) is the generated rail defect image;

[0027] Figure 4 is a structural diagram of a C2f_MLCA ​​module provided in an embodiment of the present invention;

[0028] Figure 5 This is a network structure diagram of the railway rail surface defect detection model YOLOv8-GLCA provided by an embodiment of the present invention;

[0029] Figure 6 is a network structure diagram of the MLCA provided by an embodiment of the present invention;

[0030] Figure 7 1 is a schematic diagram of the LAWDS module according to an embodiment of the present invention;

[0031] Figure 8 is a structural diagram of the DetectAux auxiliary detection head provided by an embodiment of the present invention;

[0032] Figure 9 is a comparison of PR curves of different models provided by an embodiment of the present invention. In the figure, (a) is the PR curve of the insulator and the damage, and (b) is the PR curve of the damage;

[0033] Figure 10 This is a comparison of the detection results of different models provided by the embodiments of the present invention. In the figure, (a) is YOLOv5, (b) is YOLOv8, (c) is YOLOv10, (d) is GD-YOLOv8, and (e) is YOLOv8-GLCA. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below in conjunction with specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0035] Example

[0036] The flow chart of the railway rail surface defect detection method based on generative adversarial network and multi-scale feature fusion proposed in this invention is shown in Figure 2. Figure 1 , the steps are as follows:

[0037] S1. To address the problem of scarce rail surface defect samples, the StyleGAN3 framework based on transfer learning is used to build a defect generation model. The structure of the StyleGAN3 model based on transfer learning strategy is as follows: Figure 2 As shown in the figure, the StyleGAN3 model uses an exponential moving average (EMA) normalization operation to replace the skip connection structure to prevent gradient vanishing; a low-pass upsampling filter replaces the bilinear 2x upsampling filter; the 3×3 convolution kernel of the StyleGAN3 model is replaced with a 1×1 convolution kernel; the pixel noise input layer of the StyleGAN3 model is removed and a learned affine transformation module is introduced; and the leaky ReLU is encapsulated between upsampling and downsampling. The network architecture of the StyleGAN3 model incorporates a transfer learning strategy and achieves the decoupling and controllable generation of defect features through a series of core modules.

[0038] The collected rail defect images are input into the StyleGAN3 model based on the transfer learning strategy for domain adaptation enhancement, enriching the diversity of defect samples and constructing an enhanced dataset. The method is as follows:

[0039] First, the latent encoding vector z of the captured rail defect image is transformed into a style vector w through a mapping network. This style vector is then injected into each layer of the synthesis network through the Adaptive Instance Normalization (AdaIN) module, achieving fine-grained control of features at different scales, including rail substrate texture and defect morphology.

[0040] Secondly, Fourier features are used instead of traditional input constants. This improvement effectively eliminates the texture adhesion caused by pixel-level position references. At the same time, a 1×1 convolution kernel and a low-pass upsampling filter are combined to process rail defect images, improving the geometric consistency of the generated images under continuous translation and rotation transformations.

[0041] Finally, the rail defect images are further processed by learning the affine transformation module to further enhance the network's ability to express defect structural features, and the generated rail defect images are constructed as an enhanced dataset.

[0042] Comparison of the original rail defect image and the rail defect image generated by the StyleGAN3 model based on the transfer learning strategy Figure 3 As shown, Figure 3 In the figure, (a) is the original rail defect image, and (b) is the rail defect image generated by the model. It can be seen that the generated image is highly consistent with the original data in terms of surface crack morphology, defect edge continuity, and local texture details.

[0043] S2. Build a railway rail surface defect detection model YOLOv8-GLCA

[0044] Based on the YOLOv8n network, the overall architecture is consistent with the YOLOv8 network, including the input end, Backbone network, Neck network and Head. The Backbone network replaces the Bottleneck structure in the C2f module of the Backbone network with a hybrid local channel attention mechanism (MLCA) module on the basis of retaining the original YOLOv8 feature pyramid structure, and constructs the C2f_MLCA ​​module. Its structure is as follows Figure 4As shown. The C2f_MLCA ​​module is introduced into the 6th-7th layers of the Backbone network. The C2f_MLCA ​​module constructs a cross-channel feature interaction matrix through the MLCA module, and uses deformable convolution kernels to achieve dynamic receptive field adjustment. In response to the needs of multi-scale target detection in complex scenarios, the C2f_MLCA ​​module and the lightweight adaptive weight downsampling (LAWDS) module are fused in the 18th-19th layers of the Neck network. The feature contribution evaluation function is established through the dynamic channel recalibration mechanism, and the efficiency of cross-scale feature interaction is improved by using a dual-path feature fusion strategy. In order to enhance the target positioning accuracy, the Head part adopts the DetectAux auxiliary detection head. The detection head adopts a feature pyramid distillation algorithm. By establishing a multi-level supervision signal, it realizes the accurate mapping from high-dimensional feature space to target positioning and classification, and effectively compensates for the cumulative error of coordinate regression in the traditional architecture. Finally, the railway rail surface defect detection model YOLOv8-GLCA based on generative adversarial network and multi-scale feature fusion is obtained. Its network structure is as shown below. Figure 5 As shown in the figure, it adopts a progressive architecture of "data enhancement-feature extraction-multi-scale fusion-cooperative detection", which consists of a StyleGAN3 data generation module, an improved Backbone network, an enhanced Neck network and a dual-path detection head to form a complete technical closed loop.

[0045] S3. Use the enhanced dataset to train the railway rail surface defect detection model YOLOv8-GLCA to improve the robustness and generalization ability of the algorithm, and obtain the trained railway rail surface defect detection model.

[0046] S4. Input the data set to be tested into the trained railway rail surface defect detection model to perform defect detection and output the detection results.

[0047] In the YOLOv8-GLCA model, the MLCA (Mixed local channel attention) module is introduced. It is a lightweight attention mechanism module that mixes local spatial information and global spatial information to achieve a balance between detection effect, speed and model parameter quantity, and enables the attention mechanism to include channel information, spatial information, local channel information and global channel information at the same time. The network structure of MLCA is as follows Figure 6 As shown in the figure, this module first applies local spatial pooling to the input features to generate a C×ks×ks local representation tensor. It then uses a two-way feature transformation path: the global branch uses global average pooling to extract global statistical features in the channel dimension, while the local branch uses spatial dimension expansion to preserve local spatial structure information. After the two features are interacted across channels through a one-dimensional convolution kernel, the original spatial resolution is restored through unpooling, and finally feature fusion is achieved through element-by-element addition.

[0048] When processing images using the C2f_MLCA ​​module, local spatial attention is first used to focus on key areas of rail damage, while dilated convolution is used to expand the receptive field and capture long-range dependencies. Channel-wise attention is then used to dynamically calibrate feature channel weights, strengthening effective features and suppressing redundant information. During training, multi-scale feature interaction branches are used to enhance the model's ability to represent subtle insulator defects. During inference, attention weight fusion and branch folding techniques are used to achieve a coordinated optimization of feature selection and information integration while maintaining single-path computational efficiency, achieving a balance between model lightweighting and detection robustness.

[0049] The LAWDS module is introduced into the YOLOv8-GLCA model. Through the coordinated optimization of the dual-path attention mechanism and the dynamic feature selection strategy, the accuracy and robustness of rail surface defect detection are effectively improved. Its framework structure is as follows: Figure 7 As shown in Figure 2, this module integrates a spatial-channel hybrid attention mechanism with an adaptive downsampling operation, optimizing the design to address the limitations of traditional fixed downsampling in complex industrial scenarios. During the backbone network feature extraction stage, LAWDS achieves adaptive fusion of multi-scale features through a dual-branch parallel processing architecture. The main branch performs basic downsampling through group convolution layers, while expanding the channel dimension by a factor of four to match the spatial decomposition requirements of neighborhood features. Tensor reshaping is then used to restructure the feature dimensions into a structure that matches the attention weights. Secondly, the auxiliary branch constructs a spatial attention mechanism using a cascade of local average pooling and convolution layers. The pooling operation captures local contextual prior information, while the convolution layer learns to generate a spatially adaptive attention distribution. The weights of the four sub-regions within the neighborhood are normalized using a softmax function, establishing a probability distribution model under spatial constraints. Finally, the expanded features and normalized weights are element-wise modulated through product multiplication, and a weighted sum operation is performed along the spatial dimension, achieving resolution reduction while maintaining feature discriminability.

[0050] The DetectAux auxiliary detection head is used in the YOLOv8-GLCA model, and its structure is as follows Figure 8As shown in the figure, a dynamic label assignment mechanism optimizes the adaptability of target features in complex scenarios for rail surface defect detection. Rail detection often faces challenges such as background interference, diverse rail surface defect morphologies, and small-scale or localized rust. The Assigner in the DetectAux auxiliary detection head adopts a dynamic strategy to adaptively adjust the matching threshold based on the statistical characteristics of the predicted and ground-truth boxes. To address the common problem of low-quality predicted boxes in rail detection, label assignment is modeled as an optimal transfer problem by constructing a cost matrix. Candidate boxes with high classification confidence and low localization error are prioritized as positive samples. The weights of negative samples are dynamically adjusted to suppress interference from ballast areas with similar rail features. Furthermore, rail detection is often affected by interference from ballast texture and light reflection, resulting in a large number of low-quality predicted boxes. Cross-layer label assignment is achieved through the Neck and Head of YOLOv8, enabling multi-scale feature synergy: low-level feature maps leverage their high resolution to capture the microscopic edge features of rail surface defects, while high-level feature maps leverage strong semantic information to perceive the overall rail orientation. Each layer independently calculates the optimal matching cost, enhancing the ability to jointly model local defect details and global structural features. YOLOv8 itself uses an anchor-free design, and the Assigner in the DetectAux auxiliary detection head further eliminates the size constraints of the preset anchor boxes and directly generates prediction boxes based on feature points. For rail inspection, this avoids the positioning errors caused by the fixed aspect ratio of traditional anchor boxes. It also combines loss to fine-tune the probability distribution of bounding box coordinates, significantly improving the localization accuracy of key points of rail surface defects.

[0051] Experimental results evaluation and analysis

[0052] 1. Experimental Platform

[0053] This experiment was conducted in the PyTorch environment, using Python 3.12.0 and CUDA 12.1. The software and hardware configuration required for the experiment are shown in Table 1:

[0054] Table 1 Software and hardware platform configuration parameters

[0055]

[0056]

[0057] In the experiment, the total number of iterations is 100, the input image pixel size is 640×640, the learning rate is set to 0.001, the training time is about 2.3 hours, and other hyperparameter settings are shown in Table 2:

[0058] Table 2 Experimental hyperparameter settings

[0059]

[0060] 2. YOLOv8-GLCA model performance evaluation indicators

[0061] In order to evaluate the performance of the detection model YOLOv8-GLCA constructed by the present invention, precision (P), recall (R), mean average precision (mAP), floating point operations (FLOPs) and frames per second (FPS) are used as the main evaluation indicators. Specifically, the calculation of precision and recall is based on true positives (TP), false positives (FP) and false negatives (FN), where TP represents the number of correct targets in the detection results, FP is the number of incorrect targets, and FN is the number of targets that were not correctly detected. In addition, the formulas for calculating mAP and FPS are given in detail to comprehensively measure the accuracy, efficiency and real-time performance of the method. The specific formulas are as follows:

[0062]

[0063] In the evaluation metrics, n represents the total number of image categories, i represents the number of detections, and AP is the average accuracy of a single category. For evaluating detection speed, Time represents the total time required to process the detection image, which is then used to calculate FPS. A higher FPS value indicates a faster detection rate and better real-time performance of the model.

[0064] 3. Comparative analysis of experimental results

[0065] (1) Comparison of different C2f modules

[0066] To evaluate the performance gain of the C2f_MLCA ​​module in the YOLOv8 object detection framework, a comparative ablation experiment was designed for the rail surface defect detection task. By comparing the C2f_MLCA ​​module with the current mainstream C2f architecture (including C2f variants), while maintaining strict consistency in module embedding positions and model hyperparameters, the impact of different feature extraction modules on network performance was systematically verified. The results are shown in Table 3:

[0067] Table 3 Comparison of different C2f modules

[0068]

[0069] According to the ablation experiment results shown in Table 3, when different variants of the C2f module are introduced into the YOLOv8 object detection framework, each improved solution exhibits differentiated detection performance on the same dataset. Among them, the improved model using the C2f_MLCA ​​structure significantly improves the detection accuracy of multi-scale objects while maintaining real-time detection efficiency. Compared with the original C2f, C2f_MLCA ​​improves the Precision of the first type by 12.2% and the Precision of the second type by 2%. In terms of the Recall metric, the improvement for the second type of objects also reaches 5%. From the perspective of comprehensive detection performance, the introduction of the C2f_MLCA ​​module into YOLOv8 improves the average mean precision (AP@0.5) of the first type of objects by 3.2% and the AP@0.5 of the second type of objects by 2.1%. The overall mAP@0.5 and mAP@0.5:0.95 achieve optimization gains of 2.6% and 1%, respectively. Although the C2f_MLCA ​​module consumes more GFLOPs than C2f_ODConv and C2f_Faster, it effectively enhances feature representation capabilities through a multi-dimensional long-range attention mechanism, demonstrating advantages in target localization accuracy under complex background interference and recall of occluded objects. This architecture achieves cross-scale feature fusion through a joint channel-spatial attention mechanism, demonstrating superior engineering applicability in balancing computational efficiency and detection accuracy. Therefore, this paper selected C2f_MLCA ​​to replace C2f to improve the model's performance in rail defect detection.

[0070] (2) Ablation experiment

[0071] To evaluate the effectiveness of modular improvements to the YOLOv8 architecture in object detection systems, we systematically validated its performance using a controlled variable ablation study while maintaining a consistent experimental setup and training strategy. However, due to the limited availability of the original dataset, all datasets used for model training and testing were obtained using a Generative Adversarial Network (GAN). The experimental results for these improvements based on the YOLOv8-G model are shown in Table 4.

[0072] Table 4 Comparison of models based on mAP

[0073]

[0074] Table 4 shows that the introduction of each optimization module effectively improves defect detection performance. Regarding single-module optimization, the introduction of LAWDS improves the YOLOv8-GL model's Type 1 defect detection accuracy by 3.5% and Type 2 by 0.6%. The overall mAP@0.5 score increases by 2.1%, but the mAP0.5-0.95 score decreases by 0.2%. The C2f_MLCA ​​module improves the YOLOv8-GC model's Type 1 and Type 2 defect detection accuracy by 3.2% and 2.1%, respectively, while simultaneously increasing mAP@0.5 and mAP@0.5:0.95 by 2.6% and 1.0%, respectively. The YOLOv8-GA model in the DetectAux module improves Type 1 and Type 2 defect detection accuracy by 5.2% and 0.9%, respectively, and overall mAP@0.5 and mAP0.5-0.95 scores by 2.6% and 1%, respectively. In dual-module combination experiments, the YOLOv8-GLC model combining LAWDS with C2f_MLCA ​​improved Type 1 accuracy by 4.6% and Type 2 accuracy by 1.5%. mAP@0.5 increased by 3.1%. The YOLOv8-GLA model combining LAWDS with DetectAux improved Type 1 and Type 2 accuracy by 2.6% and 0.6%, respectively, and its mAP@0.5 increased by 1.6%, but its mAP0.5-0.95 decreased by 1.3%. The YOLOv8-GCA model combining C2f_MLCA ​​with DetectAux improved Type 1 and Type 2 accuracy by 3.3% and 2.1%, respectively, and its mAP@0.5 and mAP0.5-0.95 increased by 1.6% and 0.7%, respectively. The performance gains from the dual-module combination did not significantly surpass those achieved by single-module optimization, and some metrics even showed negative fluctuations. When all three modules are simultaneously introduced, the Type 1 and Type 2 defect accuracy of the YOLOv8-GLCA model improves by 7.7% and 4.2%, and the overall mAP@0.5 and mAP0.5-0.95 of the model increase by 5.9% and 1.2%, respectively. Experimental data shows that the LAWDS, C2f_MLCA, and DetectAux modules form a complementary optimization mechanism through the synergy of feature enhancement, multi-scale context aggregation, and auxiliary supervision. LAWDS strengthens the representation of small object features, C2f_MLCA ​​optimizes cross-scale feature fusion, and DetectAux improves training stability through deep supervision. Together, these three modules effectively overcome the performance bottleneck of single-module and dual-module optimization.

[0075] Table 5 shows the comparison of the precision and recall rates of defect detection after each module is introduced into YOLOv8-G:

[0076] Table 5 Comparison model based on P and R

[0077]

[0078]

[0079] As shown in Table 5, the defect detection accuracy of each module has been improved after being introduced into YOLOv8-G. YOLOv8-GL improves the precision of Type 2 by 2.1%. The recall of Type 1 is improved by 3.7%. YOLOv8-GC improves the precision of Type 1 by 12.2%, and improves the precision and recall of Type 2 by 2% and 5%. YOLOv8-GA improves the precision of Type 1 by 23.1% and the precision of Type 2 by 1.7%. In the dual-module combination, YOLOv8-GLC improves the precision of Type 1 by 14.3%, and improves the precision and recall of Type 2 by 4.9% and 0.8%. YOLOv8-GLA improves the precision of Type 1 by 0.9% and the precision of Type 2 by 9.5%. YOLOv8-GCA improves the precision of Type 1 by 13.9%, and improves the precision and recall of Type 2 by 0.3% and 6.4%. YOLOv8-GLCA improved Type 1 Precision and Recall by 8.5% and 5.6%, and Type 2 Precision and Recall by 7.3% and 1.4%. Experimental results show that while the introduction of single or dual modules can partially improve specific metrics, the performance gain is localized. The three-module joint optimization strategy achieves comprehensive optimization of Precision-Recall metrics, validating the effectiveness of multi-module collaborative working mechanisms in rail defect detection tasks and providing a new technical path for improving the performance of industrial visual inspection systems.

[0080] In order to further evaluate the advantages of the detection model of the present invention, the mAP@0.5 curve and PR curve (refer to Figure 9) conducted further research and analysis, and conducted a comprehensive performance evaluation of the improved rail damage detection model based on the YOLOv8 architecture. Experimental results show that the baseline model YOLOv8-G has a slow convergence rate of mAP@0.5 indicators, and its Precision-Recall curve shows a rapid decay trend under the IoU=0.5 threshold. This indicates that the model falls into a local optimal solution too early during training, resulting in limited feature representation capabilities. In contrast, the six improved models, including YOLOv8-GL, YOLOv8-GC, YOLOv8-GA, YOLOv8-GLC, YOLOv8-GLA, and YOLOv8-GCA, show better convergence characteristics in terms of mAP@0.5 indicators, and their Precision-Recall curve decay rate is reduced. However, the performance difference between the improved models is only about 1%, which does not form a significant distinction. However, the mAP@0.5 curve of the YOLOv8-GLCA model proposed in this paper shows an exponential upward trend from the beginning of training (an 80% improvement in the first 50 epochs), while the PR curve achieves a gentle decrease while maintaining high accuracy. This performance improvement is due to the improved feature extraction efficiency brought about by multi-module collaborative optimization. Through the gradient guidance mechanism and attention recalibration strategy, the model's ability to learn fine-grained features in complex track scenarios is enhanced, verifying the effectiveness and robustness of this invention in rail surface defect detection tasks.

[0081] (3) Experimental comparison of different network models

[0082] To ensure systematic verification of the performance advantages of the YOLOv8-GLCA algorithm in rail defect detection, a strictly controlled comparative experimental scheme was adopted: all reference models (covering mainstream detection frameworks such as YOLOv5, YOLOv8, YOLOv10 and GD-YOLOv8) and the detection model of this invention were trained and evaluated based on exactly the same benchmark conditions. The training data set was uniformly pre-processed using the StyleGAN3 generative adversarial network, and the diversity of defect samples was effectively expanded through data enhancement. At the same time, the experimental parameter configuration of each model (including key hyperparameters such as learning rate strategy, batch size, and training cycle) was absolutely consistent with YOLOv8-GLCA and followed the same data set division ratio. The experimental data comparison is shown in Table 6:

[0083] Table 6 Comparison of various models

[0084]

[0085] Table 6 shows that the YOLOv8-GLCA detection model proposed in this paper demonstrates superior performance in rail defect identification tasks. In terms of core detection accuracy, the model comprehensively surpasses mainstream algorithms YOLOv5, YOLOv8, YOLOv10, and the modified GD-YOLOv8. Experimental results show that YOLOv8-GLCA's mAP@0.5 metric improves by 5.9% compared to YOLOv8. While maintaining class balance, the recognition accuracy for small target defects Type 1 and Type 2 reaches 94% and 89.9%, respectively, which are 42.5% and 44.7% higher than the GD-YOLOv8 model. Furthermore, the model performs particularly well in terms of recall. By introducing an adaptive anchor box optimization strategy and a dynamic threshold mechanism, it effectively reduces the missed detection rate under complex lighting conditions, significantly improving the stability of defect detection in practical engineering applications. Although the YOLOv8-GLCA model consumes 0.9 more GFLOPs than GD-YOLOv8, this slight increase in computational power yields a significant return in accuracy. Taking into account detection accuracy, real-time performance, and engineering practicality, YOLOv8-GLCA demonstrates superior overall performance in intelligent rail inspection scenarios. This model maintains high detection efficiency while providing railway operations and maintenance departments with more reliable defect diagnosis. This has significant engineering application value for improving railway transportation safety.

[0086] In order to objectively evaluate the actual detection performance of the present invention in real railway scenarios, a set of comparative experiments based on field collected data were designed and implemented, such as Figure 10 As shown in Figure 2, a real track surface dataset containing complex lighting conditions and multi-scale defect samples. Figure 10A comparison of field inspection results (a)-10(e) reveals significant performance differences between different algorithms in real-world rail surface defect detection tasks. Experimental data reveals that the YOLOv5 and GD-YOLOv8 models exhibit significant shortcomings in complex scene detection. Both models have a high rate of missed detection of low-contrast cracks and rusted areas, and the detection accuracy of both models is below 60%, reflecting their limitations in feature extraction and scale adaptability. Although YOLOv8 and YOLOv10 have improved their average accuracy to approximately 73% through a hierarchical feature fusion strategy, blind spots still exist in small-scale defect detection, especially under extreme conditions such as sudden changes in illumination and motion blur. The YOLOv8-GLCA model proposed in this paper achieves improved detection performance in real-world testing by coupling global context awareness with local detail enhancement mechanisms, achieving detection accuracy of approximately 91%. Furthermore, the proposed algorithm significantly enhances the model's interference tolerance in complex environments through the effective interaction of multi-scale features. Furthermore, its adaptive spatial attention mechanism significantly improves the quality of feature representation for small defects, enabling precise location of defects. This algorithm not only provides a high-precision intelligent detection solution for the railway sector, but its outstanding engineering adaptability also lays a solid technical foundation for the integrated "discovery, location, and assessment" of rail defects.

[0087] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A railway rail surface defect detection method based on generative adversarial networks and multi-scale feature fusion, characterized by: The steps include: S1. Input the collected rail defect images into the StyleGAN3 model based on the transfer learning strategy for domain adaptation enhancement to construct an enhanced dataset; S2. Build a railway rail surface defect detection model YOLOv8-GLCA Based on the YOLOv8n network, the Bottleneck structure in the C2f module of the Backbone network in the YOLOv8 network is replaced with the MLCA module to construct the C2f_MLCA ​​module. The C2f_MLCA ​​module constructs a cross-channel feature interaction matrix through the MLCA module and uses deformable convolution kernels to achieve dynamic receptive field adjustment. The C2f_MLCA ​​module is introduced into the 6th and 7th layers of the Backbone network in the YOLOv8 network, and the C2f_MLCA ​​module is fused with the LAWDS module in the 18th and 19th layers of the Neck network in the YOLOv8 network. The DetectAux auxiliary detection head is used in the Head part of the YOLOv8 network. The railway rail surface defect detection model YOLOv8-GLCA based on the generative adversarial network and multi-scale feature fusion is obtained. S3. Using the enhanced data set, train the railway rail surface defect detection model YOLOv8-GLCA to obtain a trained railway rail surface defect detection model; S4. Input the data set to be tested into the trained railway rail surface defect detection model to perform defect detection and output the detection results.

2. The railway rail surface defect detection method based on generative adversarial network and multi-scale feature fusion according to claim 1 is characterized in that: In S1, the StyleGAN3 model uses an exponential moving average (EMA) standardization operation to replace the skip connection structure, a low-pass upsampling filter is used to replace the bilinear 2x upsampling filter, and the 3×3 convolution kernel is replaced by a 1×1 convolution kernel; the pixel noise input layer of the StyleGAN3 model is removed and a learning affine transformation module is introduced; and the Leaky ReLU is encapsulated between upsampling and downsampling.

3. The railway rail surface defect detection method based on generative adversarial network and multi-scale feature fusion according to claim 2, characterized in that: The method for constructing the enhanced dataset is: First, the latent encoding vector of the collected rail defect image is transformed into a style vector through the mapping network; Secondly, Fourier features are used to replace the traditional input constant, and a 1×1 convolution kernel and a low-pass upsampling filter are combined to process rail defect images. Finally, the rail defect images are further processed by learning the affine transformation module, and the generated rail defect images are constructed as an enhanced dataset.

4. The railway rail surface defect detection method based on generative adversarial network and multi-scale feature fusion according to claim 1, characterized in that: In S2, the DetectAux auxiliary detection head models label assignment as an optimal transmission problem by constructing a cost matrix, preferentially screening candidate boxes with high classification confidence and small positioning error as positive samples, and dynamically adjusts the weights of negative samples to suppress interference from ballast areas similar to rail features, and generates prediction boxes based on feature points.

Citation Information

Patent Citations

  • Aluminum material surface defect detection method for enhancing multi-scale feature extraction and target detection

    CN118799268A

  • Improved YOLOv8-based steel surface defect target detection method

    CN118823299A

  • Object detection using multiple object detectors

    WO2024236073A1

  • Small sample steel defect detection method based on attention feature pyramid mechanism

    WO2025010883A1