Method and system for detecting gap of s700K switch machine based on improved Deeplabv3 +

By using mobilenetv2 and CBAM modules in DeepLabv3+ network, combined with specific loss functions, the problems of large calculation overhead and insufficient feature extraction capabilities in the gap detection of switch machines are solved, and more efficient and accurate gap detection is achieved.

CN119919358APending Publication Date: 2025-05-02SHANGHAI TIEDA ELECTRONICS & INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411947164.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

The traditional DeepLabv3+ network has a large calculation overhead in the detection of the switch machine gap, slow detection speed, and insufficient ability to extract detailed features, resulting in low detection efficiency and accuracy.

Method used

In the DeepLabv3+ network, mobilenetv2 is used as the backbone feature extraction network, and CBAM mixed attention module is added, combining the weighted cross entropy loss function and the loss function of the DiceLoss function to improve the network structure to improve feature extraction and expression capabilities.

Benefits of technology

While maintaining low computing overhead, the improved network can more accurately locate and identify detailed features of the gap area, improving the efficiency of detection and the accuracy of detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919358A_ABST
    Figure CN119919358A_ABST
Patent Text Reader

Abstract

The invention discloses an s700K point switch gap detection method and system based on improved Deeplabv3 +, and belongs to the field of point switch gap detection.The method comprises the steps that a training set and a test set are determined according to collected s700K point switch gap images in the process that a train passes through a turnout and a point switch drives the turnout to be converted; based on a Deplabv3 + network, selecting a mobiletv2 lightweight network as a backbone feature extraction network, and adding a mixed attention module (CBAM) to obtain an improved network; training the improved network by using the training set and the test set to obtain an improved detection network; and inputting the gap image into the improved detection network to obtain a detection result. The detection efficiency and the accuracy of the detection result are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of switch machine gap detection, and in particular relates to a method and system for detecting gaps in S700K switch machines based on an improved deeplabv3+. Background Technology

[0002] With the rapid development of railway transportation, train operation safety has received increasing attention. As a key piece of equipment in the railway transportation system, the gap detection of the S700K switch machine is of great significance to ensuring the safe operation of the turnout system. Traditional manual inspection methods suffer from low detection efficiency, strong subjectivity of results, and susceptibility to weather and lighting conditions, making it difficult to meet the safety and reliability requirements of modern railway transportation.

[0003] In related technologies, switch machine gap detection can be performed using the DeepLabv3+ semantic segmentation network based on deep learning. This method automatically identifies and locates the gap position by performing semantic segmentation on the gap image, improving the automation and accuracy of detection and reducing the workload of manual inspection.

[0004] However, the complex network structure of DeepLabv3+ results in high computational overhead, making it difficult to meet the speed requirements of practical applications. The network's ability to extract detailed features is insufficient, leading to accuracy loss when processing notch features at different scales, thus reducing detection efficiency and accuracy. Summary of the Invention

[0005] This application provides a notch detection method and system for S700K switch machines based on an improved deeplabv3+, which improves the efficiency of detection and the accuracy of detection results.

[0006] In the first aspect, this application provides an S700K switch machine gap detection method based on an improved deeplabv3+, which determines the training set and test set based on the collected S700K switch machine gap images of trains passing through the switch and the switch machine driving the switch conversion process. Based on the deeplabv3+ network, the mobilenetv2 lightweight network was selected as the backbone feature extraction network and a hybrid attention module CBAM was added to obtain an improved network; The improved detection network is obtained by training the training and test sets. The notch image is input into the improved detection network to obtain the detection results. By adopting the above technical solution, and selecting MobileNetv2 as the backbone feature extraction network in the DeepLabv3+ network and adding a CBAM hybrid attention module, the network possesses stronger feature extraction and representation capabilities. MobileNetv2's deep separable convolutional structure reduces computational complexity, decreases the number of network parameters, and improves computational speed. The CBAM module, through channel attention and spatial attention mechanisms, can adaptively adjust the weights of each channel and spatial location in the feature map, enhancing its ability to learn key features of the S700K switch machine gap. This improved network structure allows the model to more accurately locate and identify detailed features of the gap region while maintaining low computational overhead, improving detection efficiency and accuracy.

[0007] In conjunction with some embodiments of the first aspect, in some embodiments, the improved network's loss function LOSS adopts a combination of the weighted cross-entropy loss function Cross-EntropyLossWithWeight and the DiceLoss function. The weighted cross-entropy loss function Cross-EntropyLossWithWeight is: In the function, w c y is the weighting coefficient. c p is a one-hot vector c The probability values ​​are calculated using the softmax or sigmoid function after the network predictions are processed; `classes` represents the number of segmentation categories, and `N` represents the total number of pixels. c The number of pixels of category c in GroundTruth; The DiceLoss function is: In the function, X represents the pixel label of the real segmented image, Y represents the pixel category of the predicted segmented image, and a is a non-zero constant; the loss function LOSS is: Loss=CrossEntropyLossWithWeight+λ*DiceLoss In the function, the value of λ is 0.2.

