Track defect detection method based on improved YOLOv5s

By improving the YOLOV5S algorithm and the use of gradual featured pyramid networks, the problem of misunderstanding and missed inspection in rail defect detection is solved, the detection efficiency and accuracy are improved, and the calculation cost and memory occupation is reduced.

CN119338757AActive Publication Date: 2025-01-21YANGTZE DELTA REGION INST OF UNIV OF ELECTRONICS SCI & TECH OF CHINE (HUZHOU) +1
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202411342842.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-25
Publication Date
2025-01-21
Estimated Expiration
2044-09-25

AI Technical Summary

Technical Problem

The prior art has problems of misidentification and missed detection in track defect detection, and the complexity of deep learning algorithms leads to high computing costs and memory usage, affecting real-time and operational efficiency.

Method used

Put forward a track defect detection method based on improving YOLOV5S. By collecting rail images, de -no -processing, data enhancement, production data sets and model training, etc., to improve the ability to extract the characteristics of network defects, and use the gradual characteristic pyramid network replacement features Pyramid, improve target positioning accuracy and model robustness.

Benefits of technology

The characteristics of the characteristics of different defect samples are realized, the detection efficiency and accuracy is improved, the calculation cost and memory occupation is reduced, and the detection speed and robustness are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119338757A_ABST
    Figure CN119338757A_ABST
Patent Text Reader

Abstract

The invention discloses a track defect detection method based on improved YOLOv5s. The method comprises the following steps: S1, collecting a track image; acquiring the track by using image acquisition equipment; s2, carrying out de-noising processing on the acquired track image; s3, rail surface region extraction; extracting a track surface area of the track from the cleaned image data so as to facilitate subsequent defect detection; s4, data enhancement; carrying out enhancement processing on the extracted rail surface area data; s5, making a track defect data set; and S6, training a defect detection model. The method can be suitable for shape extraction of defect feature information of different defect samples, improves the extraction capability of network defect features, and improves the detection efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of target detection, and in particular to a track defect detection method based on improved YOLOv5s. Background Art

[0002] At present, most of the rail inspection tasks in my country still use manual inspection and traditional image processing detection methods. Among them, manual inspection relies on the technical level and sense of responsibility of the inspectors and is relatively subjective. Traditional image processing methods have 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 convolutional neural networks, has made many progresses in defect detection. This technology has the potential to adapt to complex rail environments and improve detection efficiency and accuracy.

[0003] In rail defect detection, the performance of the algorithm directly affects the accuracy, efficiency and reliability of the rail defect detection system. However, the traditional algorithm lacks effective modeling of rail defect background and noise, and often requires manual adjustment of parameters and thresholds, and is sensitive to the selection of parameters, 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 complex deep neural network models. These models have a large number of parameters that need to be trained and optimized, resulting in high computational costs and memory usage, which affects the real-time and operational efficiency of the algorithm, making it difficult to balance the detection speed and detection accuracy. These problems limit the effectiveness of existing methods in rail defect detection, and it is necessary to seek more efficient and effective methods to meet the actual needs of the project. Summary of the invention

[0004] The present invention aims to solve the technical problems existing in the prior art, and particularly innovatively proposes a rail defect detection method based on improved YOLOv5s, which can be applied to the shapes of different defect samples to extract defect feature information, enhance the ability to extract network defect features, and improve detection efficiency.

[0005] In order to achieve the above object, the present invention provides a track defect detection method based on improved YOLOv5s, comprising the following steps:

[0006] S1: Collect track images; use image acquisition equipment to collect tracks;

[0007] S2: De-noising the collected orbital images;

[0008] S3: rail surface area extraction: extracting the rail surface area of ​​the track from the cleaned image data for subsequent defect detection;

[0009] S4: Data enhancement: Enhance the extracted track surface area data;

[0010] S5: Create track defect dataset;

[0011] S6: Defect detection model training.

[0012] In the above scheme: step S2 also includes:

[0013] S2-1: Calculate the quality of the orbital image;

[0014] S2-2: Calculate the Laplacian operator of each pixel of the orbital image after the Laplacian operator is operated;

[0015] Calculate using 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] Among them, Δ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 to the right of the pixel point L; (x-1, y) represents the coordinate of the point one unit pixel to the left of 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 point L;

[0018] S2-3: Calculate the variance of the Laplace operator after the orbital image is processed by the Laplace operator;

[0019] Calculate using the following formula:

