Track defect detection method based on improved YOLOv5
By improving the YOLOv5s network and combining Laplacian operator denoising, edge detection, and data augmentation, and using an asymptotic feature pyramid network and adaptive feature fusion, the problems of manual dependence and high cost of deep learning in track defect detection are solved, and efficient and accurate track defect detection is achieved.
Patent Information
- Application Number
- CN202411342842.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-09-25
AI Technical Summary
Existing track defect detection methods rely on manual inspection, which is highly subjective. Traditional image processing methods are prone to misidentification and missed detection in complex scenarios. Deep learning algorithms have high computational costs, making it difficult to balance detection speed and accuracy.
An improved YOLOv5s network is adopted, which uses Laplacian operator for denoising, edge detection and Hough transform to extract orbital regions. Combined with data augmentation and asymptotic feature pyramid network, adaptive feature fusion and attention mechanism, a loss function is constructed to improve the accuracy of feature extraction and detection.
It improves the accuracy and robustness of track defect detection, reduces computational costs, increases detection speed and precision, and adapts to complex track environments.
Smart Images

Figure CN119338757B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of target detection, and particularly relates to a track defect detection method based on an improved YOLOv5s. BACKGROUND
[0002] At present, most of the track inspection tasks in China still adopt manual inspection and traditional image processing detection methods, among which manual inspection is highly subjective and depends on the technical level and responsibility of the inspectors, and the traditional image processing method has the problems of misidentification and missed detection in complex scenes. In recent years, the rapid development of artificial intelligence defect detection technology represented by deep learning, especially the convolutional neural network, has made many progress in defect detection. This technology has the potential to adapt to complex track environments and improve detection efficiency and accuracy.
[0003] In track defect detection, the performance of the algorithm directly affects the accuracy, efficiency and reliability of the track defect detection system. However, traditional algorithms lack effective modeling of track defect backgrounds and noise, often requiring manual adjustment of parameters and thresholds, and are sensitive to parameter selection, which increases the difficulty of algorithm design and debugging. Therefore, the robustness in actual scenarios is poor. The detection method based on deep learning solves this problem well, but in order to improve the detection accuracy and generalization ability, the current deep learning algorithm usually needs to use a complex deep neural network model, which has a large number of parameters to be trained and optimized, resulting in high computational cost and memory occupation, thereby affecting the real-time performance and running efficiency of the algorithm, making it difficult to balance the detection speed and accuracy. These problems limit the effectiveness of existing methods in track defect detection, and more efficient and effective methods are needed to meet the actual needs of engineering. SUMMARY
[0004] The present application aims to solve the technical problems existing in the prior art, and particularly innovatively proposes a track defect detection method based on an improved YOLOv5s, which can be applied to different defect sample shapes to extract defect feature information, improve the extraction capability of network defect features, and improve the detection efficiency.
[0005] To achieve the above purpose, the present application provides a track defect detection method based on an improved YOLOv5s, comprising the following steps:
[0006] S1: collecting track images; using an image acquisition device to collect the track;
[0007] S2: denoising the collected track images;
[0008] S3: track surface area extraction; extracting the track surface area of the track from the cleaned image data for subsequent defect detection;
[0009] S4: data enhancement; enhancing the extracted track surface area data;
[0010] S5: making a track defect data set;
[0011] S6: defect detection model training.
[0012] In the above scheme: step S2 further comprises:
[0013] S2-1: calculating the quality of the track image;
[0014] S2-2: calculating the Laplacian of each pixel point of the track image after Laplacian operation;
[0015] The calculation is performed by the following formula:
[0016] Δf = f(x+1, y) + f(x-1, y) + f(x, y+1) + f(x, y-1) - 4f(x, y)
[0017] Wherein, wherein Δf represents the Laplacian operator, f is the original track image, (x, y) is the coordinate of the pixel point L on the original track image, (x+1, y) represents the coordinate of the point one unit pixel right of the pixel point L; (x-1, y) represents the coordinate of the point one unit pixel left of the pixel point L; (x, y+1) represents the coordinate of the point one unit pixel below of the pixel point L; f(x, y-1) represents the coordinate of the point one unit pixel above of the point L;
[0018] S2-3: calculating the variance of the Laplacian of the track image after Laplacian operation;
[0019] The calculation is performed by the following formula:
[0020]
[0021] In the above formula, i represents the i-th pixel point of the track image after Laplacian operation, N represents the total number of pixel points, Δf i represents the Laplacian of the i-th pixel point, Val(Δf) represents the variance of the Laplacian; represents the average value of the pixel points;
[0022] S2-4: setting a minimum sharpness value M, comparing the variance of the Laplacian calculated in step S2-3 with the minimum sharpness value M, if it is lower than the minimum sharpness value M, it indicates that it is a low-quality image, and the track image is removed;
[0023] S2-5: repeating steps S2-1 to S2-4 until all the collected track images are processed, and the next step is performed.
[0024] In the above scheme, step S3 further comprises:
[0025] S3-1: denoising the image through a bilateral filter;
[0026] S3-2: obtaining an edge image of the image through an edge detection algorithm;
[0027] S3-3: detecting straight lines in the edge image through a Hough transform algorithm, and filtering out straight lines that do not meet the parameter requirements through parameter screening;
[0028] S3-4: calculating the boundary of the track area according to the screened straight lines, and extracting the track area in the track image.
[0029] In the above scheme, step S4 further comprises:
[0030] S4-1: performing mirror flipping in the horizontal or vertical direction on the extracted track surface area image through an image transformation algorithm;
[0031] S4-2: rotating the track surface area image;
[0032] S4-3: scaling the track surface area image;
[0033] S4-4: eliminating Gaussian noise and salt and pepper noise in the track surface area image;
[0034] Step S5 further comprises:
[0035] S5-1: manually framing and labeling the defect information on the image through the labelimg image labeling tool after enhancing the track image data; when framing, a selected labeling tool is used to draw a corresponding shape on the image to label the track defect area;
[0036] S5-2: saving and generating a data set; after labeling, save as a txt format file with the corresponding name, i.e., a data set; the file contains a self-defined defect type number and pixel coordinates of the manually framed defect in the image, and the coordinates are normalized.
[0037] In the above scheme, step S4-2 comprises the following steps:
[0038] Copy the track surface area image multiple times, and rotate the copied same track surface area image according to different angles to form a rotated track surface area image.
[0039] In the above scheme, step S4-3 comprises the following steps:
[0040] The rotated rail surface area image is copied multiple times, and the copied same rail surface area image is scaled at different scales to form a scaled rail surface area image.
[0041] In the above scheme, step S6 comprises the following steps:
[0042] S6-1: input data and perform convolution operation through a convolution layer;
[0043] S6-2: divide the feature map obtained after convolution in the channel dimension into an original feature map and a feature map that needs to be extracted at a deeper level;
[0044] extracted feature map;
[0045] S6-3: calculate the feature map that needs to be extracted at a deeper level through a Bottleneck module;
[0046] S6-4: adjust the number of channels through a convolution operation;
[0047] S6-5: calculate through a deformable convolution module;
[0048] The calculation is performed through the following formula:
[0049]
[0050] In the above formula, p n is the nth sampling point in the grid, Δm n is a weight coefficient, which is 0 if the region of the sampling point is not of interest, and is 1 if it is of interest; Δp n is the offset of the nth sampling point; p0 is the center sampling point of convolution; R is the set of sampling points, R = {(-1,-1),(-1,0),(1,0),(0,0),(1,0)(1,-1),(1,0),(1,1)}; w(·) is a convolution operation, and x(·) represents the pixel value of the point;
[0051] S6-6: perform feature fusion through an asymptotic feature pyramid network;
[0052] S6-7: assign different spatial weights to features of different levels through an adaptive feature fusion module; assign weights to features of different levels according to the importance of features at specific positions, and automatically select the most effective features for the current task;
[0053] S6-8: comprehensively consider the shape of the rail defect and the performance of the evaluation model, and construct a loss function as follows:
[0054]
[0055] wherein, CIoU LOSSThe complete intersection-over-union ratio representing the loss, d represents the distance between the center points of the true frame and the predicted frame, c represents the diagonal length of the desired bounding box, ARP represents the aspect ratio error, a represents the width-height ratio of the bounding box, and v is a parameter for measuring the scale; IoU represents the intersection-over-union ratio, and CIoU represents the complete intersection-over-union ratio. LOSS The intersection-over-union ratio represents the loss, and CIoU represents the complete intersection-over-union ratio.
[0056] S6-9: The feature map processed by the deformable convolution module is sent to the next level network for further target detection processing.
[0057] In the above scheme, step S6-3 further includes:
[0058] S6-3-1: Adjust the channel number through the convolution layer to reduce the dimension;
[0059] S6-3-2: Extract spatial feature information in the image through the convolution layer;
[0060] S6-3-3: Fuse the feature map processed by the Bottleneck module with the original feature map in step S6-2 through Concatenate;
[0061] S6-6 further includes:
[0062] S6-6-1: Input features to extract multi-scale feature maps of different levels from the Backbone;
[0063] S6-6-2: Process each level of feature map in turn from high to low through the up-sampling module, restore the feature map of lower resolution to higher resolution, and fuse with the feature of the previous level; each time the feature of the current layer is fused with the feature of the upper layer, the feature is also reconstructed through convolution operation to further enhance the feature representation after fusion;
[0064] S6-6-3: Calculate the importance coefficients of the multi-scale feature maps of each level, so that the network can focus on the feature regions more important for target detection;
[0065] S6-6-4: Process each level of feature map in turn from low to high through the down-sampling module; pass the feature from the low resolution level to the high resolution level through the down-sampling module to realize further combination of global and local information;
[0066] S6-6-5: Final feature output; after bidirectional feature fusion, a set of multi-scale feature maps are finally output, each of which contains rich spatial and semantic information; these feature maps are sent to the detection head for target classification and bounding box regression.
[0067] In the above scheme, step S6-7 further comprises:
[0068] S6-7-1: feature fusion, the fused feature map is generated through convolution;
[0069] S6-7-2: then the weight of different feature maps at each spatial position is calculated through the attention mechanism.
[0070] In the above scheme, the model training of step S6 is carried out under the pytorch framework, the system is ubuntu18.04, and the version of the YOLO basic model is YOLOv5-6.1 version;
[0071] After step S6, step S7 of inputting the track image to be detected into the defect detection model trained in step S6 and outputting a detection result is further included.
[0072] In summary, the beneficial effects of the present application are: the defect feature information can be extracted for different defect sample shapes, and the network defect feature extraction capability is improved. Secondly, the asymptotic feature pyramid AFPN network is used to replace the feature pyramid in the neck module, which can better fuse the feature maps under non-adjacent scales, effectively improve the target positioning accuracy and the robustness of the model, and has fewer parameters, improving the detection speed. BRIEF DESCRIPTION OF DRAWINGS
[0073] Figure 1 The flowchart of the present application.
[0074] Figure 2 The installation schematic diagram of the image acquisition device.
[0075] Figure 3 The image instance diagram collected.
[0076] Figure 4 The track surface area extraction image.
[0077] Figure 5 The data set annotation.
[0078] Figure 6 The YOLOv5s network structure diagram of the present application.
[0079] Figure 7 The model training diagram.
[0080] Figure 8 The schematic diagram of detecting the corrugation wear after model training.
[0081] Figure 9 The schematic diagram of detecting the surface scratch after model training. DETAILED DESCRIPTION
[0082] The application will be further described below by way of examples in conjunction with the accompanying drawings:
[0083] As Figures 1-9 indicated in a track defect detection method based on improved YOLO v5, comprising the following steps:
[0084] S1: collecting track images; using an image acquisition device 1 to collect the track; as Figure 2 indicated, the image acquisition device 1 of the embodiment is three, and is installed as Figure 3 indicated.
[0085] S2: processing the collected track images; removing noise and unnecessary information to improve the accuracy of subsequent processing; removing images with poor image quality or no defect information from the collected images to ensure the quality of images in the data set;
[0086] S2-1: calculating the quality of the track image;
[0087] S2-2: calculating the Laplacian of each pixel point of the track image after Laplacian operation;
[0088] The calculation is performed by the following formula:
[0089] Δf = f(x+1, y) + f(x-1, y) + f(x, y+1) + f(x, y-1) - 4f(x, y)
[0090] Wherein, wherein Δf represents the Laplacian operator, f is the original track image, (x, y) is the coordinate of the pixel point L on the original track image, (x+1, y) represents the coordinate of the point one unit pixel right to the pixel point L; (x-1, y) represents the coordinate of the point one unit pixel left to the pixel point L; (x, y+1) represents the coordinate of the point one unit pixel below the pixel point L; f(x, y-1) represents the coordinate of the point one unit pixel above the pixel point L;
[0091] S2-3: calculating the variance of the Laplacian after the Laplacian operation of the track image;
[0092] The calculation is performed by the following formula:
[0093]
[0094] In the above formula, i represents the i-th pixel point of the track image after the Laplacian operation, N represents the total number of pixel points, Δf i represents the Laplacian of the i-th pixel point, Val(Δf) represents the variance of the Laplacian; represents the average value of the pixel points;
[0095] S2-4: Set a minimum sharpness value M, compare the variance of the Laplacian calculated in step S2-3 with the minimum sharpness value M, if lower than the minimum sharpness value M, it indicates a low-quality image, and the track image is removed;
[0096] S2-5: Loop steps S2-1-S2-4 until all the track images collected are processed, and the next step is executed.
[0097] S3: Track surface area extraction; extract the track surface area from the cleaned image data for subsequent defect detection;
[0098] S3-1: Denoise the image by a bilateral filter;
[0099] S3-2: Obtain the edge image of the image by edge detection algorithm processing;
[0100] S3-3: Detect straight lines in the edge image by Hough transform algorithm, and filter out straight lines that do not meet the parameter requirements by parameter screening; The parameters set in this embodiment include that the straight line inclination angle is between 87 degrees and 93 degrees, and the straight line length is between 465 and 480 pixels;
[0101] S3-4: According to the screened straight lines, calculate the boundary of the track area, and extract the track area in the track image;
[0102] S4: Data enhancement; enhance the extracted track surface area data to expand the data set and improve the generalization ability of the defect detection model;
[0103] S4-1: Mirror flip the extracted track surface area image in horizontal or vertical direction by image transformation algorithm;
[0104] S4-2: Rotate the track surface area image; In this embodiment, the rotation angles are 15°, 30°, 45°, 60°, and 75°, and the same track surface area image can be copied multiple times and rotated according to the set angles; It can also be randomly selected to rotate at the set angle; Or rotate at a fixed rotation angle;
[0105] S4-3: Scale the track surface area image; It can be randomly scaled or fixed scaled to simulate the track surface situation under different scales; The scaling ratio of this embodiment is 1:0.25, 1:0.5, 1:2, and 1:4.
[0106] S4-4: Eliminate Gaussian noise, salt and pepper noise, etc. in the track surface area image to increase the robustness and generalization ability of the data.
[0107] S5: making a track defect dataset; based on the enhanced track image data, a track defect dataset is constructed;
[0108] S5-1: manually frame and label the defect information on the picture through the labelimg picture labeling tool on the enhanced track image data; when framing, the selected labeling tool is used to draw the corresponding shape on the image to label the track defect area;
[0109] S5-2: save and generate the dataset; after labeling, save it as a txt file with the corresponding name, that is, the dataset; the file contains the custom defect type number and the pixel coordinates of the manually framed defects in the image, and the coordinates are normalized.
[0110] S6: defect detection model training; using the constructed track defect dataset, the defect detection model is trained to realize automatic detection and recognition of track defects;
[0111] S6-1: input data and perform convolution operation through a 1x1 convolution layer;
[0112] S6-2: divide the feature map obtained after convolution into original feature map and feature map that needs to be extracted in a deeper level in the channel dimension;
[0113] Divide the feature map after convolution into two parts; the first part is divided into the original feature map, which is directly passed without further processing; the second part is the feature map that needs to be extracted in a deeper level, which is input into the Bottleneck module;
[0114] S6-3: calculate the feature map that needs to be extracted in a deeper level through the Bottleneck module;
[0115] S6-3-1: adjust the channel number through a 1x1 convolution layer for dimension reduction;
[0116] S6-3-2: extract spatial feature information in the image through a 3x3 convolution layer;
[0117] S6-3-3: fuse the feature map processed by the Bottleneck module with the original feature map in step S6-2 through
[0118] Concatenate; add the input feature directly to the output feature and merge in the channel dimension.
[0119] At this time, the number of channels is doubled;
[0120] S6-4: adjust the number of channels through convolution operation; perform the last convolution: adjust the number of channels to the target value Cfinal through a 1x1 convolution layer;
[0121] S6-5: Calculation by deformable convolution module; based on the Backbone module in the original YOLOv5s network, the C3 convolution module therein is replaced by a deformable convolution module for calculation;
[0122] The calculation is performed by the following formula:
[0123]
[0124] In the above formula, p n is the nth sampling point in the grid, Δm n is the weight coefficient, which is 0 if the region of the sampling point is not of interest and 1 if it is of interest; Δp n is the offset of the nth sampling point; p0 is the center sampling point of the convolution; R is the set of sampling points, R = {(-1,-1),(-1,0),(1,0),(0,0),(1,0)(1,-1),(1,0),(1,1)}; w(·) is the convolution operation, and x(·) represents the pixel value of the point;
[0125] Given an input feature map and a basic convolution kernel, the offset Δp n and the weight coefficient Δm n are learned through an additional convolution layer. Deformable convolution dynamically adjusts the shape and position of the convolution kernel according to the generated two data, realizing nonlinear sampling and deformation of the input feature map.
[0126] S6-6: Feature fusion by an asymptotic feature pyramid network;
[0127] S6-6-1: Input features, extract multi-scale feature maps of different levels from the Backbone;
[0128] S6-6-2: Process each level of feature map from high to low through the up-sampling module, restore the feature map of lower resolution to higher resolution, and fuse with the feature of the previous level; each time the current layer of feature is fused with the feature of the upper layer, the feature is also reconstructed by convolution operation to further enhance the feature representation after fusion;
[0129] S6-6-3: Calculate the importance coefficients of multi-scale feature maps of each level, so that the network can focus on the feature regions more important for target detection, i.e. automatically adjust the fusion weights between different scale features;
[0130] S6-6-4: The feature maps of each level are sequentially processed by the downsampling module from low to high; the features are passed from the low-resolution level to the high-resolution level through the downsampling module to further combine global and local information; this bottom-up path allows the network to also have deep semantic information at higher resolution levels.
[0131] S6-6-5: Final feature output; after bidirectional feature fusion, a set of multi-scale feature maps is output, each containing rich spatial and semantic information; these feature maps are sent to the detection head for target classification and bounding box regression.
[0132] Since the method of constructing a feature pyramid through top-down and bottom-up feature fusion in the original YOLO v5s network can cause feature information loss or degradation, thereby weakening the fusion effect between non-adjacent levels, an adaptive feature pyramid network (AFPN) is used to replace the original feature fusion pyramid structure.
[0133] In the process of feature extraction from bottom to top by the backbone network, AFPN first fuses bottom-level features, then fuses deeper-level features, and finally fuses top-level features; to solve the problem of poor non-adjacent level feature fusion effect, the AFPN architecture adopts a progressive mode, each layer contains the feature information of the previous layer, making the semantic information of different levels of features closer in the progressive fusion process.
[0134] S6-7: Assign different spatial weights to features of different levels through the adaptive feature fusion module; assign weights to features of different levels according to the importance of features in a specific position, and automatically select the most effective features for the current task;
[0135] S6-7-1: Feature fusion, generate fused feature maps through convolution or other operations, representing the correlation between the two;
[0136] S6-7-2: Then calculate the weight of different feature maps at each spatial position through the attention mechanism;
[0137] In the multi-level feature fusion process, to strengthen the importance of key levels and suppress the influence of contradictory information from different objects, adaptive spatial feature fusion (ASFF) is used to assign different spatial weights to features of different levels.
[0138] S6-8: Considering the shape of the track defect and the performance of the evaluation model, the loss function is constructed as follows:
[0139]
[0140] CIoU = 1 - IoU + a * (1 - IoU) * d lOSS represents the loss, d represents the distance between the center points, c represents the diagonal length of the desired bounding box, ARP represents the aspect ratio error, a represents the width-height ratio of the bounding box, and v is a parameter that measures the scale. IoU represents the intersection over union, which is an evaluation index for measuring the overlap between two bounding boxes, and is widely used in object detection tasks. IoU reflects the overlap between the predicted box and the real box, and the higher the value, the better the degree of coincidence between the two boxes. IoU LOSS represents the loss, CIoU represents the complete intersection over union, which is an improved version of IoU (Intersection over Union) and is used to measure the similarity between the predicted box and the real box in object detection.
[0141] S6-9: The feature map processed by the deformable convolution module is sent to the next level network (which may be a convolution layer, a detection head, etc.) to continue the processing of object detection.
[0142] S7: Input the track image to be detected into the defect detection model trained in step S6, and output the detection result.
[0143] The model training is carried out under the pytorch framework, the system is ubuntu18.04, and the YOLO basic model version is YOLOv5-6.1 version. The training process is as follows Figure 7 , and the trained model is tested in the field. The detection structure is as shown in Figure 8 、 9 .
Claims
1. A method for detecting track defects based on an improved YOLOv5s, characterized in that: Includes the following steps: S1: Acquire orbital images; The track was captured using an image acquisition device (1); S2: Clean the acquired track images; S3: Track surface region extraction; Extract the track surface region from the cleaned image data for subsequent defect detection; S4: Data augmentation; Enhancement processing is performed on the extracted track surface area data; S5: Create a dataset of track defects; S6: Defect detection model training; Step S6 includes the following steps: S6-1: Input data and perform convolution operations through convolutional layers; S6-2: Divide the feature map obtained after convolution into the original feature map and the feature map that needs to be extracted at a deeper level along the channel dimension; S6-3: The feature maps that need to be extracted at a deeper level are calculated using the Bottleneck module; S6-3-1: Dimensionality reduction is achieved by adjusting the number of channels through convolutional layers; S6-3-2: Extract spatial feature information from the image through convolutional layers; S6-3-3: Compare the feature map processed by the Bottleneck module with the original feature map from step S6-2. Concatenate performs feature map fusion; S6-4: Adjust the number of channels through convolution operations; S6-5: Calculated using deformable convolution modules; The calculation is performed using the following formula: In the above formula, p n It is the nth sampling point in the grid, Δm n The weight coefficient is 0 if the region of the sampling point is not of interest, and 1 if it is of interest; Δp n is the offset of the nth sampling point; p0 is the center sampling point of the convolution; R is the set of sampling points, R={(-1,-1),(-1,0),(1,0),(0,0),(1,0)(1,-1),(1,0),(1,1)}; w(·) is the convolution operation, and x(·) represents the pixel value of the point; S6-6: Feature fusion via an asymptotic feature pyramid network; S6-6-1: Input features, extract multi-scale feature maps of different levels from the backbone; S6-6-2: The feature maps of each layer are processed sequentially from high to low through the upsampling module to restore the lower resolution feature maps to a higher resolution and fuse them with the features of the previous layer; each time the features of the current layer are fused with the features of the previous layer, the features are also reconstructed through convolution operations; S6-6-3: Calculate the importance coefficients of the multi-scale feature maps at each level, so that the network can focus on the feature regions that are more important for object detection; S6-6-4: The feature maps of each level are processed sequentially from low to high using the downsampling module; S6-6-5: Final feature output; S6-7: The adaptive feature fusion module assigns different spatial weights to features at different levels; it assigns weights to features at different levels based on the importance of features at specific locations, and automatically selects the most effective features for the current task. S6-7-1: Feature fusion, generating a fused feature map through convolution; S6-7-2: Then, the weights of different feature maps at each spatial location are calculated using an attention mechanism; S6-8: Taking into account the shape of the track defect and evaluating the model's performance, the loss function is constructed as follows: Among them, CIoU LOSS The loss represents the Cross-Union Ratio (IoU), where d represents the distance between the center points of the ground truth bounding box and the center points of the predicted bounding box, c represents the diagonal length of the desired bounding box, ARP represents the aspect ratio error, a represents the aspect ratio of the bounding box, and v is a parameter that measures the scale; IoU represents the Cross-Union Ratio. LOSS CIoU represents the crossover and union ratio of the loss, while CIoU represents the complete crossover and union ratio. S6-9: The feature map processed by the deformable convolutional module is fed into the next layer of the network to continue the object detection process.
2. The orbital defect detection method based on the improved YOLOv5s according to claim 1, characterized in that: Step S2 also includes: S2-1: Calculate the quality of the orbital image; S2-2: Calculate the Laplacian operator for each pixel of the orbital image after Laplacian operator operation; The calculation is performed using the following formula: Δf=f(x+1,y)+f(x-1,y)+f(x,y+1)+f(x,y-1)-4f(x,y) Where Δf represents the Laplacian operator, f is the original orbit image, (x,y) are the coordinates of pixel L in the original orbit image, (x+1,y) represents the coordinates of the pixel one unit to the right of L; (x-1,y) represents the coordinates of the pixel one unit to the left of L; (x,y+1) represents the coordinates of the pixel one unit below L; and f(x,y-1) represents the coordinates of the pixel one unit above L. S2-3: Calculate the variance of the Laplacian operator after the orbital image has been processed by the Laplacian operator; The calculation is performed using the following formula: In the above formula, i represents the i-th pixel of the orbital image after the Laplacian operator operation, N represents the sum of the pixels, and Δf i Let represent the Laplacian operator for the i-th pixel, and Val(Δf) represent the variance of the Laplacian operator. This represents the average value of the pixels. S2-4: Set a minimum resolution value M. Compare the variance of the Laplacian operator calculated in step S2-3 with the minimum resolution value M. If it is lower than the minimum resolution value M, it indicates that it is a low-quality image and the track image is discarded. S2-5: Repeat steps S2-1 to S2-4 until all acquired orbital images have been processed, then proceed to the next step.
3. The orbital defect detection method based on the improved YOLOv5s according to claim 2, characterized in that: Step S3 also includes: S3-1: Denoising the image using a bilateral filter; S3-2: Obtain the edge image of the image through edge detection algorithm; S3-3: The edge image is processed by the Hough transform algorithm to detect straight lines in the edge image, and the detected straight lines are filtered out by parameter filtering to remove those that do not meet the parameter requirements; S3-4: Based on the filtered straight lines, calculate the boundary of the track region and extract the track region from the track image.
4. The orbital defect detection method based on improved YOLOv5s according to claim 1, characterized in that: Step S4 also includes: S4-1: Mirror the extracted track surface area image horizontally or vertically using an image transformation algorithm; S4-2: Rotate the image of the track surface area; S4-3: Scale the image of the track surface area; S4-4: Eliminate Gaussian noise and salt-and-pepper noise in the track surface area image; Step S5 also includes: S5-1: Manually select and annotate the defect information on the enhanced track image data using the labelimg image annotation tool; when selecting, use the selected annotation tool to draw the corresponding shape on the image to mark the track defect area; S5-2: Save and generate the dataset; after annotation, save it as a txt file with the corresponding name.
5. The orbital defect detection method based on the improved YOLOv5s according to claim 4, characterized in that: Step S4-2 includes the following steps: The track surface area image is copied multiple times, and the copied track surface area image is rotated at different angles to form a rotated track surface area image.
6. The orbital defect detection method based on the improved YOLOv5s according to claim 5, characterized in that: Step S4-3 includes the following steps: The rotated track area image is copied multiple times, and the copied track area images are scaled up according to different ratios to form scaled track area images.
7. The orbital defect detection method based on improved YOLOv5s according to claim 1, characterized in that: The model training in step S6 was performed under the PyTorch framework, on the Ubuntu 18.04 system, and the YOLO base model version was YOLOv5-6.
1. Step S6 is followed by step S7, in which the track image to be detected is input into the defect detection model trained in step S6, and the detection result is output.
Citation Information
Patent Citations
Method for rapidly extracting steel rail surface area under condition of vibration
CN106355185A
Railway track defect automatic identification image quality enhancement method and device and medium
CN117333379A
Railway track defect detection method and system based on improved YOLOv5s algorithm
CN118115476A