Track fastener detection method and system based on improved YOLO-v5 model
By improving the YOLO-v5 model, using MobileNetV2 network and DAS/EMA module for feature extraction and data enhancement processing, the problem of small data set size and large computing overhead in track fastener detection is solved, and the detection effect of high precision and low computing overhead is achieved.
Patent Information
- Application Number
- CN202411897656.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-15
AI Technical Summary
In the track fastener detection, the prior art problems such as small data set size, incomplete feature extraction and large computing overhead.
By improving the YOLO-v5 model, using the MobileNetV2 network as the backbone network, and introducing the DAS dynamic convolution module and the EMA attention mechanism module into the feature fusion network, data augmentation processing is performed to expand the data set.
High-precision detection of track fasteners is achieved, the accuracy and comprehensiveness of feature extraction is improved, and the calculation overhead is reduced, making this method more suitable for edge-end deployment.
Smart Images

Figure CN119831955A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of rail fastener detection, and in particular to a rail fastener detection method and system based on an improved YOLO-v5 model. Background Art
[0002] Track fasteners play a vital role in rail transportation. They not only ensure the stability of the track, but also ensure the safe operation of trains. These fasteners connect the track and the sleepers and are subject to huge forces and dynamic loads. Therefore, their integrity is directly related to the safety and efficiency of the railway system. However, traditional fastener inspection methods mainly rely on manual inspection. Although this method has been widely used in the past, it has many defects. Manual inspection is not only time-consuming and labor-intensive, but also easily affected by the subjective judgment of the inspectors and the external environment, resulting in frequent missed inspections and false inspections, thus affecting the overall safety.
[0003] With the advancement of science and technology, computer vision and deep learning technologies provide new solutions for automated inspection. These technologies use high-resolution cameras to capture real-time images of the track, and then analyze the image content through deep learning models to identify and locate the status of fasteners. This automated inspection system can not only greatly improve the speed and accuracy of inspection, but also maintain consistent performance under various environmental conditions, thereby greatly reducing the impact of human factors on the inspection results. At present, deep learning target detection algorithms can be divided into two categories: two-stage detection algorithms and one-stage detection algorithms. Two-stage detection algorithms include convolutional neural networks, CNNs, and R-CNNs, which generate candidate boxes containing potential targets and then use regional classifiers to predict them. One-stage detection algorithms, such as SSD and YOLO series, directly classify and predict targets at each position on the feature map, with faster detection speed and stronger practicality. YOLO-v5 has significantly improved speed and accuracy, and is suitable for complex inspection scenarios.
[0004] However, for the detection of rail fasteners, YOLO-v5 still has problems such as small dataset size, incomplete feature extraction, and high computational overhead. Summary of the invention
[0005] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and to provide a rail fastener detection method and system based on an improved YOLO-v5 model, so as to solve or partially solve the problems of small data set size, incomplete feature extraction, high computational overhead, etc.
[0006] The purpose of the present invention can be achieved by the following technical solutions:
[0007] One aspect of the present invention provides a rail fastener detection method based on an improved YOLO-v5 model, comprising the following steps:
[0008] Obtain rail fastener images, annotate the rail fastener status, and construct an annotated raw data set;
[0009] Performing data enhancement processing on the original data set;
[0010] Based on the data-enhanced dataset, train the YOLO-v5 model based on the MobileNetV2 network;
[0011] Obtain the image of the track fastener to be predicted, use the trained YOLO-v5 model to predict the state of the track fastener, and realize track fastener detection.
[0012] As a preferred technical solution, the data enhancement process includes:
[0013] Constructing a first enhancement space and a second enhancement space, wherein for each enhancement space, a plurality of data enhancement operations are included;
[0014] constructing an operation sampling strategy for generating a plurality of data augmentation operations from the first augmentation space and / or the second augmentation space;
[0015] Based on the original data set, new data is obtained by utilizing the operation sampling strategy to form an enhanced data set.
[0016] As a preferred technical solution, the data enhancement operations of the first enhancement space include rotation, horizontal flipping, vertical flipping, scaling, horizontal coordinate transformation, vertical coordinate transformation, horizontal shearing and vertical shearing, and the data enhancement operations of the second enhancement space include contrast conversion, sharpening operation, brightness change, Gaussian blur and noise.
[0017] As a preferred technical solution, the YOLO-v5 model includes a backbone network based on MobileNetV2, a feature fusion network and a detection head.
[0018] As a preferred technical solution, the backbone network includes multiple depth-separable convolutions, dynamic convolution DAS modules, multiple inverted residual structures and linear bottleneck modules.
[0019] Among them, the separable convolution model is:
[0020]
[0021] In the above formula, X is the feature map, D(X) represents the result of deep convolution, and K C is the convolution kernel of the Cth channel, W is a 1×1 convolution kernel, i.e., point-by-point convolution, and Y is the feature map of the final output.
[0022] The dynamic convolution DAS module is modeled as:
[0023]
[0024] Y=FFN(A i (W v *X))+FFN(X+Δ)
[0025] In the above formula, A i is the attention weight, Q i is the query vector, K is the key vector, and d k is the dimension of the key, X is the input feature, W v is the convolution kernel used to generate the value vector, FFN is a feedforward neural network used to further process the variability features, and Δ is the variability offset obtained through learning.
[0026] As a preferred technical solution, the feature fusion network includes an EMA attention mechanism module, an FPN module and a PAN module, wherein the EMA attention mechanism module is modeled as:
[0027]
[0028] In the above formula, W s is the convolution kernel, X s is the input feature map, σ is the activation function, and Y is the enhanced feature map of the final output.
[0029] As a preferred technical solution, the detection head includes a category prediction branch and a position prediction branch.
[0030] As a preferred technical solution, the rail fastener states include a fastener missing state, a fastener displacement state, a fastener damaged state and a normal fastener state.
[0031] As a preferred technical solution, during the training process of the YOLO-v5 model, the loss function is configured as:
[0032] Loss=1-IoU(B,G)+α·D(B,G)+β·A(B,G)
[0033]
[0034]
[0035] Among them, α and β are adjustment parameters, IoU is the ratio of the area of the intersection of the predicted box and the real box to the area of the union, D(B,G) represents the distance between the center coordinates of the predicted box B and the real box G, A(B,G) represents the difference in the aspect ratio of the predicted box B and the real box G, and x B ,y BRespectively represent the horizontal and vertical coordinates of the prediction box, x G ,y G Respectively represent the horizontal and vertical coordinates of the real frame, w B 、h B Respectively represent the width and height of the prediction box, w G 、h G Represent the width and height of the real box respectively.
[0036] Another aspect of the present invention provides a rail fastener detection system based on an improved YOLO-v5 model, which is used to implement the aforementioned rail fastener detection method based on the improved YOLO-v5 model, and the system includes:
[0037] The labeling module is used to obtain rail fastener images, label the rail fastener status, and construct an original data set with labels;
[0038] A data enhancement processing module, used for performing data enhancement processing on the original data set;
[0039] Model training module, used to train the YOLO-v5 model based on the MobileNetV2 network based on the data-enhanced dataset;
[0040] The rail fastener detection module is used to obtain the rail fastener image to be predicted, use the trained YOLO-v5 model to predict the rail fastener status, and realize rail fastener detection.
[0041] Compared with the prior art, the present invention has at least one of the following beneficial effects:
[0042] (1) Ensuring sample richness through sample expansion: In data enhancement, the present invention achieves sample data volume expansion through random sampling, and the sample distribution is random.
[0043] (2) Accurate and comprehensive feature extraction: By adopting an improved MobileNetV2 backbone network to achieve fast and effective feature extraction, both the DAS module and the EMA module can enhance feature expression without increasing computational overhead, making the present invention more suitable for edge deployment and achieving accurate detection of rail fasteners in complex backgrounds. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 It is a schematic diagram of the flow of the rail fastener detection method based on the improved YOLO-v5 model in the embodiment;
[0045] Figure 2 This is a schematic diagram of data enhancement in the embodiment;
[0046] Figure 3 is a schematic diagram of a DAS module in an embodiment;
[0047] Figure 4 Schematic diagram of the EMA module in the embodiment;
[0048] Figure 5 This is a schematic diagram of the improved YOLO-v5 model structure in the embodiment;
[0049] Figure 6 Schematic diagram of a rail fastener detection system based on an improved YOLO-v5 model in an embodiment;
[0050] Figure 7 Schematic diagram of an electronic device in an embodiment. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0052] Example 1
[0053] In view of the problems existing in the aforementioned prior art, this embodiment provides a rail fastener detection method based on an improved YOLO-v5 model with high accuracy, low false alarm rate, and fast inference speed. The rail fastener dataset with annotations is expanded and constructed through data enhancement processing to generate enhanced image samples for training. The backbone network of YOLO-v5 is replaced by the original CSPNet with an improved MobileNetV2 network, which contains multiple depth-separable convolutions, DAS dynamic convolution modules, multiple inverted residual structures, and linear bottleneck modules; in addition, the feature fusion network is changed to an EMA attention mechanism, a combination of FPN and PAN modules. Finally, based on the modified rail fastener detection model, the image to be detected is detected to generate accurate detection results.
[0054] See also Figure 1 , the methods mainly include:
[0055] S100, obtaining and constructing a rail fastener image dataset with annotations.
[0056] Track fastener videos are collected during the inspection process, and the track fastener RGB image dataset is collected by video frame sampling. The Labelme tool is used to label the track fastener RGB images, and the annotated categories are fastener missing state, fastener displacement state, fastener damage state and normal fastener state.
[0057] Specifically, images of rail fasteners can be collected through the data acquisition system built by the rail inspection vehicle. High-performance industrial cameras and related image acquisition equipment are installed in the rail inspection vehicle to ensure that real-time images and videos of rail fasteners can be captured efficiently and accurately. The construction of this system is designed to meet the needs of subsequent data set construction and ensure that the collected images have sufficient clarity and stability. During the inspection process, the system automatically records videos of rail fasteners. Through video frame sampling technology, key frames are extracted from them to collect RGB image datasets of rail fasteners. The extracted RGB images are annotated using the Labelme tool, and the annotated categories include fastener missing state, fastener displacement state, fastener damage state, and normal fastener state. The labeling process ensures that each image is accurately classified, thereby providing clear supervision signals for subsequent model training and improving the model's ability to recognize various states.
[0058] S200, data augmentation and expansion of the dataset.
[0059] The scale and diversity of the dataset are further improved through data augmentation. Through hyperparameter mapping, this method can sample a limited number of augmentation operations from the predefined pixel augmentation space and spatial augmentation space to generate a reasonable augmentation level. Specifically:
[0060] The data augmentation method is used to expand the dataset size for the annotated original images and their labels. The data augmentation method samples a limited number of data augmentation operations from the pixel augmentation space and the spatial augmentation space through hyperparameter mapping to produce a reasonable enhancement level. The pixel augmentation space includes: contrast conversion, sharpening operation, brightness change, Gaussian blur and noise. The spatial augmentation space includes: rotation, shift, vertical and horizontal flip, and scaling operations.
[0061] Specifically, Figure 2 As shown in the figure, two enhancement spaces Ap and As are designed, and operations that may destroy image details and features are excluded. Ap and As contain 6 and 8 common data enhancement operations, respectively. In addition, an operation sampling strategy Π is developed to limit the number of operations sampled from the two spaces, thereby generating M = {2,3} sequential DA operations in each expansion branch, where M represents the maximum number of sampling times from the Ap and As enhancement spaces. The Ap enhancement space includes operations such as contrast conversion, sharpening operations, light and dark changes, Gaussian blur, and noise. These operations simulate the visual effects under different shooting conditions and enhance the robustness of the model by changing parameters such as image brightness, contrast, and clarity.
[0062] The image contrast conversion formula is specifically expressed as:
[0063] g'(x,y)=α·g(x,y)+β
[0064] Where g(x,y) is the original image pixel, g'(x,y) is the output image pixel, x and y indicate that the pixel is located in the xth row and yth column, and the parameters a>0 and β are the gain and bias parameters, which control the contrast and brightness respectively;
[0065] The image sharpening operation formula is specifically expressed as:
[0066]
[0067] Among them, is the Laplace operator of the image, which calculates the second-order derivative of the image. is the sharpening coefficient, which controls the sharpening intensity.
[0068] The image brightness conversion formula is specifically expressed as:
[0069] g'(x,y)=g(x,y)+b
[0070] Where b is the brightness gain parameter.
[0071] The Gaussian blur formula is specifically expressed as:
[0072]
[0073] Among them, G(i,j) is the Gaussian kernel, expressed as:
[0074]
[0075] Among them, σ controls the degree of blur, and k is the kernel size
[0076] The Gaussian noise formula is specifically expressed as:
[0077] g'(x,y)=g(x,y)+N(0,σ 2 )
[0078] Among them, the mean is 0 and the variance is σ 2 Gaussian noise.
[0079] The augmented space includes rotation, shift, vertical and horizontal flipping, and scaling operations. These operations enhance the model's adaptability to different viewpoints and positions by changing the spatial layout of the image.
[0080] The image rotation formula is specifically expressed as:
[0081]
[0082] Where (x, y) represents the coordinates of the pixel in the original image, (x', y') represents the coordinates of the pixel in the output image after the corresponding pixel (x, y) is rotated, and θ is the rotation angle.
[0083] The image translation formula is specifically expressed as:
[0084]
[0085] Where (x0, y0) is the translation of the image along the x-axis and y-axis;
[0086] The image vertical flip transformation formula is specifically expressed as:
[0087]
[0088] The image horizontal flip transformation formula is specifically expressed as:
[0089]
[0090] Where N and M represent the length and width of the image, respectively, (x, y) is the original image coordinate, and (x', y') is the transformed coordinate;
[0091] The image scaling formula is specifically expressed as:
[0092] x'=s x ·x,y'=s y ·y
[0093] Among them, s x is the horizontal scaling factor. y is the scaling factor in the vertical direction.
[0094] The data augmented dataset is divided into training set, validation set and test set in the ratio of 7:1:2.
[0095] S300 replaces the YOLO-v5 model backbone network with an improved MobileNetV2 network and adds a DAS dynamic convolution module to enhance feature extraction capabilities.
[0096] The backbone network is replaced from the original CSPNet to an improved MobileNetV2 network, including multiple depth-wise separable convolutions, DAS dynamic convolution modules, multiple inverted residual structures, and linear bottleneck modules.
[0097] The rail fastener image is input into the constructed YOLO-v5 target detection network, which outputs the fastener status and fastener position; the target detection network includes a backbone network, a feature fusion network and a detection head.
[0098] As a preferred solution of the rail fastener detection method based on the improved YOLO-v5 model of the present invention, wherein:
[0099] In the backbone network, the image first passes through the improved MobileNetV2 network, performing multiple depth-separable convolutions to extract initial features; then, the features are processed layer by layer through multiple inverted residual structures to retain important feature information, and feature dimension compression is achieved through a linear bottleneck module. Finally, the initial features are enhanced through the DAS module to output a more semantic feature representation.
[0100] In the feature fusion network, the features first pass through the upsampling module to improve the feature resolution; then, the EMA module is added to the upsampling module to smooth the upsampled features to reduce noise and enhance stability; then, the smoothed features are input into the FPN module to construct a feature pyramid to improve the perception of targets of different scales; finally, the features are passed to the PAN module to further enhance feature propagation, thereby optimizing information flow and feature integration.
[0101] In the detection head, the fusion features are input into the category prediction branch and the position prediction branch. First, the category judgment is performed through the improved Softmax activation function in the category prediction branch. Then, the features are optimized in the position prediction branch using the revised loss function to output the final fastener status and position.
[0102] Specifically, Figure 3 In the backbone network of the YOLOv5 model, the input image is first processed by the improved MobileNetV2 network to extract the initial features. The improved MobileNetV2 performs preliminary feature extraction through multiple layers of deep separable convolution, effectively reducing the amount of calculation and the amount of parameters, thereby retaining a high computational efficiency. At the same time, the initial features processed by deep separable convolution further enter multiple inverted residual structures, which transmit features layer by layer, retain important feature information, and achieve feature dimension compression through a linear bottleneck module for efficient transmission in subsequent networks. Finally, the processed initial features are processed by the DAS module for information enhancement and feature optimization, thereby outputting feature representations with stronger semantic expression.
[0103] A DAS dynamic convolution module is added to each linear bottleneck module of the replaced MobileNetV2 backbone network to more effectively extract and reorganize important features and enhance feature expression capabilities. The feature representation of the DAS dynamic convolution module is:
[0104]
[0105] Y=FFN(A i (W v *X))+FFN(X+Δ)
[0106] Among them, A i is the attention weight, Qi is the query vector, K is the key vector, and d k is the dimension of the key, X is the input feature, W v is the convolution kernel used to generate the value vector, FFN is a feedforward neural network used to further process the variability features, and Δ is the variability offset obtained through learning. The DAS dynamic convolution module aims to improve the performance of the model by dynamically searching for the optimal network architecture. The core of this module is the dynamic perceptron, which can adaptively adjust the weights of the convolution kernel according to the input features to achieve personalized processing of different input data. In the DAS dynamic convolution module, the input features are first encoded through an attention mechanism, and then these encoded features are used to dynamically adjust the convolution kernel so that the network can optimize its structure for specific input data. This dynamic adjustment not only enhances the model's ability to express features, but also improves the model's flexibility and adaptability. In this way, the DAS dynamic convolution module can significantly improve the model's performance in various visual tasks while keeping the model lightweight, especially when performing real-time image processing on resource-constrained devices.
[0107] S400 adds an EMA attention mechanism module to the upsampling module of the feature fusion network of the YOLO-v5 model to preserve channel information and reduce computational overhead.
[0108] like Figure 4 As part of the improved YOLOv5 model, in the feature fusion network, the extracted features first pass through the upsampling module to improve the resolution of the features to capture more detailed information. The EMA module is also introduced in the upsampling module to smooth the upsampled features, reduce the interference of high-frequency noise, and improve the stability of the features, thereby enhancing the robustness of the model in different environments. The smoothed features are then input to the FPN module, and through the construction of the feature pyramid, the model's perception of targets of different scales is improved, enabling it to better identify fasteners of various sizes. Finally, the features are passed to the PAN module, which optimizes the information flow on the basis of further enhancing feature propagation and integration, ensuring the effective fusion of multi-level features, thereby improving the model's detection performance for rail fasteners.
[0109] The EMA module is an attention mechanism. First, the channels of the feature map are divided into multiple subgroups to reduce the redundant information between channels and maintain the uniform distribution of spatial semantic features. Then, these sub-feature groups are processed in two parallel paths: one path captures global context information through 1x1 convolution operations and global average pooling, while the other path extracts local detail features through 3x3 convolution kernels. The outputs of these two paths are then fused inside the EMA module, using matrix dot product operations to achieve cross-space learning, thereby capturing pixel-level pairwise relationships and strengthening the representation of global context. The fused feature maps are normalized by the sigmoid activation function to accurately adjust the weights of each channel to prevent numerical instability. Finally, the normalized feature maps are interactively integrated across dimensions to further enhance the model's ability to capture detailed features. The features of these feature maps in key areas are enhanced, while redundant information is suppressed, which significantly improves the model's performance in visual tasks such as object detection.
[0110] An EMA attention mechanism module is added to the upsampling module of the feature fusion network to preserve channel information and reduce computational overhead. The feature representation of the EMA attention mechanism module is:
[0111]
[0112] Among them, W s is the convolution kernel, X s is the input feature map, σ is the activation function, and Y is the enhanced feature map of the final output.
[0113] In the detection head of the improved YOLOv5 model, the fused features are distributed to the category prediction branch and the position prediction branch. The category prediction branch uses an improved Softmax activation function to improve the accuracy of category judgment, so that the model can more accurately identify the category of the fastener. In the position prediction branch, the revised loss function α-IoULoss is used to optimize the position to improve the accuracy of position prediction. This optimized loss function can more effectively reduce the positioning error while retaining the model prediction effect, thereby accurately outputting the state and position of the fastener.
[0114] S500, replace the improved YOLOv5 model loss function with α-IoU Loss.
[0115] This loss function adjusts the sensitivity of IoU (intersection over union) by introducing a power parameter α, thereby enhancing the accuracy and robustness of the model for bounding box regression. When the α value increases, the loss function gives greater weight to the prediction of high IoU values, prompting the model to pay more attention to accurate bounding box predictions. This loss function shows better performance and faster convergence speed than traditional IoU loss in object detection tasks. The α-IoU Loss loss function is expressed as:
[0116] Loss=1-IoU(B,G)+α·D(B,G)+β·A(B,G)
[0117]
[0118]
[0119] Among them, α and β are adjustment parameters used to balance the impact of different loss terms. IoU is the ratio of the area of the intersection of the predicted box and the true box to the area of the union. D(B,G) calculates the distance between the center coordinates of the predicted box and the true box. A(B,G) calculates the difference in the aspect ratio between the predicted box and the true box.
[0120] The evaluation is based on the detection results. The evaluation index involved is mAP@0.5:0.95. The evaluation index mAP is obtained by calculating the average accuracy of the model at the IoU threshold, which is expressed as:
[0121]
[0122]
[0123] Among them, mAP represents mean average precision, p represents precision, R represents recall, TP represents the number of positive classes predicted as positive classes, FP represents the number of negative classes predicted as positive classes, and FN represents the number of negative classes predicted as negative classes. Preferably, the IoU threshold range is [0.5, 0.95].
[0124] In order to verify the beneficial effects of this method, the comparison results of two schemes are provided.
[0125] First, the experimental environment and parameter settings. The hardware configuration of this experiment is NvidiaRTXA4000 GPU and Intel i7-12700 2.70GHz CPU under P920 tower graphics workstation, and the software environment is Pytorch deep learning framework under Windows11 system. The input image size is 640×640, and there are 200 training rounds in total. At the same time, in order to accelerate network convergence, the official pre-trained weights are used as the initial weights, the initial learning rate of network training is set to 0.001, the epoch is set to 200, and the batch size is set to 16.
[0126] Prepare experimental data sets. The data sets use a 200-meter track line as the experimental site to create a track fastener data set. In the experiment, track fasteners are selected as the research object. These data sets will be used to train and test the track fastener detection model. The data sets are divided into 1400 training sets, 200 validation sets, and 400 test sets for experiments to evaluate the performance of each strategy.
[0127] The performance of the model is evaluated according to the following evaluation indicators: mean Average Precision (mAP) denoted as PmAP, frames per second (FPS) and computational overhead (GLOPs). The relevant formulas are as follows:
[0128]
[0129]
[0130]
[0131] Among them, T p The positive samples are correctly classified; T N Negative samples are correctly classified; F p Negative samples are misclassified; F N The positive samples are misclassified. n is the number of all categories; P A is the average precision of the target category.
[0132] Finally, the experimental results of rail fastener detection were obtained. In order to verify the effectiveness and superiority of the algorithm, the method proposed in the present invention was experimentally compared with Fast R-CNN, Faster-RCNN, YOLOv5s, YOLOv5, YOLOv5X and other methods under the same training conditions and data. Several models were tested on the data set and the average accuracy and processing speed detection results were compared. The experimental results are shown in Table 1.
[0133] Table 1 Comparative experimental results
[0134] algorithm Model size PmAP@0.5 / % frames per second Calculation Amount Fast-RCNN 80 75.3 32 105.2 Faster-RCNN 104 74.2 68 101.7 YOLOv5s 14 77.6 84 47.3 YOLOv5 27 88.5 81 108.2 YOLOv5X 73 81.2 73 164.8 Algorithm of the present invention 24 90.1 95 91.8
[0135] Comparing the experimental results of various target detection algorithms in the table, it can be seen that this method has obvious advantages in the average precision index and shows good detection accuracy. Compared with the YOLOv5s algorithm, the algorithm of the present invention has improved the average precision by 12.5%, compared with YOLOv5 by 1.6%, and compared with Faster-RCNN by 15.9%. Compared with the YOLOv5X algorithm, the detection accuracy of the algorithm of the present invention has increased by 9.0%.
[0136] In terms of detection speed, although YOLOv5s and Faster-RCNN have higher frames per second, the algorithm of the present invention is significantly superior to them in detection accuracy; although YOLOv5X has a slight advantage in speed, its detection accuracy is relatively low, and it is difficult to meet the high-precision detection requirements in complex environments. In summary, the algorithm of the present invention is not only superior to the YOLOv5s target detection algorithm in average accuracy and detection speed, but also achieves a significant improvement in detection accuracy, achieving a good balance between speed and accuracy, and is suitable for target detection requirements in complex scenes.
[0137] Example 2
[0138] Based on Example 1, this example provides a rail fastener detection based on an improved YOLO-v5 model. Figure 6 , the system includes:
[0139] (1) The labeling module is used to obtain rail fastener images, label the rail fastener status, and construct an annotated raw data set.
[0140] (2) A data enhancement processing module, used to perform data enhancement processing on the original data set.
[0141] (3) Model training module, used to train the YOLO-v5 model based on the MobileNetV2 network based on the data augmented dataset.
[0142] (4) Track fastener detection module, which is used to obtain the track fastener image to be predicted, use the trained YOLO-v5 model to predict the track fastener status, and realize track fastener detection.
[0143] Compared with the prior art, the present invention achieves sample data volume expansion through random sampling in data enhancement, and the sample distribution is random. Fast and effective feature extraction is achieved through the improved MobileNetV2 backbone network. Both the DAS module and the EMA module can enhance feature expression without increasing computational overhead, making the present invention more suitable for edge deployment and achieving accurate detection of rail fasteners under complex backgrounds.
[0144] Example 3
[0145] Based on the above embodiments, this embodiment provides an electronic device, including:
[0146] Memory and processor;
[0147] The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions. When the computer executable instructions are executed by the processor, the steps of the rail fastener detection method based on the improved YOLO-v5 model described in the embodiment are implemented.
[0148] like Figure 7 As mentioned above, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 Of course, in addition to the software implementation, the present invention does not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0149] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0150] Example 4
[0151] Based on the foregoing implementation, this embodiment provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the rail fastener detection method based on the improved YOLO-v5 model.
[0152] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0153] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A rail fastener detection method based on an improved YOLO-v5 model, characterized in that: The steps include: Obtain rail fastener images, annotate the rail fastener status, and construct an annotated raw data set; Performing data enhancement processing on the original data set; Based on the data-enhanced dataset, train the YOLO-v5 model based on the MobileNetV2 network; Obtain the image of the track fastener to be predicted, use the trained YOLO-v5 model to predict the state of the track fastener, and realize track fastener detection.
2. A rail fastener detection method based on an improved YOLO-v5 model according to claim 1, characterized in that: The data enhancement process includes: Constructing a first enhancement space and a second enhancement space, wherein for each enhancement space, a plurality of data enhancement operations are included; constructing an operation sampling strategy for generating a plurality of data augmentation operations from the first augmentation space and / or the second augmentation space; Based on the original data set, new data is obtained by utilizing the operation sampling strategy to form an enhanced data set.
3. A rail fastener detection method based on an improved YOLO-v5 model according to claim 2, characterized in that: The data enhancement operations of the first enhancement space include rotation, horizontal flipping, vertical flipping, scaling, horizontal coordinate transformation, vertical coordinate transformation, horizontal shearing and vertical shearing, and the data enhancement operations of the second enhancement space include contrast conversion, sharpening operation, brightness change, Gaussian blur and noise.
4. A rail fastener detection method based on an improved YOLO-v5 model according to claim 1, characterized in that: The YOLO-v5 model includes a backbone network based on MobileNetV2, a feature fusion network and a detection head.
5. A rail fastener detection method based on an improved YOLO-v5 model according to claim 4, characterized in that: The backbone network includes multiple depth-separable convolutions, dynamic convolution DAS modules, multiple inverted residual structures and linear bottleneck modules. Among them, the separable convolution model is: In the above formula, X is the feature map, D(X) represents the result of deep convolution, and K C is the convolution kernel of the Cth channel, W is a 1×1 convolution kernel, i.e., point-by-point convolution, and Y is the feature map of the final output. The dynamic convolution DAS module is modeled as: Y=FFN(A i (W v *X))+FFN(X+Δ) In the above formula, A i is the attention weight, Q i is the query vector, K is the key vector, and d k is the dimension of the key, X is the input feature, W v is the convolution kernel used to generate the value vector, FFN is a feedforward neural network used to further process the variability features, and Δ is the variability offset obtained through learning.
6. A rail fastener detection method based on an improved YOLO-v5 model according to claim 4, characterized in that: The feature fusion network includes an EMA attention mechanism module, an FPN module and a PAN module, wherein the EMA attention mechanism module is modeled as follows: In the above formula, W s is the convolution kernel, X s is the input feature map, σ is the activation function, and Y is the enhanced feature map of the final output.
7. A rail fastener detection method based on an improved YOLO-v5 model according to claim 4, characterized in that: The detection head includes a category prediction branch and a position prediction branch.
8. The rail fastener detection method based on the improved YOLO-v5 model according to claim 1, characterized in that: The rail fastener states include a fastener missing state, a fastener displacement state, a fastener damaged state and a normal fastener state.
9. The rail fastener detection method based on the improved YOLO-v5 model according to claim 1, characterized in that: During the training process of the YOLO-v5 model, the loss function is configured as: Loss=1-IoU(B,G)+α·D(B,G)+β·A(B,G) Among them, α and β are adjustment parameters, IoU is the ratio of the area of the intersection of the predicted box and the real box to the area of the union, D(B,G) represents the distance between the center coordinates of the predicted box B and the real box G, A(B,G) represents the difference in the aspect ratio of the predicted box B and the real box G, and x B ,y B Respectively represent the horizontal and vertical coordinates of the prediction box, x G ,y G Respectively represent the horizontal and vertical coordinates of the real frame, w B 、h B Respectively represent the width and height of the prediction box, w G 、h G Represent the width and height of the real box respectively.
10. A rail fastener detection system based on an improved YOLO-v5 model, characterized in that: A system for implementing the rail fastener detection method based on the improved YOLO-v5 model as described in any one of claims 1 to 9, comprising: The labeling module is used to obtain rail fastener images, label the rail fastener status, and construct an original data set with labels; A data enhancement processing module, used for performing data enhancement processing on the original data set; Model training module, used to train the YOLO-v5 model based on the MobileNetV2 network based on the data-enhanced dataset; The rail fastener detection module is used to obtain the rail fastener image to be predicted, use the trained YOLO-v5 model to predict the rail fastener status, and realize rail fastener detection.
Citation Information
Cited By
Isolation switch on-off state detection method and device based on deep learning
CN120707882A
A deep learning-based detection method and device for open / close state of an isolating switch
CN120707882B