[0008] By employing the above technical solution, the loss function combines the weighted cross-entropy loss function and the DiceLoss function, thus addressing the data imbalance problem. The weighted cross-entropy loss function assigns different weight coefficients to different classes, ensuring that classes with fewer samples receive more attention during training, preventing the model from overfitting to the majority class. The DiceLoss function measures the overlap between the predicted and actual segmented images, directly optimizing segmentation performance metrics. The combination of these two loss functions considers both pixel-level classification accuracy and overall segmentation performance, improving the model's segmentation precision and generalization ability.

[0009] In conjunction with some embodiments of the first aspect, in some embodiments, after training the improved network with a training set and a test set to obtain the improved detection network, the method further includes: Establish evaluation criteria, which include accuracy, average intersection-over-union ratio, average pixel accuracy, and recall. Evaluate and improve the testing network according to the evaluation criteria; If the improved detection network is determined to meet the evaluation criteria, proceed with the step of inputting the notch image into the improved detection network.

[0010] By adopting the above technical solutions, accuracy reflects the overall correctness of the model's classification, mean intersection-over-union ratio measures the overlap between the predicted and real regions, mean pixel accuracy evaluates pixel-level classification accuracy, and recall characterizes the model's ability to detect real defects. Multiple evaluation metrics quantify network performance from different perspectives, improving the model's performance level before practical application.

[0011] In conjunction with some embodiments of the first aspect, in some embodiments, the evaluation criteria for accuracy, mean intersection-over-union ratio, mean pixel accuracy, and recall are expressed as follows: In the function, Accuracy is the function corresponding to accuracy, Recall is the function corresponding to average intersection-union ratio, MAP is the function corresponding to average pixel accuracy, and MIoU is the function corresponding to recall. TP represents true positives, TN represents true negatives, FP represents false positives, FN represents false negatives, and k represents the number of classes.

[0012] By employing the above technical solutions, the accuracy function comprehensively considers true positives, true negatives, false positives, and false negatives to fully evaluate classification performance. The recall function focuses on the model's ability to detect true defects. The average pixel precision function measures the accuracy of pixel-level predictions. The average intersection-union function evaluates the matching degree between the segmentation results and the ground truth labels. These mathematical evaluation metrics provide clear quantitative evidence, making model performance evaluation more objective and reliable.

[0013] In conjunction with some embodiments of the first aspect, in some embodiments, after inputting the notch image into the improved detection network and obtaining the detection result, the method further includes: Calculate the average pixel coordinates of the center line of the center line of the intermediate positioning block based on the mask value in the detection results; Calculate the average pixel coordinates of the left line of the gap based on the detection results; Calculate the average pixel coordinates of the right line of the gap based on the detection results; The average pixel coordinates of the center line, the average pixel coordinates of the left line, and the average pixel coordinates of the right line are input into the actual distance function group to calculate the left actual distance from the center line of the middle positioning block to the left line of the gap and the right actual distance from the center line of the middle positioning block to the right line of the gap. When either the actual left distance or the actual right distance is within the preset range, the S700K switch machine gap is determined to be normal. When both the actual left distance and the actual right distance are outside the preset range, the S700K switch machine gap is determined to be abnormal.

[0014] By employing the above technical solution, the system calculates the average pixel coordinates of the centerline of the intermediate positioning block and the left and right lines of the gap. These coordinates are then input into a set of actual distance functions for calculation, yielding the actual distances from the centerline of the intermediate positioning block to the left and right lines of the gap. Based on a comparison of these actual distances with preset range values, the system can accurately determine whether the gap in the S700K switch machine is normal or abnormal. This method, based on actual distances, reduces the errors that may arise from directly using pixel coordinates for judgment and improves the accuracy of detection.

[0015] In conjunction with some embodiments of the first aspect, in some embodiments, the actual distance function set is: In the function group, D cl D represents the actual distance to the left. cr The actual distance to the right is C, where C is the average pixel coordinate of the center line, and l is l. l The average pixel coordinates of the left line, l r denoted as the average pixel coordinates of the right line, and 'a' as the size of the gap.

[0016] By adopting the above technical solution, the actual distance function group uses the mapping relationship between pixel coordinate differences and the actual size of the notch to convert the pixel distance in image space into the actual distance in physical space. The normalization processing in the function group eliminates the distortion caused by factors such as image shooting angle and distance, making the measurement results have good universality while ensuring measurement accuracy, and providing a reliable quantitative basis for determining the notch state.

[0017] In conjunction with some embodiments of the first aspect, in some embodiments, based on the DeepLabv3+ network, the MobileNetv2 lightweight network is selected as the backbone feature extraction network and a Hybrid Attention Module (CBAM) is added to obtain an improved network, specifically including: A CBAM module is added after the last convolutional layer of the Mobilenetv2 network. The CBAM module includes channel attention mechanism and spatial attention mechanism. The feature maps output by the MobileNetv2 network are processed by global max pooling and global average pooling respectively to obtain feature descriptors; The feature descriptors are input into a shared multilayer perceptron to obtain the weights; The channel attention map is obtained based on the weights and the sigmoid function. Multiplying the channel attention map by the original feature map yields the channel-weighted feature map; Max pooling and average pooling operations are performed on the channel-weighted feature map along the channel dimension to obtain the pooling results; The pooling results are concatenated along the channel dimension, and a spatial attention map is calculated using a convolutional layer and a sigmoid function. By applying channel attention maps and spatial attention maps sequentially to the input features, an improved network is obtained.