[0020]

[0021] In the above formula, i represents the i-th pixel of the orbital image after the Laplace operator operation, N represents the sum of the pixels, and Δf i represents the Laplacian operator of the i-th pixel, Val(Δf) represents the variance of the Laplacian operator; Represents the average value of pixels;

[0022] S2-4: Setting a minimum definition value M, comparing the variance of the Laplace operator calculated in step S2-3 with the minimum definition value M, if it is lower than the minimum definition value M, it indicates that it is a low-quality image, and the track image is discarded;

[0023] S2-5: loop steps S2-1 to S2-4 until all the collected track images are processed, and then execute the next step.

[0024] In the above scheme: step S3 also includes:

[0025] S3-1: De-noise the image using a bilateral filter;

[0026] S3-2: Obtaining an edge image of the image by edge detection algorithm;

[0027] S3-3: The edge image is subjected to the Hough transform algorithm to detect straight lines in the edge image, and the detected straight lines are filtered out through parameter screening to remove straight lines that do not meet the parameter requirements;

[0028] S3-4: Calculate the boundary of the track area based on the filtered straight lines, and extract the track area in the track image.

[0029] In the above scheme: step S4 also includes:

[0030] S4-1: The extracted rail surface area image is mirror-flipped in the horizontal or vertical direction by using an image transformation algorithm;

[0031] S4-2: Rotate the track surface area image;

[0032] S4-3: Zooming the rail surface area image;

[0033] S4-4: Eliminate Gaussian noise and salt and pepper noise in the rail surface area image;

[0034] Step S5 also includes:

[0035] S5-1: Use the labelimg image annotation tool to manually select and annotate the defect information on the enhanced track image data; when selecting, use the selected annotation tool to draw a corresponding shape on the image to mark the track defect area;

[0036] S5-2: Save and generate a data set; after the annotation is completed, save it as a txt format file with the corresponding name, that is, the data set; this file contains the custom defect type number and the pixel coordinates of the manually selected defect in the image, and the coordinates are normalized.

[0037] In the above scheme: step S4-2 includes the following steps:

[0038] The rail surface area image is copied into multiple copies, and the copied rail surface area image is rotated according to different angles to form a rotated rail surface area image.

[0039] In the above scheme: step S4-3 includes the following steps:

[0040] The rotated rail surface area image is copied into multiple copies, and the copied rail surface area image is scaled according to different proportions to form a scaled rail surface area image.

[0041] In the above scheme: step S6 includes the following steps:

[0042] S6-1: Input data and perform convolution operation through the convolution layer;

[0043] S6-2: Split the feature map obtained after convolution into the original feature map and the feature map that needs to be further layered in the channel dimension.

[0044] Extracted feature map;

[0045] S6-3: The feature map that needs to be extracted at a deeper level is calculated through the Bottleneck module;

[0046] S6-4: Adjust the number of channels through convolution operation;

[0047] S6-5: Calculation via deformable convolution module;

[0048] Calculate using the following formula:

[0049]

[0050] In the above formula, p n is the nth sampling point in the grid, Δm n is the weight coefficient. If the area of ​​the sampling point is not of interest, the weight learning is 0, and if it is of interest, it is 1; Δp n is the offset of the nth sampling point; p0 is the central sampling point of the convolution; R is the sampling point set, R = {(-1,-1), (-1,0), (1,0), (0,0), (1,0) (1,-1), (1,0), (1,1)}; w(·) is the convolution operation, x(·) represents the pixel value of the point;

[0051] S6-6: Feature fusion via asymptotic feature pyramid network;

[0052] S6-7: Assign different spatial weights to features at different levels through the adaptive feature fusion module; assign weights to features at different levels according to the importance of features at specific locations, and automatically select the most effective features for the current task;

[0053] S6-8: Considering the shape of the track defect and the performance of the evaluation model, the loss function is constructed as follows:

[0054]

[0055] Among them, CIoU LOSSrepresents the complete intersection-over-union ratio of the loss, d represents the distance between the center point of the real box and the center point of the predicted 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 to measure the scale; IoU represents the intersection-over-union ratio, IoU LOSS represents the intersection-over-union ratio of the loss, 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 to continue the target detection process.

[0057] In the above scheme: step S6-3 also includes:

[0058] S6-3-1: Adjust the number of channels through the convolution layer to reduce the dimension;

[0059] S6-3-2: Extract spatial feature information from the image through the convolution layer;

