A real-time detection method and system for key components of railway freight vehicles based on a transformer
By using a lightweight dynamic hybrid convolutional network and a polarized self-attention mechanism for multi-scale feature fusion, combined with the Inner-Shape-IoU loss function, the problems of low efficiency and low accuracy in the detection of key components of railway freight vehicles are solved, achieving real-time accurate detection and high robustness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- EAST CHINA UNIV OF TECH
- Filing Date
- 2026-04-23
- Publication Date
- 2026-06-23
AI Technical Summary
Existing methods for detecting key components of railway freight vehicles suffer from low detection efficiency and low accuracy. They are also unable to capture the edge texture details of small-scale targets in complex backgrounds, and there are problems of semantic incompatibility and positioning deviation when fusing multi-scale features.
We employ a lightweight dynamic hybrid convolutional network and a polarization self-attention mechanism for multi-scale feature fusion. Combined with the Inner-Shape-IoU loss function, we extract multi-scale features through dynamic hybrid convolutional layers, enhance the edge texture information of small-scale components through the polarization self-attention mechanism, and optimize the bounding box localization through the Inner-Shape-IoU loss function.
It enables real-time and accurate detection of key components of railway freight vehicles, reduces computational complexity, improves the robustness and positioning accuracy of the model, and meets the needs of dynamic online detection of railway freight vehicles.
Smart Images