[0018] By adopting the above technical solution, a CBAM module is added to the MobileNetv2 network. The combination of channel attention and spatial attention mechanisms enhances the network's ability to extract key features. The channel attention mechanism, through dual-path processing of global max pooling and average pooling, comprehensively captures the statistical information of the feature map. Combined with a multilayer perceptron to learn feature weights, it highlights channel features crucial for gap detection. The spatial attention mechanism extracts spatial dimensionality information through max pooling and average pooling operations, and utilizes convolutional layers to learn the importance of spatial features, strengthening the ability to perceive gap locations. The cascaded structure of these two attention mechanisms makes the feature extraction process more refined and targeted, improving the model's accuracy in identifying gap regions while maintaining the network's lightweight nature. The improved network structure achieves a good balance between feature extraction efficiency and recognition performance, improving the accuracy and robustness of gap detection.

[0019] Secondly, embodiments of this application provide an S700K switch machine gap detection system based on an improved DeepLabv3+. The S700K switch machine gap detection system based on the improved DeepLabv3+ includes: one or more processors and a memory; the memory is coupled to one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and one or more processors call the computer instructions to cause the system to perform the method as described in the first aspect and any possible implementation of the first aspect.

[0020] Thirdly, embodiments of this application provide a computer-readable storage medium including instructions that, when executed on a system, cause the system to perform the method described in the first aspect and any possible implementation thereof.

[0021] Fourthly, embodiments of this application provide a computer program product, characterized in that, when the computer program product is run on a system, it causes the system to execute the method described in any possible implementation of the first aspect.

[0022] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages: 1. This application provides an improved S700K switch machine gap detection method based on DeepLabv3+. By selecting MobileNetv2 as the backbone feature extraction network and adding a CBAM hybrid attention module to the DeepLabv3+ network, the network possesses stronger feature extraction and representation capabilities. The deep separable convolutional structure of MobileNetv2 reduces computational complexity, decreases the number of network parameters, and improves computational speed. The CBAM module, through channel attention and spatial attention mechanisms, can adaptively adjust the weights of each channel and spatial location in the feature map, enhancing the learning ability of key features of the S700K switch machine gap. This improved network structure allows the model to more accurately locate and identify detailed features of the gap region while maintaining low computational overhead, improving detection efficiency and accuracy.

[0023] 2. This application provides a gap detection method for S700K switch machines based on an improved DeepLabv3+. The loss function employs a combination of weighted cross-entropy loss and DiceLoss, addressing the data imbalance problem. The weighted cross-entropy loss function assigns different weight coefficients to different categories, ensuring that categories with fewer samples receive more attention during training, thus preventing overfitting to the majority category. The DiceLoss function measures the overlap between the predicted and actual segmented images, directly optimizing segmentation performance metrics. The combination of these two loss functions considers both pixel-level classification accuracy and overall segmentation performance, improving the model's segmentation precision and generalization ability.

[0024] 3. This application provides a gap detection method for S700K switch machines based on an improved DeepLabv3+. A CBAM module is added to the Mobilenetv2 network, and the combination of channel attention and spatial attention mechanisms enhances the network's ability to extract key features. The channel attention mechanism comprehensively captures statistical information from the feature map through dual-path processing of global max pooling and average pooling, and combines this with a multilayer perceptron to learn feature weights, highlighting channel features crucial for gap identification. The spatial attention mechanism extracts spatial dimensionality information through max pooling and average pooling operations, and utilizes convolutional layers to learn the importance of spatial features, strengthening the ability to perceive gap locations. The cascaded structure of the two attention mechanisms makes the feature extraction process more refined and targeted, improving the model's accuracy in identifying gap regions while maintaining a lightweight network. The improved network structure achieves a good balance between feature extraction efficiency and recognition performance, improving the accuracy and robustness of gap detection. Attached Figure Description

[0025] Figure 1 This is a flowchart illustrating a gap detection method for an S700K switch machine based on an improved deeplabv3+, as described in this application.

[0026] Figure 2 This is a structural diagram of an improved network in an embodiment of this application.

[0027] Figure 3 This is a schematic diagram of the physical device structure of an S700K switch machine gap detection system based on an improved deeplabv3+, provided in an embodiment of this application. Detailed Implementation

[0028] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to any or all possible combinations including one or more of the listed items.

[0029] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

[0030] The following example is used in conjunction with Figure 1 This application describes a notch detection method for an S700K switch machine based on an improved DeepLabv3+ in its embodiments: See also Figure 1 This is a flowchart illustrating a gap detection method for an S700K switch machine based on an improved deeplabv3+ in an embodiment of this application.

