Railway track surface defect detection method based on improved YOLOv11 network cooperative optimization
By improving the YOLOv11 network and camera stabilization adjustment device, and combining the attention mechanism and WIoU loss function, the problems of low detection efficiency and insufficient accuracy in railway track surface defect detection have been solved, and high-precision automated detection in complex environments has been achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HEFEI UNIV OF TECH
- Filing Date
- 2026-03-03
- Publication Date
- 2026-05-29
Smart Images

Figure CN122115397A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision, deep learning and railway safety inspection technology, specifically to a method for detecting defects on railway track surfaces based on an improved YOLOv11 network. Background Technology
[0002] During long-term service, railway rails are prone to various surface defects such as rust, peeling, cracks, and spalling due to factors such as train loads, environmental erosion, and material fatigue. If these surface defects are not detected and addressed in a timely manner, they will seriously threaten train operation safety. Currently, rail defect detection mainly relies on manual inspections or traditional non-destructive testing equipment. These methods suffer from low efficiency, high subjectivity, high cost, and difficulty in achieving all-weather, large-scale automated inspection.
[0003] In recent years, deep learning-based object detection technology has made significant progress in the field of industrial vision inspection. The YOLO series of algorithms, due to their end-to-end and real-time characteristics, have been widely used in object detection tasks. However, current deep learning-based detection methods (such as the conventional YOLO series) suffer from the following challenges in complex railway environments: (1) The environmental background is extremely complex: the texture of the ballast crushed stone is highly similar to that of the small defects, which can easily lead to false detection.
[0004] (2) Large target scale: Due to the perspective effect, the defects in the rail are large in the near and small in the far. The standard loss function has low detection accuracy for small targets.
[0005] (3) Note noise interference: Due to the shooting angle, some defect boundaries are blurred, making it difficult to achieve high-precision regression.
[0006] (4) Unstable hardware acquisition: Traditional camera fixed devices are easily affected by vibration during the operation of the flaw detection vehicle, resulting in blurred images and further reducing the reliability of detection. Summary of the Invention
[0007] This invention addresses the shortcomings of existing technologies by proposing a railway track surface defect detection method based on an improved YOLOv11. The method aims to significantly improve the detection accuracy and robustness of small track surface defects in complex environments, while maintaining the model's lightweight and real-time performance. This effectively solves problems such as large differences in target scale, complex backgrounds, and severe perspective distortion in track defect detection, making it suitable for automated defect identification tasks in railway inspection systems.
[0008] To achieve the above-mentioned objectives, the present invention adopts the following technical solution: The present invention provides a method for detecting surface defects on railway tracks based on an improved YOLOv11 network, characterized by the following steps: Step 1: Construct a sample dataset of railway track surface defects; Step 1.1: Use a camera stabilization device to acquire original images of the rail surface containing defective targets under different lighting and background conditions, and perform preprocessing to obtain a preprocessed rail surface image sequence. ;in, This represents the nth rail surface image, and N represents the total number of rail surface images. Step 1.2: Use annotation tools to... The target defects are labeled to obtain... The Information from each real defect annotation box ,in, For the first The coordinates of the center point of a real defect annotation box The first The width and height of a real defect annotation box; Step 2: Build the improved The network comprises a backbone feature extraction module, a deep feature optimization module, a feature fusion module, and a detection head, connected sequentially, and performs... Processing is performed to obtain The Defect prediction box ; Step 2.1: The backbone feature extraction module performs... Multi-layer convolution and downsampling are performed to obtain the nth feature map containing information on rail surface defects and potential defects. ; Step 2.2: The deep feature optimization module includes: a channel-spatial attention unit and a parameterless attention unit, and performs... The process is performed to obtain the fused feature map at the j-th scale; Step 2.2.1: The channel-spatial attention unit pair The process is performed to obtain the nth texture enhancement feature map. ; Step 2.2.2: The parameterless attention unit pair The process is performed to obtain the nth high signal-to-noise ratio defect feature map. ; Step 2.3: The feature fusion module will... Multi-scale fusion is performed with the intermediate layer features of the backbone feature extraction module to obtain the nth multi-scale fused feature map. ,in, Let J represent the j-th scale fused feature map, and J represent the number of scales contained in the n-th multi-scale fused feature map; Step 2.4: The detection head pairs Decoding is performed to obtain a size of The j-th scale grid, thus obtaining from the J-th scale grid The Defect prediction box ,in, Indicates the first The coordinates of the center point of each defect prediction bounding box and The first The width and height of each defect prediction box, This represents the confidence level of the i-th defect prediction box; This represents the row number of the grid at scale j. This represents the number of columns in the grid at the j-th scale. Step 3: Based on and Construct the total loss function ; Step 4: Improve the algorithm using the SGD optimizer. The network undergoes iterative training, and the total loss function is calculated. Adjust the network parameters until the total loss function is achieved. The process continues until convergence, thus obtaining a trained rail defect detection model, which is used to predict defects in the input original image of the rail surface.
[0009] The railway track surface defect detection method based on improved YOLOv11 network collaborative optimization described in this invention is also characterized in that the camera stabilization adjustment device sequentially includes: a robotic arm body, a Z-axis shock absorber, and a gimbal module; The main body of the simulated robotic arm includes: a rubber pad, a base, a rotating turntable, a rotary motor one, a rotary motor two, a telescopic arm, and a main arm support assembly; The rubber pad is located at the connection between the base and the detection vehicle body to achieve a flexible connection between the robotic arm body and the detection vehicle body. A rotating turntable is provided on the base and connected to the lower end of the telescopic arm via a rotating motor one. The upper end of the telescopic arm is connected to one end of the main arm support assembly via a rotating motor two. The main body of the simulated robotic arm is driven by rotating motor one and rotating motor two to swing the telescopic arm along the rail plane and rotate around the axis of the rail under the action of the rotating turntable. The Z-axis damper includes: a parallel linkage mechanism and a damper; One end of the parallel linkage mechanism and one end of the shock absorber are respectively connected to the other end of the main arm support assembly of the simulated robotic arm body. The other ends of the parallel linkage mechanism and the shock absorber are respectively connected to the gimbal module. The gimbal module remains parallel to the ground under the action of the parallel linkage mechanism. The shock absorber is used to attenuate the low- and medium-frequency vibrations generated by the detection vehicle body during driving. The gimbal module includes: an upper gimbal frame, airbags, a lower gimbal frame, a camera, and a servo motor; the upper gimbal frame is connected to the shock absorber of the Z-axis shock absorber, and the upper gimbal frame and the lower gimbal frame are elastically connected by several airbags, which are used to attenuate the high-frequency vibrations generated by the detection vehicle body during driving. The camera is mounted on the lower frame of the gimbal, and the servo motor is connected to the camera via a transmission mechanism to drive the camera to achieve vertical angle adjustment.
[0010] Furthermore, in the deep feature optimization module, step 2.2.1 includes: Step a: Perform the following on the channel dimension respectively Perform global average pooling and global max pooling operations to generate the nth average pooling feature. and max pooling features Thus, the attention map of the nth channel can be obtained using equation (1). And the weighted enhancement features of the nth channel are obtained through equation (2). ; (1) (2) In equation (1), represents the sigmoid activation function, and MLP represents the multilayer perceptron; In equation (2), This indicates element-wise multiplication; Step b: Perform the following on the spatial dimensions respectively Perform global average pooling and global max pooling operations to generate the nth average pooling feature. and max pooling features Thus, the nth spatial attention map is obtained using equation (3). And the nth texture enhancement feature map is obtained using equation (4). : (3) (4) In equations (3) and (4), Indicates the convolution operation; This indicates a splicing operation.
[0011] Furthermore, in step 2.2.2, the nth texture enhancement feature map is calculated using equation (5). Position on the m-th channel Energy value at the location After processing the energy value at each position on all channels using the sigmoid function, the nth energy weight map is obtained. Thus, the nth high signal-to-noise ratio defect feature map is obtained using equation (6). : (5) (6) In equation (5), and They are respectively The mean and variance of pixel values in the m-th channel The regularization coefficient is used. for Position on the m-th channel The pixel value at that location.
[0012] Furthermore, step 3 includes: Step 3.1: Construct the i-th regression loss function using equation (7) ; (7) In equation (7), Indicates outlier degree. Two adjustable parameters, and Represents the i-th defect prediction box With the i-th real defect annotation box The minimum width and minimum height of the enclosure; Step 3.2: Construct the i-th classification loss function using equation (8) ; (8) In equation (8), Represents the i-th defect prediction box Does it include the first A label for a real defect; if included, then... =1, otherwise, let =0; Step 3.3: Based on J scale grids, construct the i-th distributed focal length loss function using equation (9). ; (9) In equation (9), Let represent the set of all grid locations at the j-th scale that contain the i-th true defect annotation box. This represents the distance from the grid center point at position (h, w) on the j-th scale to the grid center point at the j-th scale. The distance between the actual defect annotation boxes , These represent the predicted distances from the grid center point at position (h, w) to the i-th defect, respectively. The probability, Indicates rounding up; Step 3.4: Construct the total loss function using equation (10) ; (10) In equation (10), , and These are the corresponding weight coefficients, and I represents the total number of defect prediction boxes.
[0013] The present invention provides an electronic device, including a memory and a processor, characterized in that the memory is used to store a program that supports the processor in executing the rail surface defect detection method, and the processor is configured to execute the program stored in the memory.
[0014] The present invention discloses a computer-readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, performs the steps of the rail surface defect detection method.
[0015] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. Synergistic optimization of feature enhancement and background suppression: Following the SPPF layer at the end of the backbone network, the CBAM and SimAM attention modules are sequentially coupled to form an integrated unit for feature enhancement and background suppression. The CBAM module focuses on key features in the railhead region through channel attention and enhances the defect location response through spatial attention; the SimAM module adaptively suppresses background noise such as ballast and corrosion based on an energy function. This sequential coupling achieves a coherent processing from feature enhancement to background suppression, significantly improving the detection saliency of small defects.
[0016] 2. Improved robustness of bounding box regression: To address the characteristics of railway track defects, such as large scale variations, elongated shapes, and blurred boundaries, the WIoU loss function is employed for bounding box regression. This function, through a dynamic weighting mechanism, differentiates samples of varying difficulty, significantly improving the localization accuracy and regression stability for small targets and challenging samples.
[0017] 3. Optimizing the balance between accuracy and efficiency: The CBAM structure is lightweight, and SimAM has no additional trainable parameters. The serial coupling of the two enhances sensing capabilities while having minimal impact on computational complexity. Combined with the efficient architecture of YOLOv11, this invention achieves a significant improvement in detection accuracy while maintaining high inference speed, meeting the real-time detection requirements of railways.
[0018] 4. Excellent engineering applicability and generalization ability: Each improved module has a clear division of labor and strong synergy within the network. In particular, the attention coupling unit built at the backbone end effectively enhances the model's adaptability to complex railway environments. Experiments show that the method performs stably under different lighting conditions, line sections, and defect types, possessing good generalization ability and engineering deployment value, and can be integrated into vehicle-mounted or fixed railway intelligent inspection systems.
[0019] 5. Software and hardware co-optimization: The hardware device ensures image acquisition quality through multi-level vibration reduction and fine adjustment; the software algorithm enhances defect features through an attention mechanism, and the combination of the two significantly improves detection saliency. Attached Figure Description
[0020] Figure 1 This is a flowchart of the method of the present invention; Figure 2 This is a schematic diagram of the camera stabilization adjustment device of the present invention; Figure 3a This is a network structure diagram of the present invention; Figure 3b This is a diagram of the deep feature optimization module of the present invention; Figure 4 This is a diagram showing the detection results of the present invention; The following components are labeled in the diagram: 1. Rubber pad; 2. Base; 3. Rotary turntable; 4. Rotary motor one; 5. Rotary motor two; 6. Telescopic arm; 7. Main arm support assembly; 8. Parallel linkage mechanism; 9. Shock absorber; 10. Upper frame of the gimbal; 11. Airbag; 12. Lower frame of the gimbal; 13. Camera; 14. Servo motor. Detailed Implementation
[0021] In this embodiment, to address the issues of insufficient detection accuracy and weak generalization ability, a railway track surface defect detection method based on an improved YOLOv11 network is proposed. Through hardware and software co-optimization, an attention mechanism unit serially coupled with SimAM is constructed at the end of the backbone network to collaboratively achieve feature enhancement and background suppression. Furthermore, the WIoU loss function is used to optimize bounding box regression, thereby improving the accuracy, stability, and detection precision of defect identification. The process is as follows: Figure 1 As shown, the method includes the following steps: Step 1: As Figure 2As shown, a camera stabilization and adjustment device is constructed. Step 1.1: To address the problem of image blurring and fixed shooting angle caused by vibration during the operation of traditional camera fixing devices in railway track inspection vehicles, thus reducing the reliability of rail defect detection, a multi-degree-of-freedom, multi-level vibration damping, and finely adjustable camera stabilization and adjustment device was designed. This device is adapted to the complex operating conditions of railway track inspection vehicles, ensuring the clarity, stability, and positional accuracy of track surface image acquisition, providing a high-quality image data foundation for subsequent defect detection algorithms. The overall structure of the camera stabilization and adjustment device is shown in Figure 1, comprising three main functional units: a robotic arm-like main body, a Z-axis vibration damper, and a gimbal module. The robotic arm-like main body enables multi-degree-of-freedom spatial adjustment of the device; the Z-axis vibration damper attenuates low-to-medium frequency vibrations generated by the movement of the inspection vehicle; and the gimbal module suppresses high-frequency vibrations and finely adjusts the camera angle. These three components work together to ensure the camera's shooting stability from both spatial positioning and vibration suppression perspectives.
[0022] Step 1.2: Implementation details of the robotic arm body: The robotic arm body serves as the basic support and coarse adjustment unit of the device, including: rubber pad 1, base 2, rotating turntable 3, rotary motor 1 4, rotary motor 2 5, telescopic arm 6, and main arm support assembly 7. It enables the camera to rotate and extend in multiple directions in space, adapting to the shooting requirements of different track types and different detection distances, while also completing the initial attenuation of vibration.
[0023] Step 1.2.1: Flexible connection and initial damping: A rubber pad 1 is installed at the connection between the base 2 and the inspection vehicle body. It is made of nitrile rubber with a Shore hardness of 60±5HA, which has good elasticity and anti-aging properties. It realizes a flexible connection between the robotic arm body and the inspection vehicle body, effectively attenuating the high-frequency vibration transmitted during the movement of the flaw detection vehicle, and avoiding the vibration caused by the rigid connection from being directly transmitted to the camera.
[0024] Step 1.2.2: Realizing rotational and oscillating degrees of freedom: A rotating turntable 3 is set on the base 2, driven by a stepper motor with a rotation accuracy of 0.5°. It can drive the entire simulated robotic arm body to rotate 360° around the axis of the railway track, realizing the full-angle adjustment of the camera in the horizontal circumference, and adapting to the detection needs on both sides of the railway track. The rotating turntable 3 is connected to the lower end of the telescopic arm 6 via a rotating motor 4. The telescopic arm 6 is a structure with a telescopic stroke of 0-50cm, and the horizontal distance between the camera and the rail can be adjusted according to the detection distance. The upper end of the telescopic arm 6 is connected to one end of the main arm support assembly 7 via a rotary motor 2 5. Both the rotary motor 1 4 and the rotary motor 2 5 are servo motors, which work together to drive the telescopic arm 6 to swing back and forth and left and right along the rail plane, thereby achieving coarse adjustment of the spatial position of the camera in the rail plane and ensuring that the camera is aligned with the detection area.
[0025] Step 1.2.3: The main arm support assembly 7 is made of aluminum alloy profile in one piece, which is lightweight and has high structural strength. The bending strength is ≥200MPa, which can effectively support the weight of the gimbal module and camera, while reducing its own vibration and deformation, and ensuring the overall structural stability of the device.
[0026] Step 1.3: Implementation details of the Z-axis vibration damper: Step 1.3.1: The Z-axis shock absorber is connected between the simulated robotic arm body and the gimbal module. It includes a parallel linkage mechanism 8 and a shock absorber 9. Its core function is to attenuate the low-to-medium frequency vibration (vibration frequency 5-50Hz) generated by the flaw detection vehicle moving in the Z direction (vertical direction) and to ensure that the gimbal module is always parallel to the ground to avoid tilting or distortion of the captured images.
[0027] Step 1.3.2: Low- and medium-frequency vibration attenuation: The shock absorber 9 is a hydraulic shock absorber with an internal composite spring and silicone oil damping structure. The spring stiffness is 10 N / mm, and the damping coefficient can be steplessly adjusted via a threaded knob. The adjustment range is 0.5-5 N·s / m. The damping force can be adjusted according to the travel speed of the flaw detection vehicle (0-80 km / h) and the flatness of the track to achieve precise attenuation of low- and medium-frequency vibrations of different amplitudes.
[0028] Step 1.3.3: Maintaining Levelness: The parallel linkage mechanism 8 is a four-bar parallel structure made of high-strength engineering plastic. The kinematic pairs are self-lubricating bearings. One end of the mechanism is connected to the other end of the main arm support assembly 7, and the other end is connected to the gimbal top frame 10 of the gimbal module, forming a double support structure in conjunction with the shock absorber 9. The rotary motor 1 and the rotary belt motor 2 ensure that the main arm support assembly 7 remains parallel to the ground. Regardless of the swing angle of the simulated robotic arm body, the parallel linkage mechanism 8 can constrain the spatial posture of the gimbal module, ensuring that the shooting end face of the gimbal module always remains parallel to the ground.
[0029] Step 1.4: The gimbal module is the end effector of the device, including the upper gimbal frame 10, airbag 11, lower gimbal frame 12, camera 13 and servo motor 14. It completes the final attenuation of high-frequency vibration and fine adjustment of the vertical angle of the camera, and is the core unit to ensure the clarity of image acquisition.
[0030] Step 1.4.1: High-frequency vibration suppression: The upper frame 10 of the gimbal is connected to the damper 9 of the Z-axis damper. Four independent airbags 11 are evenly arranged between the upper frame 10 and the lower frame 12 of the gimbal. The airbags 11 are made of butyl rubber and filled with nitrogen gas at an inflation pressure of 0.3-0.5MPa. They use gas damping as the main component and rubber elasticity as a supplement to replace traditional rubber or spring damping components. They effectively attenuate the high-frequency vibration (vibration frequency 50-200Hz) generated by the movement of the flaw detection vehicle, with a vibration attenuation rate ≥90%. At the same time, the elastic support of the airbags 11 can effectively absorb instantaneous impact vibration, avoiding hardware damage or image blurring of the camera due to severe impact.
[0031] Step 1.4.2: Fine adjustment of the vertical angle of the camera: The camera 13 is fixedly installed at the center of the lower frame 12 of the pan-tilt unit. A 20-megapixel line array industrial camera with a frame rate of 120fps is selected to meet the image acquisition requirements of high-speed flaw detection. The servo motor 14 is connected to the camera 13. The servo motor 14 is a digital servo motor with a rotation accuracy of 0.1° and a vertical rotation range of ±45°. The shooting angle of the camera can be finely adjusted according to the rail surface angle and the travel height of the flaw detection vehicle to ensure the flaw detection requirements of different camera angles.
[0032] Step 2: Construct a sample dataset of rail surface defects; Step 2.1: Use a camera stabilization device to acquire original images of the rail surface containing defective targets under different lighting and background conditions, and perform preprocessing to obtain a preprocessed rail surface image sequence. ;in, This represents the nth rail surface image, and N represents the total number of rail surface images. Step 2.2: Use annotation tools to... The target defects are labeled to obtain... The Information from each real defect annotation box ,in, For the first The coordinates of the center point of a real defect annotation box The first The width and height of a real defect annotation box.
[0033] In practice, the original images are often of varying sizes and contain a lot of useless information. In this embodiment, a total of 2,400 original images were collected. During the preprocessing stage, the image scale was normalized to 640×640 pixels, and random flipping and brightness adjustment were performed. The labelimg annotation tool was used for manual annotation, and the types of defects on the railway track surface were divided into four categories: dents, wheel burns, rail surface spalling, and wave wear. Finally, the ratio of training set, validation set, and test set was 8:1:1.
[0034] Step 3: Build the improved The network comprises a backbone feature extraction module, a deep feature optimization module, a feature fusion module, and a detection head, connected in sequence. Its network structure is as follows: Figure 3a As shown, YOLOv11n is used as the basic structure.
[0035] Step 3.1: The backbone feature extraction module extracts... Multi-layer convolution and downsampling are performed to obtain the nth feature map containing information on rail surface defects and potential defects. ; Step 3.2: The deep feature optimization module includes: channel-spatial attention units and parameterless attention units, and its processing is as follows: Figure 3b As shown; Step 3.2.1: The channel-spatial attention unit performs attention on the channel dimension respectively. Perform global average pooling and global max pooling operations to generate the nth average pooling feature. and max pooling features Both are fed into a shared multilayer perceptron, the output features are summed, and then passed through a sigmoid activation function to obtain the channel attention map. That is, equation (1), and the enhanced features of the nth channel after weighting are obtained through equation (2). ; (1) (2) In equation (1), represents the sigmoid activation function, and MLP represents the multilayer perceptron; In equation (2), This indicates element-wise multiplication.
[0036] In terms of spatial dimension, respectively Perform global average pooling and global max pooling operations to generate the nth average pooling feature. and max pooling features Thus, the nth spatial attention map is obtained using equation (3). And the nth texture enhancement feature map is obtained using equation (4). : (3) (4) In equations (3) and (4), Indicates the convolution operation; This indicates a splicing operation.
[0037] Channel attention can adaptively learn the importance of different channels and assign weights accordingly. For rail surface defect detection, some channels respond strongly to the specific texture of "rail surface peeling," while others are sensitive to the edges of "dents." Through the attention mechanism, these defect-sensitive channels can be enhanced, while irrelevant channel responses can be suppressed. Spatial attention can effectively capture the structural information of spatial location, accurately locate the specific physical coordinates of defects such as "dents" and "peeling," thereby achieving texture enhancement. This allows the network to focus more on the local area where the defect is located, achieving feature enhancement in the spatial dimension.
[0038] Step 3.2.2: The parameterless attention unit calculates the nth texture enhancement feature map using equation (5). Position on the m-th channel Energy value at the location After processing the energy value at each position on all channels using the sigmoid function, the nth energy weight map is obtained. Thus, the nth high signal-to-noise ratio defect feature map is obtained using equation (6). : (5) (6) In equation (5), and They are respectively The mean and variance of pixel values in the m-th channel The regularization coefficient is used. for Position on the m-th channel The pixel value at that location.
[0039] Equation (5) measures the linear separability of a pixel with all pixel values in the current channel. The lower the energy value of the current pixel, the greater its difference from the surrounding environment, and therefore its higher importance. In a railway track image, an isolated, small crack pixel will have a very low energy value and thus be assigned a higher weight. In this embodiment, the regularization coefficient... Set as .
[0040] This embodiment introduces [a feature] at the end of the backbone network. and The serial coupling structure is designed to first pass through Enhance the channel and spatial response of the defective area, and then through Suppressing background noise and the combined effect of these two methods significantly improves the model's robustness in complex environments. Meanwhile, As a parameterless attention module, it does not introduce additional computational burden, thus ensuring the real-time performance of the model.
[0041] Step 3.3: The feature fusion module combines the nth high signal-to-noise ratio defect feature map. Multi-scale fusion is performed with the intermediate layer features of the backbone feature extraction module to obtain the nth multi-scale fused feature map. ,in, Let J represent the j-th scale fusion feature map, and J represent the number of scales contained in the n-th multi-scale fusion feature map; in this example, J=3, which corresponds to the three target detection scales of large, medium and small respectively.
[0042] Step 3.4: The detection head pair Decoding is performed to divide it into sizes of The j-th scale grid, and obtained from the J-th scale grid The Defect prediction box ,in, Indicates the first The coordinates of the center point of each defect prediction bounding box and The first The width and height of each defect prediction box, This represents the confidence level of the i-th defect prediction box; This represents the row number of the grid at scale j. This represents the number of columns in the grid at the j-th scale. Step 4: Based on and Construct the total loss function ; Step 4.1: Construct the i-th regression loss function using equation (7) ; (7) In equation (7), Indicates outlier degree. Two adjustable parameters, and Represents the i-th defect prediction box With the i-th real defect annotation box The minimum width and minimum height enclosed; WIoU automatically assigns gradient weights to samples of different difficulty levels based on the outlier β of the samples through a dynamic, non-monotonic focusing mechanism. For difficult samples with high outlier β, such as small, blurry defects, a larger optimization weight is given; for simple samples with low outlier β, the weight is appropriately reduced.
[0043] Step 4.2: Construct the i-th classification loss function using equation (8) ; (8) In equation (8), Represents the i-th defect prediction box Does it include the first A label for a real defect; if included, then... =1, otherwise, let =0.
[0044] Step 3.3: Based on J scale grids, construct the i-th distributed focal length loss function using equation (9). ; (9) In equation (9), This represents the set of all grid locations at the j-th scale that contain the i-th true defect annotation box. This represents the distance from the grid center point at position (h, w) on the i-th scale to the i-th grid. The distance between the actual defect annotation boxes , These represent the predicted distances from the grid center point at position (h, w) to the i-th defect, respectively. The probability, This indicates rounding up; in actual images, the edges of defects on the rail surface are very blurry, and there is no absolutely clear physical boundary. DFL transforms the originally defined bounding box into a continuous probability distribution, thus more scientifically tolerating the interference caused by the blurry edges of real defects.
[0045] Step 4.4: Construct the total loss function using equation (10) ; (10) In equation (10), , and These are the corresponding weight coefficients, and I represents the total number of defect prediction boxes.
[0046] Step 5: Improve the SGD optimizer The network undergoes iterative training, and the total loss function is calculated. Adjust the network parameters until the total loss function is achieved. The training continues until convergence, resulting in a trained rail defect detection model used to predict defects in the input raw rail surface image. During training, an initial learning rate of 0.001 and a batch size of 16 are set, and training is performed for 260 epochs.
[0047] In this embodiment, an electronic device includes a memory and a processor. The memory stores a program that supports the processor in executing the above-described method for detecting defects on the rail surface. The processor is configured to execute the program stored in the memory.
[0048] In this embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is run by a processor, it executes the steps of the above-described method for detecting defects on the rail surface.
[0049] Results analysis: This experiment used precision, recall, mean precision (AP0.5), and AP0.5:0.95 to quantitatively analyze the proposed method and the comparative method. The results are shown in Table 1. (11) (12) (13) In equations (11)-(13), TP represents the IoU value between the model's predicted defect box and the actual defect annotation box being greater than TP, and vice versa, it is considered FP. FN indicates that there is a rail surface defect but the model did not detect it. AP is the precision-recall curve (PRC) score of the rail surface defect category. AP 0.5 represents the AP of each defect category on the rail surface when IoU = 0.50. AP0.5:0.95 represents the AP calculated between the IoU critical value of 0.50 and 0.95, with an increment of 0.05.
[0050] Table 1 Experiments were conducted on the constructed railway surface defect dataset. The overall accuracy of the model was 69.2%, the recall rate was 85.1%, and the mAP50 was 82.1%. Compared with the original network, the method of this invention improved the overall accuracy by 3.6%, reduced invalid manual verification, and achieved an mAP of 90.1% for key defect depressions, which is 2.5% higher than the original network, providing more reliable detection results for railway surface defect detection.
[0051] Step 5: Network testing; After obtaining the trained detection network, it is used to detect surface defects on railway tracks. The network outputs the detection results of railway surface defects, including the coordinates, length, width, and confidence score of the predicted bounding box. Using this information, the detection bounding box is drawn, and the result is as follows: Figure 4 As shown in the image, no small or densely packed defects on the rail surface were missed, indicating a good result in the rail surface defect detection.
[0052] By using a trained network to detect real-world data, the location and quantity of defects on the rail surface can be quickly and accurately identified, providing strong support for railway maintenance and monitoring.
Claims
1. A method for detecting surface defects in railway tracks based on an improved YOLOv11 network, characterized in that, Includes the following steps: Step 1: Construct a sample dataset of railway track surface defects; Step 1.1: Use a camera stabilization device to acquire original images of the rail surface containing defective targets under different lighting and background conditions, and perform preprocessing to obtain a preprocessed rail surface image sequence. ;in, This represents the nth image of the railway track surface, where N represents the total number of railway track surface images. Step 1.2: Use annotation tools to... The target defects are labeled to obtain... The Information from each real defect annotation box ,in, For the first The coordinates of the center point of a real defect annotation box The first The width and height of a real defect annotation box; Step 2: Build the improved The network comprises a backbone feature extraction module, a deep feature optimization module, a feature fusion module, and a detection head, connected sequentially, and performs... Processing is performed to obtain The Defect prediction box ; Step 2.1: The backbone feature extraction module performs... Multi-layer convolution and downsampling are performed to obtain the nth feature map containing information on rail surface defects and potential defects. ; Step 2.2: The deep feature optimization module includes: a channel-spatial attention unit and a parameterless attention unit, and performs... The process is performed to obtain the nth high signal-to-noise ratio defect feature map. ; Step 2.2.1: The channel-spatial attention unit pair The process is performed to obtain the nth texture enhancement feature map. ; Step 2.2.2: The parameterless attention unit pair The process is performed to obtain the nth high signal-to-noise ratio defect feature map. ; Step 2.3: The feature fusion module will... Multi-scale fusion is performed with the intermediate layer features of the backbone feature extraction module to obtain the nth multi-scale fused feature map. ,in, Let J represent the j-th scale fused feature map, and J represent the number of scales contained in the n-th multi-scale fused feature map; Step 2.4: The detection head pairs Decoding is performed to obtain a size of The j-th scale grid, thus obtaining from the J-th scale grid The Defect prediction box ,in, Indicates the first The center point coordinates of the defect prediction bounding box and The first The width and height of each defect prediction box, This represents the confidence level of the i-th defect prediction box; This represents the row number of the grid at scale j. This represents the column number of the grid at the j-th scale. Step 3: Based on and Construct the total loss function ; Step 4: Improve the algorithm using the SGD optimizer. The network undergoes iterative training, and the total loss function is calculated. Adjust the network parameters until the total loss function is achieved. The process continues until convergence, thus obtaining a trained rail defect detection model, which is used to predict defects in the input original image of the rail surface.
2. The railway track surface defect detection method based on improved YOLOv11 network collaborative optimization according to claim 1, characterized in that, The camera stabilization adjustment device comprises, in sequence: a robotic arm body, a Z-axis shock absorber, and a gimbal module; The main body of the simulated robotic arm includes: a rubber pad (1), a base (2), a rotating turntable (3), a first rotary motor (4), a second rotary motor (5), a telescopic arm (6), and a main arm support assembly (7); The rubber pad (1) is located at the connection between the base (2) and the detection vehicle body to achieve a flexible connection between the robotic arm body and the detection vehicle body; A rotating turntable (3) is provided on the base (2) and connected to the lower end of the telescopic arm (6) via a first rotating motor (4). The upper end of the telescopic arm (6) is connected to one end of the main arm support assembly (7) via a second rotating motor (5). The main body of the simulated robotic arm is driven by the first rotating motor (4) and the second rotating motor (5) to swing along the rail plane and rotate around the axis of the rail under the action of the rotating turntable (3). The Z-axis damper includes: a parallel linkage mechanism (8) and a damper (9); One end of the parallel linkage mechanism (8) and one end of the shock absorber (9) are respectively connected to the other end of the main arm support assembly (7) of the simulated robotic arm body. The other ends of the parallel linkage mechanism (8) and the shock absorber (9) are respectively connected to the gimbal module. The gimbal module remains parallel to the ground under the action of the parallel linkage mechanism (8). The shock absorber (9) is used to attenuate the low-frequency vibrations generated by the detection vehicle body during driving. The gimbal module includes: an upper gimbal frame (10), an airbag (11), a lower gimbal frame (12), a camera (13), and a servo motor (14); the upper gimbal frame (10) is connected to the shock absorber (9) of the Z-axis shock absorber, and the upper gimbal frame (10) and the lower gimbal frame (12) are elastically connected by several airbags (11), which are used to attenuate the high-frequency vibration generated by the detection vehicle body during driving; The camera (13) is mounted on the lower frame (12) of the gimbal. The servo motor (14) is connected to the camera (13) for driving the camera (13) to achieve vertical angle adjustment.
3. The railway track surface defect detection method based on the improved YOLOv11 network according to claim 1, characterized in that, In the deep feature optimization module, step 2.2.1 includes: Step a: Perform the following on the channel dimension respectively Perform global average pooling and global max pooling operations to generate the nth average pooling feature. and max pooling features Thus, the attention map of the nth channel can be obtained using equation (1). And the weighted enhancement features of the nth channel are obtained through equation (2). ; (1) (2) In equation (1), represents the sigmoid activation function, and MLP represents the multilayer perceptron; In equation (2), This indicates element-wise multiplication; Step b: Perform the following on the spatial dimensions respectively Perform global average pooling and global max pooling operations to generate the nth average pooling feature. and max pooling features Thus, the nth spatial attention map is obtained using equation (3). And the nth texture enhancement feature map is obtained using equation (4). : (3) (4) In equations (3) and (4), Indicates the convolution operation; This indicates a splicing operation.
4. The railway track surface defect detection method based on the improved YOLOv11 network according to claim 3, characterized in that, In step 2.2.2, the nth texture enhancement feature map is calculated using equation (5). Position on the m-th channel Energy value at the location After processing the energy value at each position on all channels using the sigmoid function, the nth energy weight map is obtained. Thus, the nth high signal-to-noise ratio defect feature map is obtained using equation (6). : (5) (6) In equation (5), and They are respectively The mean and variance of pixel values in the m-th channel The regularization coefficient is used. for Position on the m-th channel The pixel value at that location.
5. The railway track surface defect detection method based on the improved YOLOv11 network according to claim 1, characterized in that, Step 3 includes: Step 3.1: Construct the i-th regression loss function using equation (7) ; (7) In equation (7), Indicates outlier degree. Two adjustable parameters, and Represents the i-th defect prediction box With the i-th real defect annotation box The minimum width and minimum height of the enclosure; Step 3.2: Construct the i-th classification loss function using equation (8) ; (8) In equation (8), Represents the i-th defect prediction box Does it include the first A label for a real defect; if included, then... =1, otherwise, let =0; Step 3.3: Based on J scale grids, construct the i-th distributed focal length loss function using equation (9). ; (9) In equation (9), Let represent the set of all grid locations at the j-th scale that contain the i-th true defect annotation box. This represents the distance from the grid center point at position (h, w) on the j-th scale to the grid center point at the j-th scale. The distance between the actual defect annotation boxes , These represent the predicted distances from the grid center point at position (h, w) to the i-th defect, respectively. The probability, Indicates rounding up; Step 3.4: Construct the total loss function using equation (10) ; (10) In equation (10), , and These are the corresponding weight coefficients, and I represents the total number of defect prediction boxes.
6. An electronic device, comprising a memory and a processor, characterized in that, The memory is used to store programs that support the processor in executing any of the rail surface defect detection methods according to claims 1-5, and the processor is configured to execute the programs stored in the memory.
7. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is run by the processor, it performs the steps of any of the rail surface defect detection methods described in claims 1-5.