[0060] S6-3-3: The feature map processed by the Bottleneck module is fused with the original feature map in step S6-2 by Concatenate;

[0061] S6-6 also includes:

[0062] S6-6-1: Input features and extract multi-scale feature maps at different levels from Backbone;

[0063] S6-6-2: The feature maps of each layer are processed from high to low through the upsampling module, and the lower resolution feature maps are restored to higher resolution and fused 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 reconstructed through convolution operations to further enhance the fused feature representation;

[0064] S6-6-3: Calculate the importance coefficients of multi-scale feature maps at each level, so that the network can focus on the feature areas that are more important for target detection;

[0065] S6-6-4: The feature maps of each level are processed from low to high in turn through the downsampling module; the features are passed to the high-resolution level at the low-resolution level through the downsampling module to further combine the 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 feature map 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 also includes:

[0068] S6-7-1: Feature fusion, generating fused feature maps through convolution;

[0069] S6-7-2: Then the weights of different feature maps at each spatial position are 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 YOLO basic model version is YOLOv5-6.1;

[0071] The method further includes step S7 after step S6, wherein the track image to be inspected is input into the defect detection model trained in step S6, and the inspection result is output.

[0072] In summary, the beneficial effects of the present invention are: it can extract defect feature information according to the shapes of different defect samples, and improve the network defect feature extraction capability. Secondly, it is proposed to use the asymptotic feature pyramid AFPN network to replace the feature pyramid in the neck module, which can better integrate the feature maps at non-adjacent scales, effectively improve the positioning accuracy of the target and the robustness of the model, and at the same time have fewer parameters and improve the detection speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] Figure 1 It is a flow chart of the present invention.

[0074] Figure 2 This is a schematic diagram of the installation of the image acquisition equipment.

[0075] Figure 3 This is an example of the image collected.

[0076] Figure 4 Extract images for the rail surface area.

[0077] Figure 5 Label the dataset.

[0078] Figure 6 This is the YOLOv5s network structure diagram of the present invention.

[0079] Figure 7 Training graph for the model.

[0080] Figure 8 Schematic diagram of detecting corrugation wear after model training.

[0081] Fig. 9 Schematic diagram of detecting surface scratches after model training. DETAILED DESCRIPTION

[0082] The present invention will be further described below by way of embodiments and in conjunction with the accompanying drawings:

[0083] like Figures 1 to 9 A track defect detection method based on improved YOLO v5s is shown, comprising the following steps:

[0084] S1: Collecting track images; using image acquisition device 1 to collect tracks; Figure 2 As shown, the image acquisition devices 1 of this embodiment are three and are installed as follows Figure 3 shown.

[0085] S2: Process the collected orbital images; remove noise and unnecessary information to improve the accuracy of subsequent processing; remove images with poor image quality or no defect information from the collected images to ensure the quality of the images in the data set;

[0086] S2-1: Calculate the quality of the orbital image;

[0087] S2-2: Calculate the Laplacian operator of each pixel of the orbital image after the Laplacian operator is operated;

[0088] Calculate using 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] Among them, Δ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 to the right of the pixel point L; (x-1, y) represents the coordinate of the point one unit pixel to the left of 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 point L;

[0091] S2-3: Calculate the variance of the Laplace operator after the orbital image is processed by the Laplace operator;

[0092] Calculate using the following formula:

[0093]

[0094] In the above formula, i represents the i-th pixel of the orbital image after the Laplace operator operation, N represents the sum of the pixels, and Δf i represents the Laplacian operator of the i-th pixel, Val(Δf) represents the variance of the Laplacian operator; Represents the average value of pixels;

[0095] S2-4: Setting a minimum definition value M, comparing the variance of the Laplace operator calculated in step S2-3 with the minimum definition value M, if it is lower than the minimum definition value M, it indicates that it is a low-quality image, and the track image is discarded;

[0096] S2-5: looping steps S2-1 to S2-4 until all the acquired track images are processed, and then proceeding to the next step;

[0097] S3: rail surface area extraction: extracting the rail surface area of ​​the track from the cleaned image data for subsequent defect detection;

[0098] S3-1: De-noise the image using a bilateral filter;

[0099] S3-2: Obtaining an edge image of the image by edge detection algorithm;

[0100] S3-3: Detect straight lines in the edge image by using the Hough transform algorithm, and filter out the detected straight lines that do not meet the parameter requirements through parameter screening; the parameters set in this embodiment include a straight line inclination angle between 87 degrees and 93 degrees, and a straight line length between 465 and 480 pixels;