[0031] S101. Determine the training set and test set based on the collected images of the S700K switch machine gaps during the process of trains passing through the turnout and the switch machine driving the turnout conversion. In this step, the system first needs to acquire image data of the gaps in the S700K switch machine during the process of a train passing through a turnout and the switch machine driving the turnout to switch. This image data can be acquired in real time by installing high-definition cameras or other image acquisition devices near the railway turnout and switch machine. The acquired image data needs to be preprocessed, such as image cropping, noise reduction, and normalization, to obtain an image dataset suitable for training and testing.

[0032] The system can divide the acquired S700K switch machine gap images into two parts: a training set and a test set, based on actual needs. Typically, a portion of the images can be randomly selected in a ratio of 8:2 as the training set, and the remaining portion as the test set. The training set is used to train the improved DeepLabv3+ network model, enabling it to accurately identify and locate S700K switch machine gaps. The test set is used to verify the performance and generalization ability of the trained model on new data.

[0033] When dividing the training and test sets, the system can also employ cross-validation. This involves dividing the entire dataset into k parts (e.g., 5 or 10), selecting one part as the test set each time, and using the remaining k-1 parts as the training set. This process is repeated k times, and the average of the k results is taken as the final performance metric. This allows for a more comprehensive evaluation of the model's performance and reduces the impact of randomness in data partitioning. Furthermore, the system can group the collected image data based on factors such as different railway lines, climate conditions, and lighting conditions to ensure that the distribution of the training and test sets is as consistent as possible across these factors, thereby improving the model's robustness and practical application capabilities.

[0034] S102. Based on the deeplabv3+ network, the mobilenetv2 lightweight network is selected as the backbone feature extraction network and a hybrid attention module CBAM is added to obtain an improved network; The system is based on the DeepLabv3+ network, using the lightweight MobileNetv2 network as the backbone feature extraction network and incorporating a Hybrid Attention Module (CBAM) to obtain an improved network. Specifically: a CBAM module is added after the last convolutional layer of the MobileNetv2 network, which includes channel attention and spatial attention mechanisms; the feature maps output by the MobileNetv2 network are processed by global max pooling and global average pooling respectively to obtain feature descriptors; the feature descriptors are input into a shared multilayer perceptron to obtain weights; channel attention maps are obtained based on the weights and the sigmoid function; the channel attention maps are multiplied by the original feature maps to obtain channel-weighted feature maps; max pooling and average pooling operations are performed on the channel-weighted feature maps along the channel dimensions to obtain pooling results; the pooling results are concatenated along the channel dimensions and the spatial attention map is calculated through convolutional layers and the sigmoid function; the channel attention maps and spatial attention maps are applied sequentially to the input features to obtain the improved network. The improved network loss function LOSS combines the weighted cross-entropy loss function Cross-EntropyLossWithWeight and the DiceLoss function. The weighted cross-entropy loss function Cross-EntropyLossWithWeight is as follows: In the function, w c y is the weighting coefficient. c p is a one-hot vector c The probability values ​​are calculated using the softmax or sigmoid function after the network predictions are processed; `classes` represents the number of segmentation categories, and `N` represents the total number of pixels. c The number of pixels of category c in GroundTruth; The DiceLoss function is: In the function, X represents the pixel label of the real segmented image, Y represents the pixel category of the predicted segmented image, and a is a non-zero constant; the loss function LOSS is: Loss=CrossEntropyLossWithWeight+λ*DiceLoss In the function, the value of λ is 0.2.

[0035] In this step, the system improves and optimizes the existing deeplabv3+ semantic segmentation network to meet the requirements of the S700K switch machine gap detection task. Specifically, the system selects the lightweight Mobilenetv2 network as the backbone feature extraction network of deeplabv3+, replacing the original more complex feature extraction networks such as Xception or ResNet. This significantly reduces the number of model parameters and computational cost, improves the model's inference speed, and makes it more suitable for deployment and application on embedded or mobile devices.

[0036] Building upon this, the system further incorporates a Hybrid Block Attention Module (CBAM) after the last convolutional layer of the Mobilenetv2 network. The CBAM module, composed of channel attention and spatial attention mechanisms, adaptively adjusts feature weights across different channels and spatial locations, highlighting useful feature information and suppressing irrelevant background noise, thereby improving the discriminative power and robustness of feature representations. By introducing the CBAM module, the improved network can better focus on the key regions and detailed features of the S700K switch machine gap, enhancing the accuracy and reliability of gap detection.

[0037] S103. Train the improved network using the training set and the test set to obtain the improved detection network; After obtaining the improved deeplabv3+ network structure, the system needs to train and optimize the improved network using the training and test sets constructed in step S101 to obtain the final S700k switch machine gap detection model. Specifically, the system inputs the training set images into the improved network, calculates the network output through forward propagation, compares it with the ground truth labels corresponding to the images, and calculates the loss function value. Then, the system calculates the gradient of the loss function with respect to the network parameters through the backpropagation algorithm, and updates the network parameters using optimization algorithms (such as Adam or SGD) to gradually reduce the loss function value and gradually improve the network's detection performance.