Figure CN122265264A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and deep learning technology, and more specifically to a method and system for real-time detection of key components of railway freight vehicles based on Transformer. Background Technology
[0002] Anomalies in critical components of railway freight cars are a common train safety hazard. The loss or damage of critical components often compromises the overall structure of the vehicle, increasing the risk of major accidents such as derailments. With the development of computer vision technology, image-based target detection has become the most widely used intelligent inspection method in railway freight yards. In practical engineering, accurately defining the boundaries of critical components of freight cars (such as sides, door locks, and locking pins) is crucial for fault diagnosis and safety early warning. Currently, this work is mainly done manually by experienced inspectors through dynamic image reading, which is not only time-consuming and labor-intensive, but the inspection results also depend on the inspector's experience and fatigue level.
[0003] Traditional methods for detecting freight vehicle components, including manual feature extraction or template matching, are inefficient, time-consuming, and labor-intensive, resulting in low detection accuracy and failing to meet the needs of complex freight yard environments. Deep learning-based methods have shown greater advantages over classical methods in visual object detection. Multilayer convolutional neural networks and their variants have been proposed to extract multi-scale features at different resolutions by stacking standard convolutions or cross-stage local networks, but they often struggle to capture global contextual information. Transformer-based networks (such as RT-DETR) have shown great potential in capturing global contextual information. However, due to the redundancy of parameters and high computational requirements in their backbone networks, conventional self-attention mechanisms (such as AIFI) and conventional feature pyramids have been explored as fundamental modules for multi-scale feature interaction. Existing techniques have demonstrated that these mainstream architectures can compute the correlation between feature sequences through multi-head self-attention and achieve top-down and bottom-up concatenation and communication between shallow spatial features and deep semantic features through path aggregation networks. Conventional intersection-union ratios (such as GIoU or CIoU) are commonly used during the training phase to compute bounding box localization losses. However, these mainstream models neglect the fine edge texture details of small-scale targets in complex backgrounds, and suffer from semantic incompatibility and biases in the localization of complex-shaped components when fusing multi-scale features. Therefore, there is an urgent need to develop an automatic and accurate method for detecting key components in railway freight vehicle images. Summary of the Invention
[0004] The purpose of this invention is to provide a real-time detection method and system for key components of railway freight vehicles based on Transformer. Through multi-scale feature fusion of lightweight dynamic hybrid convolution and polarized self-attention mechanism and Inner-Shape-IoU loss optimization, the real-time accurate detection of key components of railway freight vehicles is achieved.
[0005] To achieve the above objectives, the present invention provides the following technical solution: A real-time detection method for key components of railway freight vehicles based on Transformer includes the following steps: S1. Obtain the original images of the key components of the railway freight vehicle to be inspected and perform preprocessing; S2. Input the preprocessed original images of key components of railway freight vehicles into the improved Transformer backbone network. The preprocessed original images of key components of railway freight vehicles are extracted through the introduced lightweight dynamic hybrid convolutional network to obtain multi-scale feature maps. The multi-scale feature maps include shallow, medium and deep multi-scale features. S3. Through dual-branch parallel processing of the polarization self-attention mechanism, the edge texture information of small-scale components in the deep multi-scale feature map is extracted and enhanced to obtain the enhanced feature map. S4. The enhanced feature map is used as the first branch input, and the shallow multi-scale features and the mid-scale features are used as the second branch input. The first branch input and the second branch input are spliced and fused to obtain the fused feature map. S5. Introduce the Inner-Shape-IoU loss function to calculate the localization loss of the bounding box of the fused feature map, so as to realize the detection of key components of railway freight vehicles.
[0006] Furthermore, in S1, the preprocessing process includes: data size adjustment, data augmentation, and dataset splitting.
[0007] Further, in step S2, feature extraction is performed on the preprocessed original image of the key components of the railway freight vehicle, specifically as follows: The original images of key components of railway freight vehicles are downsampled and multi-scale features are extracted by using dynamic hybrid convolutional layers. Parameter redundancy is reduced by dynamic weight adjustment, and multi-scale feature maps are output.
[0008] Furthermore, in S3, the dual-branch parallel processing of the polarization self-attention mechanism is specifically as follows: The deep multi-scale feature map is mapped into query, key, and value feature matrices and then overlaid with positional encoding. In the two parallel branches, feature association is enhanced by convolutional dimensionality reduction, softmax normalization, and matrix multiplication, respectively. Enhanced feature maps are output through residual connections, multilayer perceptrons, and layer normalization layers.
[0009] Furthermore, in step S4, the process of generating the fused feature map is specifically as follows: The enhanced feature map is used as the input of one branch, and the multi-scale features of the shallow and mid-level layers of the backbone network are used as the input of another branch. Through a specific upsampling and concatenation mechanism, the deep high semantic features and the shallow high resolution features are progressively coordinated and fused to obtain the fused feature map.
[0010] Furthermore, in S5, the process of inspecting key components of railway freight vehicles specifically includes: The Inner-Shape-IoU loss function is introduced to optimize the matching degree evaluation in the bounding box regression process by combining the geometric features of the target shape and the auxiliary bounding box penalty term, so as to improve the localization accuracy of key components with complex shapes and partial occlusion.
[0011] Furthermore, in S5, before calculating the bounding box localization loss, the AdamW optimizer is used to train and optimize the network, wherein the learning rate is set to 0.001, the weight decay is set to 0.0001, the batch size is set to 16, and the number of training epochs is set to 300.
[0012] The present invention also provides a system for performing a Transformer-based real-time detection method for key components of railway freight vehicles, comprising: The data acquisition and processing module is used to acquire raw images of key components of the railway freight vehicle to be inspected and to perform preprocessing. The LDIM backbone module is used to input the preprocessed original images of key components of railway freight vehicles into the improved Transformer backbone network. The introduced lightweight dynamic hybrid convolutional network extracts features from the preprocessed original images of key components of railway freight vehicles to obtain multi-scale feature maps. The multi-scale feature maps include shallow, medium and deep multi-scale features. The PSM-DyT attention encoding module is used to extract and enhance the edge texture information of small-scale components in the deep multi-scale feature map through dual-branch parallel processing of the polarization self-attention mechanism, so as to obtain the enhanced feature map. The Pyramid-IEL feature fusion module is used to take the enhanced feature map as the first branch input, take the shallow multi-scale features and the mid-scale features as the second branch input, and concatenate and fuse the first branch input and the second branch input to obtain the fused feature map. The detection output module is used to introduce the Inner-Shape-IoU loss function to calculate the localization loss of the bounding box of the fused feature map, so as to realize the detection of key components of railway freight vehicles.
[0013] The present invention also provides an electronic device comprising a processor and a memory, wherein the processor is used to execute a computer program stored in the memory to implement a Transformer-based real-time detection method for key components of railway freight vehicles.
[0014] The present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements a Transformer-based real-time detection method for key components of railway freight vehicles.
[0015] According to specific embodiments provided by the present invention, the present invention has the following technical effects compared to the prior art: The introduction of a lightweight dynamic hybrid convolutional network in this invention significantly reduces computational complexity and ensures real-time model inference while comprehensively extracting multi-scale features containing rich contextual information. Addressing the pain points of small-scale railway components being easily affected by background interference and features being easily lost during downsampling, the dual-branch parallel processing of the polarized self-attention mechanism accurately focuses on and significantly enhances the edge and texture details of small targets in deep features, greatly improving the model's feature representation and sensitivity to minute components. The enhanced deep high-semantic features are fused with shallow and mid-level high-resolution spatial features across layers, effectively compensating for the lack of spatial localization information caused by deep networks, achieving complementary advantages of global semantic understanding and precise local localization. The introduction of the Inner-Shape-IoU loss function specifically optimizes the regression process of the fused feature bounding box, significantly improving the localization accuracy of components with varying shapes. Overall, it achieves an optimal balance between lightweight deployment and high robustness and accuracy, effectively meeting the stringent engineering requirements of dynamic online detection of railway freight vehicles. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0017] The following description, in conjunction with the accompanying drawings, further illustrates the real-time detection method and system for key components of railway freight vehicles based on Transformer. Figure 1This is a schematic diagram of the overall process of the real-time detection method for key components of railway freight vehicles based on Transformer in Embodiment 1 of the present invention; Figure 2 This is a heatmap comparison of the final effects of the method proposed in Embodiment 1 of this invention with other methods; Figure 3 This is a schematic diagram of the overall structure of the DAF-DETR target detection network in Embodiment 1 of the present invention; Figure 4 This is a schematic diagram of the LDIM backbone feature extraction module in Embodiment 2 of the present invention; Figure 5 This is a schematic diagram of the specific structure of the PSM-DyT attention encoding module in Embodiment 2 of the present invention. Detailed Implementation
[0018] The specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and are not intended to limit the scope of the invention.
[0019] To better understand the purpose, structure, and function of this invention, the invention will be described in further detail below with reference to the accompanying drawings.
[0020] Example 1 like Figure 1 As shown, this invention provides a real-time detection method for key components of railway freight vehicles based on Transformer, including the following steps: S1. Obtain the original image of the railway freight vehicle to be detected and perform preprocessing; In S1, the preprocessing process includes: data resizing, data augmentation, and dataset splitting to obtain the datasets required for training and testing.
[0021] S2. Input the preprocessed original images of key components of railway freight vehicles into the improved Transformer backbone network. The preprocessed original images of key components of railway freight vehicles are extracted through the introduced lightweight dynamic hybrid convolutional network to obtain multi-scale feature maps. The multi-scale feature maps include shallow, medium and deep multi-scale features. In step S2, the process of feature extraction from the preprocessed original image of the railway freight vehicle is as follows: The preprocessed original images of railway freight vehicles are downsampled and multi-scale features are extracted by using dynamic hybrid convolutional layers. Parameter redundancy is reduced by dynamic weight adjustment, and the output is a multi-scale feature map that includes both shallow spatial information and deep semantic information.
[0022] S3. Through dual-branch parallel processing of the polarization self-attention mechanism, the edge texture information of small-scale components in the deep multi-scale feature map is extracted and enhanced to obtain the enhanced feature map. In S3, the dual-branch parallel processing of the polarization self-attention mechanism specifically involves mapping the deep multi-scale feature map into query, key, and value feature matrices and superimposing positional encoding. In the two parallel branches, feature association is enhanced by convolutional dimensionality reduction, softmax normalization, and matrix multiplication, respectively. Enhanced feature maps are output through residual connections, multilayer perceptrons, and layer normalization layers.
[0023] In step S3, the process of generating the enhanced feature map is as follows: The features output by the polarization self-attention mechanism are used as input to one branch, and the multi-scale features of the shallow and mid-level layers of the backbone network are used as input to another branch. Through a specific upsampling and concatenation mechanism, the deep high-semantic features and the shallow high-resolution features are progressively coordinated and fused to obtain a fused feature map.
[0024] S4. The enhanced feature map is used as the first branch input, and the multi-scale features of the shallow and middle layers are used as the second branch input. The first branch input and the second branch input are spliced and fused to obtain the fused feature map. Specifically, in this embodiment, the input image is a two-dimensional image of a railway freight vehicle in a real-world scene, with 3 channels (RGB image), and H and W scaled uniformly to 640. The image first enters the LDIM backbone feature extraction network to extract multi-scale feature maps of different sizes; then, it addresses the problem of insufficient fine-grained feature extraction of small-scale components in complex backgrounds; next, the extracted features are fed into the Pyramid-IEL feature fusion network for progressive coordinated fusion; finally, the high-quality fused features are sent to the prediction output for feature decoding.
[0025] S5. Introduce the Inner-Shape-IoU loss function to calculate the localization loss of the bounding box of the fused feature map, and complete the accurate detection of key components of railway freight vehicles.
[0026] In S5, the process of accurately detecting key components of railway freight vehicles specifically includes: The Inner-Shape-IoU loss function optimizes the matching evaluation during the bounding box regression process by combining the geometric features of the target shape with an auxiliary bounding box penalty term, thereby improving the localization accuracy of key components with complex shapes and partial occlusion.
[0027] The input features are first processed through a dynamically hybrid convolutional layer for adaptive feature extraction, and parameter redundancy is reduced through dynamic weight adjustment. This module effectively captures spatial information at different scales and outputs the extracted features as shallow, medium, and deep features (such as C3, C4, and C5), which achieves both lightweight model structure and preservation of rich multi-scale semantic information.
[0028] In the feature fusion and prediction output stages, top-down and bottom-up approaches are used for feature transfer and interaction, effectively mitigating the incompatibility and semantic gap between cross-scale features and enhancing model robustness. The fused features are then fed into the prediction output, where a regression branch gradually restores the features to the target location boundaries in the actual image. Simultaneously, an innovative Inner-Shape-IoU loss function is introduced during model training to optimize localization accuracy across different shapes and occluded targets, significantly improving false positives and false negatives for complex shapes such as sides, door locks, and latches.
[0029] like Figure 2 The image shows a heatmap comparison of the final effects of the proposed method with other methods. The feature activation heatmap clearly shows that existing benchmark models, in complex railway freight yard backgrounds, are prone to attention distraction and weak response to small-scale targets (such as locking pins and manhole covers). In contrast, the detection model proposed in this invention, with its high-response area (highlighted in red), can more accurately and densely cover the true boundaries and core textures of key target components. The comparative results further demonstrate that the method of this invention has significant advantages in resisting background interference, locating complex-shaped targets, and capturing fine-grained features of small targets.
[0030] This embodiment also includes the construction of training data and validation data, specifically as follows: (a) First, scale the original data of the image to be detected to 640×640 and use a data processing tool to convert the original data into a standard format.
[0031] (b) A self-built freight vehicle dataset consisting of multiple vehicle types was selected based on real-world shooting scenarios. Within this dataset, the number of training and testing sets were defined for network training and detection. During training and prediction, five commonly used quantitative metrics (precision, recall, mAP@50, mAP@50:95, and FPS) were used to verify the performance.
[0032] (c) The preprocessing and training processes of this invention are performed on an improved Transformer framework. The AdamW optimizer is used to optimize the training network with a learning rate of 0.001 and a weight decay of 0.0001. During training, the batch size and epochs are set to 16 and 300, respectively. Simultaneously, the training data and validation data are randomly divided in an 8:2 ratio during training.
[0033] Example 2 The present invention also provides a system for performing a Transformer-based real-time detection method for key components of railway freight vehicles, comprising: The data processing module is used to acquire the original images of the railway freight vehicles to be inspected and to perform preprocessing. The LDIM backbone module is used to downsample and extract multi-scale features from the preprocessed original images of railway freight vehicles through an introduced lightweight dynamic hybrid convolutional network to obtain multi-scale feature maps; wherein the multi-scale feature maps include: shallow, medium and deep multi-scale features; In this embodiment, the two-dimensional image data is extracted into 640×640 slices and input into the backbone encoder of the network for downsampling. Each downsampling block introduces a lightweight dynamic hybrid convolutional network (LDIM) to replace part of the traditional backbone structure for more efficient network training. This process performs preliminary multi-scale feature extraction on the input image, and the extracted features are then passed to the subsequent attention module and feature fusion module for feature fusion.
[0034] Step Six: In the main module of this invention, the input image ultimately outputs a deep, high-semantic multi-scale feature map, which is then fed into the PSM-DyT attention encoding module. The LDIM module first performs lightweight extraction of multi-scale features while maintaining a large receptive field, and the PSM-DyT module extracts precise edge texture information of small-scale components through a polarization self-attention mechanism.
[0035] The PSM-DyT attention encoding module is used to extract and enhance the edge texture information of small-scale components in the deep multi-scale feature map through dual-branch parallel processing of the polarization self-attention mechanism, so as to obtain the enhanced feature map. In this embodiment, the PSM-DyT attention encoding module uses a polarization self-attention mechanism to capture fine-grained features, instead of the conventional AIFI self-attention mechanism. Furthermore, features are passed through parallel processing via two branches. Compared to standard self-attention techniques, the polarization mechanism in PSM-DyT can obtain more effective edge texture information and significantly enhances the expressive power of small-scale parts under complex background interference.
[0036] In the PSM-DyT attention encoding module, the feature map is first mapped to query, key, and value feature matrices and then positional encodings are superimposed. These matrices are then fed into two parallel branches of the polarization self-attention unit to perform feature extraction. During this process, convolutional dimensionality reduction, softmax normalization, and matrix multiplication enhance the correlation of features. The enhanced feature map is then obtained through residual connections, a multilayer perceptron, and a layer normalization layer. Once the feature map has completed the polarization self-attention operation, the enhanced feature map is used as input to the Pyramid-IEL feature fusion stage.
[0037] The Pyramid-IEL feature fusion module is used to take the enhanced feature map as the first branch input, take the multi-scale features of the shallow and middle layers as the second branch input, and concatenate and fuse the first branch input and the second branch input to obtain the fused feature map. In this embodiment, the fusion method in the Pyramid-IEL feature fusion module is different from the RepC3 structure fusion method in the benchmark model. This method coordinates deep high semantic features and shallow high resolution features through a specific upsampling and splicing mechanism, which effectively alleviates the semantic gap and detail incompatibility problem between multi-scale features.
[0038] In the Pyramid-IEL feature fusion module, a novel feature interaction mechanism is introduced to coordinate multi-scale features, improving the robust representation capability of image features in complex scenes. In this process, the Pyramid-IEL module accepts the output from the PSM-DyT module as input to one branch, and simultaneously uses multi-scale features from the shallow / mid-layers of the backbone network as input to another branch. These two inputs are passed and concatenated in a top-down and bottom-up manner. Then, features at different scales are coordinated and fused to eliminate semantic gaps. The final output after the fusion operation is fed into the prediction output.
[0039] like Figure 5 The diagram shows the specific structure of the PSM-DyT attention encoding module constructed in this invention. This module enhances deep features using a polarization self-attention mechanism and a dual-branch parallel extraction architecture. For the input feature sequence, it is first mapped to query, key, and value features and then positional encoding is superimposed. Subsequently, in the two branches, convolutional dimensionality reduction, softmax normalization, and matrix multiplication are used to enhance feature association, and feature mapping is gradually performed with a multilayer perceptron and layer normalization. Finally, the original input features and the polarization self-attention output features are residually concatenated and fused. This module significantly enhances the network's ability to extract precise edge texture details of small targets.
[0040] The detection output module is used to introduce the Inner-Shape-IoU loss function to calculate the localization loss of the bounding box of the fused feature map, thereby completing the accurate detection of key components of railway freight vehicles.
[0041] In this embodiment, the Inner-Shape-IoU loss function is applied to the detection output, connecting it to the bounding box regression calculation for that layer. Conventional intersection-over-union (IoU) loss functions often suffer from poor localization accuracy and false positives / false negatives during bounding box regression due to the complexity of the target shape and partial occlusion. The Inner-Shape-IoU loss function proposed in this invention addresses this problem by applying a penalty term for the target shape and auxiliary bounding box.
[0042] This embodiment specifically describes the overall operation process as follows: inputting the original image data of the freight vehicle, extracting multi-scale features through downsampling of the LDIM backbone network, encoding the deep multi-scale features using PSM-DyT attention features, performing cross-scale interaction on the features through the Pyramid-IEL fusion module, calculating the bounding box regression at the prediction output end using the Inner-Shape-IoU loss function, and finally outputting the accurate detection results of the key components.
[0043] The present invention also provides an electronic device, which includes a processor and a memory, wherein the processor is used to execute a computer program stored in the memory to implement the real-time detection method for key components of railway freight vehicles based on Transformer in Embodiment 1.
[0044] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the real-time detection method for key components of railway freight vehicles based on Transformer in Embodiment 1.
[0045] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A real-time detection method for key components of railway freight vehicles based on Transformer, characterized in that, Includes the following steps: S1. Obtain the original images of the key components of the railway freight vehicle to be inspected and perform preprocessing; S2. Input the preprocessed original images of key components of railway freight vehicles into the improved Transformer backbone network. The preprocessed original images of key components of railway freight vehicles are extracted through the introduced lightweight dynamic hybrid convolutional network to obtain multi-scale feature maps. The multi-scale feature maps include shallow, medium and deep multi-scale features. S3. Through dual-branch parallel processing of the polarization self-attention mechanism, the edge texture information of small-scale components in the deep multi-scale feature map is extracted and enhanced to obtain the enhanced feature map. S4. The enhanced feature map is used as the first branch input, and the shallow multi-scale features and the mid-scale features are used as the second branch input. The first branch input and the second branch input are spliced and fused to obtain the fused feature map. S5. Introduce the Inner-Shape-IoU loss function to calculate the localization loss of the bounding box of the fused feature map, so as to realize the detection of key components of railway freight vehicles.
2. The real-time detection method for key components of railway freight vehicles based on Transformer according to claim 1, characterized in that, In S1, the preprocessing process includes: data size adjustment, data augmentation, and dataset splitting.
3. The real-time detection method for key components of railway freight vehicles based on Transformer according to claim 2, characterized in that, In step S2, feature extraction is performed on the preprocessed original image of the key components of the railway freight vehicle, specifically as follows: The original images of key components of railway freight vehicles are downsampled and multi-scale features are extracted by using dynamic hybrid convolutional layers. Parameter redundancy is reduced by dynamic weight adjustment, and multi-scale feature maps are output.
4. The real-time detection method for key components of railway freight vehicles based on Transformer according to claim 1, characterized in that, In S3, the dual-branch parallel processing of the polarization self-attention mechanism is specifically as follows: The deep multi-scale feature map is mapped into query, key, and value feature matrices and then overlaid with positional encoding. In the two parallel branches, feature association is enhanced by convolutional dimensionality reduction, softmax normalization, and matrix multiplication, respectively. Enhanced feature maps are output through residual connections, multilayer perceptrons, and layer normalization layers.
5. The real-time detection method for key components of railway freight vehicles based on Transformer according to claim 1, characterized in that, In step S4, the process of generating the fused feature map is as follows: The enhanced feature map is used as the input of one branch, and the multi-scale features of the shallow and mid-level layers of the backbone network are used as the input of another branch. Through a specific upsampling and concatenation mechanism, the deep high semantic features and the shallow high resolution features are progressively coordinated and fused to obtain the fused feature map.
6. The real-time detection method for key components of railway freight vehicles based on Transformer according to claim 3, characterized in that, In S5, the process of detecting key components of railway freight vehicles is specifically as follows: The Inner-Shape-IoU loss function is introduced to optimize the matching degree evaluation in the bounding box regression process by combining the geometric features of the target shape and the auxiliary bounding box penalty term, so as to improve the localization accuracy of key components with complex shapes and partial occlusion.
7. The real-time detection method for key components of railway freight vehicles based on Transformer according to claim 1, characterized in that, In step S5, before calculating the bounding box localization loss, the AdamW optimizer is used to train and optimize the network, with the learning rate set to 0.001, the weight decay set to 0.0001, the batch size set to 16, and the training epochs set to 300.
8. A Transformer-based real-time detection system for key components of railway freight vehicles, used to implement the Transformer-based real-time detection method for key components of railway freight vehicles as described in any one of claims 1 to 7, characterized in that, include: The data acquisition and processing module is used to acquire raw images of key components of the railway freight vehicle to be inspected and to perform preprocessing. The LDIM backbone module is used to input the preprocessed original images of key components of railway freight vehicles into the improved Transformer backbone network. The introduced lightweight dynamic hybrid convolutional network extracts features from the preprocessed original images of key components of railway freight vehicles to obtain multi-scale feature maps. The multi-scale feature maps include shallow, medium and deep multi-scale features. The PSM-DyT attention encoding module is used to extract and enhance the edge texture information of small-scale components in the deep multi-scale feature map through dual-branch parallel processing of the polarization self-attention mechanism, so as to obtain the enhanced feature map. The Pyramid-IEL feature fusion module is used to take the enhanced feature map as the first branch input, take the shallow multi-scale features and the mid-scale features as the second branch input, and concatenate and fuse the first branch input and the second branch input to obtain the fused feature map. The detection output module is used to introduce the Inner-Shape-IoU loss function to calculate the localization loss of the bounding box of the fused feature map, so as to realize the detection of key components of railway freight vehicles.
9. An electronic device, characterized in that, The electronic device includes a processor and a memory, wherein the processor is used to execute a computer program stored in the memory to implement the real-time detection method for key components of railway freight vehicles based on Transformer as described in any one of claims 1-7.
10. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by the processor, it implements the real-time detection method for key components of railway freight vehicles based on Transformer as described in any one of claims 1-7.