[0101] S3-4: Calculate the boundary of the track area according to the screened straight lines, and extract the track area in the track image;

[0102] S4: Data enhancement: Enhance the extracted rail surface area data to expand the data set and improve the generalization ability of the defect detection model;

[0103] S4-1: The extracted rail surface area image is mirror-flipped in the horizontal or vertical direction by using an image transformation algorithm;

[0104] S4-2: Rotate the rail surface area image; in this embodiment, the rotation angles are 15°, 30°, 45°, 60°, and 75°, respectively, and the same rail surface area image may be copied into multiple copies and rotated in sequence according to the set angles; or the set angles may be randomly selected for rotation; or the image may be rotated according to a fixed rotation angle;

[0105] S4-3: scaling the rail surface area image; the scaling may be random or fixed to simulate rail surface conditions at different scales; the scaling ratios of this embodiment are 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: Create a track defect dataset: Based on the enhanced track image data, construct a track defect dataset;

[0108] S5-1: Use the labelimg image annotation tool to manually select and annotate the defect information on the enhanced track image data; when selecting, use the selected annotation tool to draw a corresponding shape on the image to mark the track defect area;

[0109] S5-2: Save and generate a data set; after the annotation is completed, save it as a txt format file with the corresponding name, that is, the data set; this file contains the custom defect type number and the pixel coordinates of the manually selected defect in the image, and the coordinates are normalized.

[0110] S6: Defect detection model training: Use the constructed track defect dataset to train the defect detection model to achieve automatic detection and identification of track defects;

[0111] S6-1: Input data and perform convolution operation through a 1x1 convolution layer;

[0112] S6-2: Split the feature map obtained after convolution into the original feature map and the feature map that needs to be extracted at a deeper level in the channel dimension;

[0113] The convolutional feature map is divided into two parts; the first part is split into the original feature map and passed directly without further processing; the second part is used as the feature map that needs to be extracted at a deeper level and is input into the Bottleneck module;

[0114] S6-3: The feature map that needs to be extracted at a deeper level is calculated through the Bottleneck module;

[0115] S6-3-1: Adjust the number of channels through a 1x1 convolutional layer to reduce dimensionality;

[0116] S6-3-2: Extract spatial feature information from the image through a 3x3 convolutional layer;

[0117] S6-3-3: The feature map processed by the Bottleneck module is compared with the original feature map in step S6-2.

[0118] Concatenate to fuse feature maps; add input features directly to output features and merge them in the channel dimension

[0119] At this time, the number of channels becomes twice as much as before;

[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 is performed through the deformable convolution module; based on the Backbone module in the original YOLOv5s network, the C3 convolution module is replaced with the deformable convolution module for calculation;

[0122] Calculate using 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. If the area of ​​the sampling point is not of interest, the weight learning is 0, and if it is of interest, it is 1; Δp n is the offset of the nth sampling point; p0 is the central sampling point of the convolution; R is the sampling point set, R = {(-1,-1), (-1,0), (1,0), (0,0), (1,0) (1,-1), (1,0), (1,1)}; w(·) is the convolution operation, x(·) represents the pixel value of the point;

[0125] Given an input feature map and a basic convolution kernel, the offset Δp is learned through additional convolutional layers n and weight coefficient Δm n ,Deformable convolution realizes nonlinear sampling and deformation of the input feature map by dynamically adjusting the shape and position of the convolution kernel according to the two generated data.

[0126] S6-6: Feature fusion via asymptotic feature pyramid network;

[0127] S6-6-1: Input features and extract multi-scale feature maps at different levels from Backbone;

[0128] S6-6-2: The feature maps of each layer are processed from high to low through the upsampling module, and the lower resolution feature maps are restored to higher resolution and fused 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 reconstructed through convolution operations to further enhance the fused feature representation;

[0129] S6-6-3: Calculate the importance coefficient of the multi-scale feature maps at each level, so that the network can focus on the feature areas that are more important for target detection, that is, automatically adjust the fusion weights between features of different scales;

[0130] S6-6-4: The feature maps of each level are processed from low to high in turn through the downsampling module; the features are passed to the high-resolution level at the low-resolution level through the downsampling module to achieve further combination of global and local information; this bottom-up path allows the network to 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 are finally output. Each feature map contains rich spatial and semantic information. These feature maps are sent to the detection head for target classification and bounding box regression.

[0132] In view of the fact that the method of constructing a feature pyramid by top-down and bottom-up feature fusion in the original YOLO v5s network will lead to the loss or degradation of feature information, thereby weakening the fusion effect between non-adjacent levels, the 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 in the backbone network, AFPN first fuses the bottom-level features, then the deeper features, and finally the top-level features. To solve the problem of poor fusion of features at non-adjacent levels, AFPN’s architecture adopts a progressive mode, where each layer contains the feature information of the previous layer, making the semantic information of features at different levels closer in the progressive fusion process.

[0134] S6-7: Assign different spatial weights to features at different levels through the adaptive feature fusion module; assign weights to features at different levels according to the importance of features at specific locations, and automatically select the most effective features for the current task;

[0135] S6-7-1: Feature fusion, after convolution or other operations, a fused feature map is generated to indicate the correlation between the two;

[0136] S6-7-2: Then the weights of different feature maps at each spatial position are calculated through the attention mechanism;

[0137] In the process of multi-level feature fusion, in order to enhance 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 at 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] Among them, CIoU 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 aspect ratio of the bounding box, and v is a parameter that measures the scale. ; IoU represents the intersection over union ratio, which is an evaluation index used to measure the degree of overlap between two bounding boxes (Bounding Box) and is widely used in target detection tasks. IoU reflects the overlap between the predicted box and the true box. The higher the value, the better the overlap between the two boxes. IoU LOSS CIoU represents the intersection over union (IoU) of the loss, 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 target detection.