[0038] During training, the system can employ common training techniques and strategies, such as learning rate decay, weight decay, and random data augmentation, to accelerate model convergence, improve generalization ability, and prevent overfitting. Simultaneously, the system needs to appropriately set training hyperparameters, such as batch size, number of iterations, and initial learning rate, to achieve optimal training results.

[0039] After training, the system evaluates the trained improved network using a test set, calculating some commonly used performance metrics, such as pixel accuracy (PA) and mean intersection-over-union (MIoU). By analyzing these metrics, the actual performance of the improved network on the S700K switch machine gap detection task can be comprehensively evaluated, providing a reference for subsequent optimization and application. If the performance on the test set is not ideal, the system can further adjust the network structure or training strategy, iteratively optimizing until an improved detection network that meets the requirements is obtained.

[0040] S104. Input the notch image into the improved detection network to obtain the detection result; After obtaining the trained improved detection network, the system can input the image of the S700K switch machine gap to be detected into the network. After forward propagation calculation, the detection result of the gap region is obtained. Specifically, the input image first passes through multiple convolutional and pooling layers of the backbone feature extraction network Mobilenetv2 to extract feature maps of different scales and abstraction levels. Then, these feature maps are modulated by the introduced CBAM attention module to highlight the salient features of the gap region and suppress the interference information of the background region. Next, the modulated feature maps are input into the pyramid pooling module and decoder module of DeepLabv3+ for multi-scale feature fusion and upsampling, finally obtaining a pixel-level segmentation result of the same size as the input image, where each pixel is assigned a category label (such as "background", "left edge of gap", and "right edge of gap").

[0041] To improve the stability and robustness of the detection results, the system can employ a multiple prediction strategy. This involves inputting the same input image through multiple random data augmentations before feeding it into the network for prediction, and then integrating the multiple predictions, such as through voting or averaging, to obtain the final detection result. Furthermore, the system can utilize model ensemble methods to combine multiple detection models with different structures or training strategies to predict the same input image, and then fuse the predictions from multiple models to further improve detection performance.

[0042] S105. Calculate the average pixel coordinate value of the center line of the center line of the intermediate positioning block based on the mask value in the detection result. After obtaining the detection results for the gap area of ​​the S700K switch machine, the system needs to further analyze and calculate the coordinate values ​​of some key locations, such as the centerline position of the intermediate positioning block. Specifically, the detection results are usually given in the form of a mask, which is a binary image of the same size as the input image, where pixels belonging to the gap area have a value of 1, and pixels belonging to the background area have a value of 0. The system can perform morphological processing on the mask image, such as dilation, erosion, and connected component analysis, to extract the region of the intermediate positioning block.

[0043] Then, the system analyzes the mask values ​​of the central positioning block area and calculates the average pixel coordinates of its midline (i.e., the line connecting the midpoints of the left and right edges). Specifically, the following steps can be used: First, for each row of pixels in the central positioning block area, find the leftmost and rightmost pixel positions with a mask value of 1, and calculate their midpoint positions; then, average the midpoint positions of all rows to obtain the average pixel coordinates of the midline.

[0044] It's important to note that in actual images, due to factors such as shooting angle and lighting conditions, the mask values ​​of the central positioning block region may contain noise or be missing. To improve the robustness of the centerline position calculation, the system can employ preprocessing or post-processing techniques, such as median filtering and morphological filtering, to remove isolated noise points and fill in small missing areas. Furthermore, the system can utilize algorithms such as curve fitting and line detection to further optimize and correct the centerline position, resulting in a more accurate and smoother centerline trajectory.

[0045] S106. Calculate the average pixel coordinates of the left line of the left line of the gap based on the detection results; calculate the average pixel coordinates of the right line of the right line of the gap based on the detection results. Similar to calculating the centerline position of the intermediate positioning block, the system also needs to calculate the average pixel coordinates of the left and right edges of the notch based on the detection results. Specifically, for the left edge of the notch, the system analyzes the mask image of the detection results, finds the leftmost pixel position with a mask value of 1 in each row, and then averages the leftmost positions of all rows to obtain the average pixel coordinates of the left edge. Similarly, for the right edge of the notch, the system finds the rightmost pixel position with a mask value of 1 in each row, and averages the rightmost positions of all rows to obtain the average pixel coordinates of the right edge.

[0046] In practical calculations, the system can employ the same preprocessing and post-processing techniques as the centerline position calculation, such as morphological filtering and curve fitting, to improve the robustness and accuracy of the left and right edge position calculations. Furthermore, since the notch edges may have some tilt or curvature, the system can also use algorithms such as Hough transform to perform straight-line or curve fitting on the edge positions to obtain more accurate and smoother edge trajectories.

[0047] S107. Input the average pixel coordinates of the center line, the average pixel coordinates of the left line, and the average pixel coordinates of the right line into the actual distance function group to calculate the left actual distance from the center line of the middle positioning block to the left line of the gap and the right actual distance from the center line of the middle positioning block to the right line of the gap. The system inputs the average pixel coordinates of the center line, the left line, and the right line into the actual distance function set for calculation, obtaining the left actual distance from the center line of the middle positioning block to the left line of the gap and the right actual distance from the center line of the middle positioning block to the right line of the gap. The actual distance function set is as follows: In the function group, D cl D represents the actual distance to the left. cr The actual distance to the right is C, where C is the average pixel coordinate of the center line, and l is l. l The average pixel coordinates of the left line, l r denoted as the average pixel coordinates of the right line, and 'a' as the size of the gap.

[0048] After obtaining the average pixel coordinates of the centerline of the intermediate positioning block and the left and right edges of the gap, the system needs to further convert these pixel coordinates into actual physical distance values ​​for subsequent gap status judgment and analysis. Specifically, the system pre-designs a set of actual distance functions to map pixel coordinate values ​​to corresponding actual distance values. The system substitutes the calculated average pixel coordinates of the centerline, left line, and right line into the above function set to obtain the actual distance values ​​from the centerline of the intermediate positioning block to the left and right edges of the gap. These actual distance values ​​reflect the actual positional relationship of the gap relative to the intermediate positioning block and are an important basis for subsequent gap status judgment.