[0141] S6-9: The feature map processed by the deformable convolution module is sent to the next level network (which may be a convolutional layer, a detection head, etc.) to continue the target detection process.

[0142] S7: Input the track image to be inspected into the defect detection model trained in step S6, and output the inspection 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. The training process is as follows Figure 7 , the trained model is tested in the field, and the detection structure is as follows Figure 8 , 9 shown.

Claims

1. A rail defect detection method based on improved YOLOv5s, characterized by: The following steps are involved: S1: Collect orbital images; Using an image acquisition device (1) to acquire the track; S2: De-noising the collected orbital images; S3: rail surface area extraction: extracting the rail surface area of ​​the track from the cleaned image data for subsequent defect detection; S4: Data enhancement: Enhance the extracted track surface area data; S5: Create track defect dataset; S6: Defect detection model training.

2. A track defect detection method based on 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 of each pixel of the orbital image after the Laplacian operator is operated; Calculate using the following formula: Δf=f(x+1,y)+f(x-1,y)+f(x,y+1)+f(x,y-1)-4f(x,y) Among them, Δ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 to the right of the pixel point L; (x-1, y) represents the coordinate of the point one unit pixel to the left of 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 point L; S2-3: Calculate the variance of the Laplace operator after the orbital image is processed by the Laplace operator; Calculate using the following formula: In the above formula, i represents the i-th pixel of the orbital image after the Laplace operator operation, N represents the sum of the pixels, and Δf i represents the Laplacian operator of the i-th pixel, Val(Δf) represents the variance of the Laplacian operator; Represents the average value of pixels; S2-4: Setting a minimum definition value M, comparing the variance of the Laplace operator calculated in step S2-3 with the minimum definition value M, if it is lower than the minimum definition value M, it indicates that it is a low-quality image, and the track image is discarded; S2-5: loop steps S2-1 to S2-4 until all the collected track images are processed, and then execute the next step.

3. A track defect detection method based on improved YOLOv5s according to claim 2, characterized in that: Step S3 also includes: S3-1: De-noise the image using a bilateral filter; S3-2: Obtaining an edge image of the image by edge detection algorithm; S3-3: The edge image is subjected to the Hough transform algorithm to detect straight lines in the edge image, and the detected straight lines are filtered out through parameter screening to remove straight lines that do not meet the parameter requirements; S3-4: Calculate the boundary of the track area based on the filtered straight lines, and extract the track area in the track image.

4. A track defect detection method based on improved YOLOv5s according to claim 1, characterized in that: Step S4 also includes: S4-1: The extracted rail surface area image is mirror-flipped in the horizontal or vertical direction by using an image transformation algorithm; S4-2: Rotate the track surface area image; S4-3: Zoom in and out the track surface area image; S4-4: Eliminate Gaussian noise and salt and pepper noise in the rail surface area image; Step S5 also includes: S5-1: Use the labelimg image annotation tool to manually select and annotate the defect information on the enhanced track image data; when selecting, use the selected annotation tool to draw a corresponding shape on the image to mark the track defect area; S5-2: Save and generate the data set; after labeling, save it as a txt file with the corresponding name.