[0049] S108. When either the left actual distance or the right actual distance is within the preset range, the gap of the S700K switch machine is determined to be normal. After obtaining the actual distance values ​​from the centerline of the intermediate positioning block to the left and right edges of the notch, the system needs to judge and output the state of the notch according to preset judgment rules. Specifically, the system presets an actual distance range for a normal notch, for example, [d min ,d max If the calculated actual left distance D cl Or the actual distance to the right, D cr If at least one of the gaps falls within this range, the current gap status is determined to be normal.

[0050] S109. When both the actual left distance and the actual right distance are outside the preset range, the gap of the s700K switch machine is determined to be abnormal.

[0051] Similar to the previous step, if D cl and D crIf all values ​​exceed this range, the current gap status is determined to be abnormal. It's important to note that in practical applications, the normal distance range for gaps may change with time, environment, and other factors. Therefore, the system also needs to be designed with an adaptive adjustment mechanism to dynamically update and optimize the normal distance range based on feedback from actual detection results. For example, the system can record the actual distance values ​​of all gap samples determined to be normal over a period of time, and automatically adjust the upper and lower limits of the normal distance range using statistical analysis methods such as normal distribution fitting and percentile estimation to adapt to the influence of factors such as gap wear and environmental changes.

[0052] In addition, when outputting the gap status judgment results, the system can also provide some auxiliary information, such as the deviation of the actual gap distance from the normal range and the prediction of gap wear trend, so that maintenance personnel can conduct further analysis and processing. For gaps judged to be abnormal, the system can also automatically generate alarm information to notify relevant personnel to conduct on-site inspection and repair in a timely manner to ensure the safety and reliability of railway operation.

[0053] In the above embodiments, by selecting MobileNetv2 as the backbone feature extraction network in the DeepLabv3+ network and adding the CBAM hybrid attention module, the network possesses stronger feature extraction and representation capabilities. MobileNetv2's depthwise separable convolutional structure reduces computational complexity, decreases the number of network parameters, and improves computational speed. The CBAM module, through channel attention and spatial attention mechanisms, can adaptively adjust the weights of each channel and spatial location in the feature map, enhancing its ability to learn key features of the S700K switch machine gap. This improved network structure allows the model to more accurately locate and identify detailed features of the gap region while maintaining low computational overhead, improving detection efficiency and the accuracy of detection results.

[0054] In another embodiment, after step S103 and before step S104, the method further includes: establishing evaluation criteria, which include accuracy, average intersection-over-union ratio, average pixel accuracy, and recall. Evaluate and improve the testing network according to the evaluation criteria; If the improved detection network is determined to meet the evaluation criteria, proceed with the step of inputting the notch image into the improved detection network.

[0055] The evaluation criteria, including accuracy, mean intersection-over-union ratio, mean pixel accuracy, and recall, are expressed using the following functional expressions: In the function, Accuracy is the function corresponding to accuracy, Recall is the function corresponding to average intersection-union ratio, MAP is the function corresponding to average pixel accuracy, and MIoU is the function corresponding to recall. TP represents true positives, TN represents true negatives, FP represents false positives, FN represents false negatives, and k represents the number of classes.

[0056] In this embodiment, after training the improved detection network, the system adds a step to evaluate its performance to ensure that the trained network meets the needs of practical applications. Specifically, the system pre-establishes a set of evaluation criteria, including commonly used performance metrics such as accuracy, mean intersection-over-union ratio (MIR), mean pixel accuracy (MPI), and recall. Then, the system performs a comprehensive performance evaluation of the improved detection network based on these criteria, calculating the specific values ​​for each metric. Only when the performance of the improved detection network meets the evaluation criteria will the system apply it to subsequent notch image detection steps.

[0057] In this embodiment, the system employs four specific performance evaluation metrics and provides their corresponding functional definitions. Accuracy measures the proportion of correctly classified samples out of the total number of samples, reflecting the network's overall classification accuracy. Recall measures the proportion of correctly detected positive samples out of the total number of actual positive samples, reflecting the network's ability to detect positive samples. Average Pixel Accuracy (MAP) and Average Intersection over Union (MIoU) are commonly used evaluation metrics for pixel-level segmentation tasks, measuring the average classification accuracy and average MIoU for each pixel category, respectively, reflecting the network's segmentation precision at the pixel level. By calculating the specific values ​​of these four metrics and comparing them with preset evaluation criteria, the system can comprehensively evaluate the performance of the improved detection network, providing a reliable basis for subsequent applications.

[0058] In the above embodiments, accuracy reflects the overall correctness of the model's classification, mean intersection-over-union ratio measures the overlap between the predicted and real regions, mean pixel accuracy evaluates pixel-level classification accuracy, and recall characterizes the model's ability to detect real defects. Multiple evaluation metrics quantify network performance from different perspectives, improving the model's performance level before practical application.

[0059] The following is combined Figure 2 The structural diagram of the improved network in the embodiments of this application is described below. Please refer to [link / reference]. Figure 2 This is a structural diagram of an improved network provided in an embodiment of this application.

[0060] Improving the network structure can be divided into the following key parts: Input layer: Image data is first fed into the network. The input image is typically an RGB three-channel color image, and the resolution can be set according to actual needs.

[0061] Backbone Feature Extraction Network: The input image first passes through a backbone feature extraction network, represented as MobileNetV2 in the diagram. This network employs the lightweight MobileNetV2 architecture, using designs such as depthwise separable convolutions to reduce the number of network parameters while maintaining high feature extraction capabilities. The output of the backbone network is a series of feature maps at different scales and semantic levels.

[0062] CBAM Attention Module: An improved network introduces the CBAM (Convolutional Block Attention Module) attention module onto the output feature map of the backbone network. The CBAM module consists of channel attention and spatial attention mechanisms, which can adaptively adjust the feature weights for different channels and spatial locations, highlighting task-relevant salient features.

[0063] Multi-scale feature fusion: The improved network adopts a multi-scale feature fusion strategy similar to deeplabv3+. Specifically, feature maps from different layers of the backbone network first undergo a series of convolutions and upsampling operations to align their scale and number of channels. Then, these aligned feature maps are fused through element-wise addition to obtain a feature representation that integrates information from different scales.

[0064] Decoder Module: The fused multi-scale feature maps are then input into the decoder module, represented as the Decoder in the diagram. The decoder module progressively restores the spatial resolution of the feature maps through cascaded upsampling and convolutional operations until it matches the resolution of the input image. After each upsampling layer, the decoder module also introduces an additional convolutional layer and a batch normalization layer to further enhance the representational power of the features.

[0065] Output layer: The output feature map of the decoder module is finally passed through a convolutional layer and a softmax activation function to obtain pixel-level segmentation results. The output segmentation map has the same resolution as the input image, and each pixel is assigned a category label indicating whether the pixel belongs to the gap region or the background region.

[0066] Loss Function: The improved network employs a weighted combination of cross-entropy loss and Dice loss. Cross-entropy loss focuses on pixel-level classification accuracy, while Dice loss focuses on region-level overlap. By optimizing these two loss functions, the improved network can simultaneously achieve good segmentation performance at both the pixel and region levels.

[0067] The system in the embodiments of this invention is described below from the perspective of hardware processing. Please refer to [link / reference needed]. Figure 3 This is a schematic diagram of the physical device structure of an S700K switch machine gap detection system based on an improved deeplabv3+, provided in an embodiment of this application.

[0068] It should be noted that, Figure 3 The structure of the system shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.

[0069] like Figure 3 As shown, the system includes a Central Processing Unit (CPU) 301, which can perform various appropriate actions and processes, such as executing the methods described in the above embodiments, based on a program stored in Read-Only Memory (ROM) 302 or a program loaded from storage portion 308 into Random Access Memory (RAM) 303. The RAM 303 also stores various programs and data required for system operation. The CPU 301, ROM 302, and RAM 303 are interconnected via a bus 304. An Input / Output (I / O) interface 305 is also connected to the bus 304.

[0070] The following components are connected to I / O interface 305: input section 306 including a camera, infrared sensor, etc.; output section 307 including a liquid crystal display (LCD) and speakers, etc.; storage section 308 including a hard disk, etc.; and communication section 309 including a network interface card such as a LAN (Local Area Network) card and a modem, etc. Communication section 309 performs communication processing via a network such as the Internet. Drive 310 is also connected to I / O interface 305 as needed. Removable media 311, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 310 as needed so that computer programs read from them can be installed into storage section 308 as needed.

[0071] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing computer programs for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 309, and / or installed from removable medium 311. When the computer program is executed by central processing unit (CPU) 301, it performs the various functions defined in the present invention.

[0072] It should be noted that the computer-readable medium shown in the embodiments of the present invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. The transmitted data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof.

[0073] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0074] In another aspect, the present invention also provides a computer-readable storage medium, which may be included in the system described in the above embodiments; or it may exist independently and not assembled into the system. The storage medium carries one or more computer programs that, when executed by a processor of a system, cause the system to implement the methods provided in the above embodiments.