5. A track defect detection method based on improved YOLOv5s according to claim 4, characterized in that: Step S4-2 includes the following steps: The rail surface area image is copied into multiple copies, and the copied rail surface area image is rotated according to different angles to form a rotated rail surface area image.

6. A rail defect detection method based on improved YOLOv5s according to claim 5, characterized in that: Step S4-3 includes the following steps: The rotated rail surface area image is copied into multiple copies, and the copied rail surface area image is scaled according to different proportions to form a scaled rail surface area image.

7. The track defect detection method based on improved YOLOv5s according to claim 1, characterized in that: Step S6 includes the following steps: S6-1: Input data and perform convolution operation through the convolution layer; S6-2: Split the feature map obtained after convolution into the original feature map and the feature map that needs to be extracted at a deeper level in the channel dimension; S6-3: The feature map that needs to be extracted at a deeper level is calculated through the Bottleneck module; S6-4: Adjust the number of channels through convolution operation; S6-5: Calculation via deformable convolution module; Calculate using the following formula: In the above formula, p n is the nth sampling point in the grid, Δm n is the weight coefficient. If the area of ​​the sampling point is not of interest, the weight learning is 0, and if it is of interest, it is 1; Δp n is the offset of the nth sampling point; p0 is the central sampling point of the convolution; R is the sampling point set, R = {(-1,-1), (-1,0), (1,0), (0,0), (1,0) (1,-1), (1,0), (1,1)}; w(·) is the convolution operation, x(·) represents the pixel value of the point; S6-6: Feature fusion via asymptotic feature pyramid network; S6-7: Assign different spatial weights to features at different levels through the adaptive feature fusion module; assign weights to features at different levels according to the importance of features at specific locations, and automatically select the most effective features for the current task; S6-8: Considering the shape of the track defect and the performance of the evaluation model, the loss function is constructed as follows: Among them, CIoU lOSS represents the complete intersection-over-union ratio of the loss, d represents the distance between the center point of the real box and the center point of the predicted 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 to measure the scale; IoU represents the intersection-over-union ratio, IoU LOSS represents the intersection-over-union ratio of the loss, CIoU represents the complete intersection-over-union ratio; S6-9: The feature map processed by the deformable convolution module is sent to the next level network to continue the target detection process.

8. A track defect detection method based on improved YOLOv5s according to claim 6, characterized in that: Step S6-3 also includes: S6-3-1: Adjust the number of channels through the convolution layer to reduce the dimension; S6-3-2: Extract spatial feature information from the image through the convolution layer; S6-3-3: The feature map processed by the Bottleneck module is fused with the original feature map in step S6-2 by Concatenate; S6-6 also includes: S6-6-1: Input features and extract multi-scale feature maps at different levels from Backbone; S6-6-2: The feature maps of each layer are processed from high to low through the upsampling module, and the lower resolution feature maps are restored to higher resolution and fused 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 multi-scale feature maps at each level, so that the network can focus on the feature areas that are more important for target detection; S6-6-4: Process the feature maps of each level from low to high through the downsampling module; S6-6-5: Final feature output.

9. The track defect detection method based on improved YOLOv5s according to claim 6, characterized in that: Step S6-7 also includes: S6-7-1: Feature fusion, generating fused feature maps through convolution; S6-7-2: Then the weights of different feature maps at each spatial position are calculated through the attention mechanism.

10. The track defect detection method based on improved YOLOv5s according to claim 1, characterized in that: The model training in step S6 is performed under the pytorch framework, the system is ubuntu18.04, and the YOLO basic model version is YOLOv5-6.1; The method further includes step S7 after step S6, wherein the track image to be inspected is input into the defect detection model trained in step S6, and the inspection result is output.

Citation Information

Patent Citations

  • Method for rapidly extracting steel rail surface area under condition of vibration

    CN106355185A

  • Fan blade defect detection method based on improved YOLOv5

    CN114926400A

  • Insulator defect detection model construction method and system

    CN115063648A

  • Hot rolled steel strip surface defect detection method based on improved YOLOv5s network

    CN117132827A

  • Railway track defect automatic identification image quality enhancement method and device and medium

    CN117333379A