[0075] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

[0076] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".

[0077] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.

[0078] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A s700K switch gap detection method based on improved deeplabv3+, characterized in that: include: The training set and the test set are determined based on the collected S700k switch gap images of the train passing through the switch and the switch machine driving the switch conversion process; Based on the deeplabv3+ network, the mobilenetv2 lightweight network is selected as the backbone feature extraction network and the hybrid attention module CBAM is added to obtain an improved network; Training the improved network with the training set and the test set to obtain an improved detection network; The gap image is input into the improved detection network to obtain a detection result.

2. The method according to claim 1, characterized in that The loss function LOSS of the improved network adopts a combination of a weighted cross entropy loss function Cross-EntropyLossWithWeight and a DiceLoss function. The weighted cross entropy loss function Cross-EntropyLossWithWeight is: In the function, the w c is the weight coefficient, the y c is a one-hot vector, the p c is the probability value of the network prediction value after being calculated by the softmax function or the sigmoid function; classes is the number of segmentation categories, N is the total number of pixels, and N c is the number of pixels with GroundTruth category c; The DiceLoss function is: In the function, X is the pixel label of the real segmented image, Y is the pixel category of the predicted segmented image, and a is a constant that is not 0; The loss function LOSS is: Loss=CrossEntropyLossWithWeight+λ*DiceLoss In the function, the λ value is 0.

2.

3. The method according to claim 1, characterized in that After training the improved network with the training set and the test set to obtain an improved detection network, the method further includes: Establishing evaluation criteria, wherein the evaluation criteria include accuracy, average intersection-over-union ratio, average pixel accuracy and recall rate; Evaluate the improved detection network according to the evaluation criteria; In the case where it is determined that the improved detection network meets the evaluation criteria, the step of inputting the notch image into the improved detection network is continued.

4. The method according to claim 1, characterized in that: The function formula corresponding to the accuracy rate, the average intersection-over-union ratio, the average pixel accuracy rate and the recall rate in the evaluation standard is: In the function, Accuracy is the function formula corresponding to the accuracy rate, Recall is the function formula corresponding to the average intersection-over-union ratio, MAP is the function formula corresponding to the average pixel accuracy rate, and MIoU is the function formula corresponding to the recall rate; The TP is a true positive example, the TN is a true negative example, the FP is a false positive example, the FN is a false negative example, and k is the number of categories.

5. The method according to claim 1, characterized in that: After inputting the gap image into the improved detection network to obtain the detection result, the method further includes: Calculating the midline average pixel coordinate value of the midline of the middle positioning block according to the mask value in the detection result; Calculate the left line average pixel coordinate value of the left line of the gap according to the detection result; Calculate the average pixel coordinate value of the right line of the gap according to the detection result; Input the average pixel coordinate value of the center line, the average pixel coordinate value of the left line and the average pixel coordinate value of the right line into the actual distance function group to calculate, and obtain the left actual distance from the center line of the middle positioning block to the left line of the gap and the right actual distance from the center line of the middle positioning block to the right line of the gap; When either the left actual distance or the right actual distance is within the preset range, it is determined that the gap of the s700K switch machine is normal; when both the left actual distance and the right actual distance are not within the preset range, it is determined that the gap of the s700K switch machine is abnormal.

6. The method according to claim 5, characterized in that The actual distance function group is: In the function group, the D cl is the actual distance to the left, and D cr is the actual right distance, C is the average pixel coordinate value of the center line, and l l is the average pixel coordinate value of the left line, and the l r is the average pixel coordinate value of the right line, and a is the gap size.

7. The method according to claim 1, characterized in that The deeplabv3+ network-based mobilenetv2 lightweight network is selected as the backbone feature extraction network and a hybrid attention module CBAM is added to obtain an improved network, specifically including: adding a CBAM module after the last convolutional layer of the mobilenetv2 network, and the CBAM module includes a channel attention mechanism and a spatial attention mechanism; The feature map output by the mobilenetv2 network is processed by global maximum pooling and global average pooling to obtain a feature descriptor; Inputting the feature descriptor into a shared multi-layer perceptron to obtain a weight; Obtain a channel attention map according to the weights and the sigmoid function; Multiplying the channel attention map with the original feature map to obtain a channel weighted feature map; Performing maximum pooling and average pooling operations on the channel weighted feature map along the channel dimension to obtain a pooling result; The pooling results are concatenated in the channel dimension, and a spatial attention map is obtained by calculating the convolution layer and the sigmoid function; The channel attention map and the spatial attention map are sequentially applied to input features to obtain an improved network.

8. A s700K switch gap detection system based on improved deeplabv3+, characterized in that: The system comprises: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors call the computer instructions so that the system executes the method as described in any one of claims 1-7.

9. A computer-readable storage medium comprising instructions, characterized in that: When the instructions are executed on a system, the system is caused to execute the method according to any one of claims 1 to 7.

10. A computer program product, characterized in that When the computer program product is run on a system, the system is caused to execute the method according to any one of claims 1 to 7.