Method for detecting pedestrians in lightweight station based on RT-DETR
By building a lightweight RT-DETR model and optimizing the backbone network and Transformer layer, the calculation complexity problem of the RT-DETR model on resource-constrained devices is solved, real-time and accuracy of pedestrian detection in stations is realized, and it is suitable for smart systems of urban rail transit.
Patent Information
- Application Number
- CN202510696145.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2025-07-25
AI Technical Summary
The existing RT-DETR model has high computational complexity and is difficult to directly apply in resource-constrained embedded devices or low-power systems, and cannot meet the real-time and accuracy requirements in complex scenarios within the station.
A lightweight station pedestrian detection method based on RT-DETR is constructed, using lightweight backbone network, hybrid encoder, query selection with little uncertainty, lightweight Transformer decoder and auxiliary prediction head to optimize the model structure to reduce the computational complexity.
While maintaining high detection accuracy, it significantly improves the inference speed. It is suitable for real-time detection of resource-constrained equipment, reduces missed and missed detection, and is suitable for integrated intelligent system of medium and low-voltage and weak current in urban rail transit.
Smart Images

Figure CN120375426A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer vision, relates to the fields of image recognition and pedestrian detection, and particularly relates to a lightweight pedestrian detection method in a station based on RT-DETR. Background Art
[0002] With the rapid development of urban rail transit, pedestrian monitoring in stations has become an important task to ensure operation safety and improve management efficiency. Traditional video surveillance systems usually rely on manual inspections or rule-based object detection algorithms, and these methods perform poorly in complex scenarios (such as dense pedestrians, severe occlusion, and lighting changes), making it difficult to meet the requirements of real-time performance and accuracy. In recent years, object detection technologies based on deep learning have made significant progress, especially the successful application of the Transformer architecture in the field of computer vision, providing new solutions for object detection.
[0003] RT-DETR (Real-Time Detection Transformer) is a real-time object detection model based on the Transformer architecture. By introducing self-attention mechanisms and global context modeling, it can efficiently handle object detection tasks in complex scenarios. However, the RT-DETR model has a high computational complexity and is difficult to be directly applied to resource-constrained embedded devices or low-power systems. Summary of the Invention
[0004] In order to meet the requirements of real-time performance and accuracy in complex scene detection and be able to be applied to resource-constrained embedded devices or low-power systems, the present invention proposes a lightweight pedestrian detection method in a station based on RT-DETR, which uses a lightweight object detection model based on RT-DETR to detect pedestrians in the station. The specific steps are as follows: Step 1, collect pedestrian data in the station and preprocess the images.
[0005] Step 2, based on the architecture of RT-DETR, construct a lightweight object detection model based on RT-DETR.
[0006] Step 3, train the object detection model, train the model on the training set, and use the validation set for hyperparameter tuning and model selection.
[0007] Step 4, use the trained object detection model to detect pedestrians in the station.
[0008] Furthermore, the lightweight object detection model includes a lightweight backbone network, an efficient hybrid encoder, query selection with low uncertainty, a lightweight Transformer decoder, an auxiliary prediction head, and a post-processing module, where: A lightweight backbone network for extracting multi-scale image features from the input pedestrian images within the station; An efficient hybrid encoder for performing global context modeling on the feature maps extracted by the backbone network to address occlusion and density issues.
[0009] Query selection with low uncertainty for selecting features from the encoder to initialize object queries and provide high-quality queries for the decoder.
[0010] A lightweight Transformer decoder for converting the encoded feature maps into candidate pedestrian detection results.
[0011] An auxiliary prediction head for refining the candidate detection results output by the Transformer decoder and outputting accurate pedestrian bounding boxes and classes.
[0012] Post-processing for further processing the output of the prediction head to remove redundant detection boxes.
[0013] Furthermore, the lightweight backbone network adopts the MobileNetV3 network, which uses a total of 15 bottleneck layers, one standard convolutional layer, and two pointwise convolutional layers. The lightweight backbone network converts the feature maps into 1280-dimensional feature vectors and inputs them into subsequent modules.
[0014] Furthermore, the bottleneck structure consists of an inverted residual module, a Squeeze-and-Excitation (SE) module, a convolutional compression layer, and a residual connection layer.
[0015] Furthermore, the inverted residual module consists of a convolutional expansion layer, or depthwise separable convolution of and a convolutional compression layer. The expansion layer and the depthwise separable convolution use the h-swish activation function; the SE module consists of a global average pooling layer, a fully connected layer (dimensionality reduction), a ReLU activation function, a fully connected layer (dimensionality increase), and a Sigmoid activation function.
[0016] Furthermore, the depthwise separable convolution in the 4th, 5th, 6th, 13th, 14th, and 15th bottleneck structures uses convolution, and the remaining bottleneck structures all use Convolution. The overall modules of the MobileNetV3 network are, in sequence, a convolutional layer, three bottleneck structures without the SE module and with the ReLU activation function, three bottleneck structures with the SE module and with the ReLU activation function, four bottleneck structures without the SE module and with the h-swish activation function, two bottleneck structures with the SE module and with the h-swish activation function, three bottleneck structures with the SE module and with the h-swish activation function, a convolutional layer, a pooling layer, and one convolutional layer.
[0017] Furthermore, the efficient hybrid encoder described in step 2 consists of Attention-based Intra-scale Feature Interaction (AIFI) and CNN-based Cross-scale Feature Fusion (CCFF).
[0018] Furthermore, the Attention-based Intra-scale Feature Interaction decouples intra-scale interaction and cross-scale fusion by performing intra-scale interaction using a single-scale Transformer encoder and cross-scale fusion using a PANet-style structure. The intra-scale interaction using the single-scale Transformer encoder is only performed on the features at the last stage of the backbone network output, further reducing the computational cost.
[0019] Furthermore, the CNN-based Cross-scale Feature Fusion inserts two fusion blocks composed of convolutional layers in the fusion path. The fusion block fuses the features of two adjacent scales into a new feature, including two convolutions to adjust the number of channels, uses RepBlocks composed of two RepConv for feature fusion, and fuses the outputs of the two paths by element-wise addition.
[0020] Furthermore, in the query selection with low uncertainty described in step 2, the joint latent variables of the encoder features are modeled to provide high-quality queries for the decoder. The feature uncertainty U is defined as the difference between the prediction distributions of the localization P and the classification C, and the uncertainty is integrated into the loss function for gradient-based optimization. The calculation formula for the feature uncertainty is: , where, represents the encoder features.
[0021] Furthermore, the lightweight Transformer decoder described in step 2 consists of 2 decoder layers, and each decoder layer includes a Masked Multi-Head Self-Attention (MMHSA), a Multi-Head Cross-Attention (MHCA), a Feed-Forward Network (FFN), a residual connection, and layer normalization.
[0022] Furthermore, the auxiliary prediction head described in step 2 consists of a classification branch and a regression branch, and both branches are fully connected layers.
[0023] Furthermore, the loss function adopted by the lightweight in-station pedestrian detection model based on RT-DETR during training is: , where represents the loss function of the lightweight in-station pedestrian detection model based on RT-DETR, represents the classification loss of the lightweight in-station pedestrian detection model based on RT-DETR, represents the regression loss of the lightweight in-station pedestrian detection model based on RT-DETR.
[0024] Compared with the prior art, the gain effect of a lightweight in-station pedestrian detection method based on RT-DETR proposed by the present invention is that by optimizing the model structure, the lightweight in-station pedestrian detection model based on RT-DETR significantly reduces the computational complexity by using a lightweight backbone network and reducing the number of Transformer layers. In scenarios such as station monitoring that require real-time processing, lightweight RT-DETR can process video streams at a higher frame rate and is suitable for deployment on resource-constrained devices to meet the real-time detection requirements. In complex scenarios with dense pedestrians and severe occlusions, the present invention can effectively detect targets and reduce missed detections and false detections. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 is a flowchart of a lightweight in-station pedestrian detection method based on RT-DETR of the present invention.
[0026] Figure 2 is a schematic diagram of the lightweight backbone network structure in the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0027] As Figure 1As shown in the figure, this embodiment proposes a lightweight pedestrian detection method in the station based on RT-DETR. By using a lightweight object detection model based on RT-DETR, pedestrian detection is performed on the pedestrians in the station. The specific steps are as follows: Step 1: Collect pedestrian data in urban rail transit stations and preprocess the images.
[0028] Step 2: Based on the architecture of RT-DETR, construct a lightweight object detection model based on RT-DETR. This model includes a lightweight backbone network, an efficient hybrid encoder, query selection with low uncertainty, a lightweight Transformer decoder, an auxiliary prediction head, and a post-processing module. Among them: The lightweight backbone network is used to extract multi-scale image features from the input pedestrian images in the station; The efficient hybrid encoder is used to perform global context modeling on the feature maps extracted by the backbone network to solve occlusion and density problems.
[0029] Query selection with low uncertainty is used to select features from the encoder to initialize object queries and provide high-quality queries for the decoder.
[0030] The lightweight Transformer decoder is used to convert the encoded feature maps into candidate pedestrian detection results.
[0031] The auxiliary prediction head is used to refine the candidate detection results output by the Transformer decoder and output accurate pedestrian bounding boxes and categories.
[0032] Post-processing is used to further process the output of the prediction head and remove redundant detection boxes.
[0033] Step 3: Train the object detection model, train the model on the training set, and use the validation set for hyperparameter tuning and model selection.
[0034] Step 4: Use the trained object detection model to detect pedestrians in the station.
[0035] As a preferred method of this embodiment, the lightweight backbone network adopts the MobileNetV3 network. As Figure 2 shown, a total of 15 bottleneck layers, one standard convolutional layer, and two pointwise convolutional layers are used. The lightweight backbone network converts the feature maps into 1280-dimensional feature vectors and inputs them into the subsequent modules.
[0036] As a preferred embodiment of the present embodiment, the inverted residual module is composed of an expansion layer of convolution, a depthwise separable convolution of OR, and a compression layer of convolution. The h-swish activation function is used in the expansion layer and the depthwise separable convolution; the SE module is composed of a global average pooling layer, a fully connected layer (dimensionality reduction), a ReLU activation function, a fully connected layer (dimensionality increase), and a Sigmoid activation function.
[0037] As a preferred embodiment of the present embodiment, the depthwise separable convolution in the 4th, 5th, 6th, 13th, 14th, and 15th bottleneck structures uses a convolution of [specific convolution details]. The remaining bottleneck structures all use a convolution of [specific convolution details]. The overall modules of the MobileNetV3 network are, in order, a convolutional layer, 3 bottleneck structures without an SE module and with a ReLU activation function, 3 bottleneck structures with an SE module and with a ReLU activation function, 4 bottleneck structures without an SE module and with an h-swish activation function, 2 bottleneck structures with an SE module and with an h-swish activation function, 3 bottleneck structures with an SE module and with an h-swish activation function, a convolutional layer, a pooling layer, and 1 convolutional layer.
[0038] As a preferred embodiment of the present embodiment, the efficient hybrid encoder described in step 2 is composed of Attention-based Intra-scale Feature Interaction (AIFI) and CNN-based Cross-scale Feature Fusion (CCFF).
[0039] As a preferred embodiment of the present embodiment, the Attention-based Intra-scale Feature Interaction decouples the intra-scale interaction and cross-scale fusion by using a single-scale Transformer encoder for intra-scale interaction and a PANet-style structure for cross-scale fusion. The single-scale Transformer encoder is only used for intra-scale interaction on the features at the last stage of the backbone network output, further reducing the computational cost.
[0040] As a preferred embodiment of the present embodiment, the CNN-based Cross-scale Feature Fusion inserts 2 fusion blocks composed of convolutional layers in the fusion path. The fusion block fuses the features of two adjacent scales into a new feature, including two convolutions to adjust the number of channels, uses RepBlocks composed of 2 RepConv for feature fusion, and fuses the outputs of the two paths by element-wise addition.
[0041] As a preferred embodiment of this example, in the query selection with low uncertainty in step 2, the joint latent variables of the encoder features are modeled, and only the queries with high confidence are retained to reduce the input quantity of the Transformer. . The feature uncertainty U is defined as the difference between the prediction distributions of the localization P and the classification C, and the uncertainty is integrated into the loss function for gradient-based optimization. The calculation formula for the feature uncertainty is: , where, represents the encoder feature.
[0042] As a preferred embodiment of this example, the lightweight Transformer decoder in step 2 adopts 2 decoder layers, and each decoder layer includes a Masked Multi-Head Self-Attention (MMHSA), a Multi-Head Cross-Attention (MHCA), a Feed-Forward Network (FFN), a residual connection, and layer normalization. Among them, the weights of some attention heads are shared by different decoding layers, and the intermediate layer dimension of the FFN is reduced to , being the feature dimension.
[0043] As a preferred embodiment of this example, the auxiliary prediction head in step 2 is composed of a classification branch and a regression branch, and both branches are fully connected layers. The input of the auxiliary prediction head is the output of the last decoding layer of the Transformer decoder , the classification branch is to predict the class probability , being the number of classes, and the regression branch is to predict the bounding box coordinates .
[0044] As a preferred embodiment of this example, the loss function adopted by the lightweight pedestrian detection model in the station based on RT-DETR during training is: , where, represents the loss function of the lightweight pedestrian detection model in the station based on RT-DETR, represents the classification loss of the lightweight pedestrian detection model in the station based on RT-DETR, represents the regression loss of the lightweight pedestrian detection model in the station based on RT-DETR.
[0045] As described above, although the present invention has been shown and described with reference to specific preferred embodiments, it should not be construed as a limitation of the present invention itself. Various changes in form and detail may be made thereto without departing from the spirit and scope of the present invention as defined by the appended claims.
Claims
1. A lightweight pedestrian detection method in the station based on RT-DETR, characterized in that, Adopt a lightweight object detection model based on RT-DETR to detect pedestrians in the station. The specific steps are as follows: Step 1: Collect pedestrian data in the station and preprocess the images; Step 2: Based on the architecture of RT-DETR, construct a lightweight object detection model based on RT-DETR; Step 3: Train the object detection model, train the model on the training set, and use the validation set for hyperparameter tuning and model selection; Step 4: Use the trained object detection model to detect pedestrians in the station.
2. The lightweight in-station pedestrian detection method based on RT-DETR according to claim 1, wherein The lightweight object detection model in Step 2 includes a lightweight backbone network, an efficient hybrid encoder, query selection with low uncertainty, a lightweight Transformer decoder, an auxiliary prediction head, and a post-processing module, where: The lightweight backbone network is used to extract multi-scale image features from the input pedestrian images in the station; The efficient hybrid encoder is used to perform global context modeling on the feature maps extracted by the lightweight backbone network; Query selection with low uncertainty is used to select features from the efficient hybrid encoder to initialize object queries and provide queries for the lightweight Transformer decoder; The lightweight Transformer decoder is used to convert the encoded feature maps into candidate pedestrian detection results; The auxiliary prediction head is used to refine the candidate detection results output by the lightweight Transformer decoder and output accurate pedestrian bounding boxes and categories; The post-processing module is used to further process the output of the auxiliary prediction head and remove redundant detection boxes.
3. A lightweight pedestrian detection method in a station based on RT-DETR according to claim 2, characterized in that: The lightweight backbone network adopts the MobileNetV3 network, with a total of 15 bottleneck layers, one standard convolutional layer, and three pointwise convolutional layers; the lightweight backbone network converts the feature map into a 1280-dimensional feature vector and inputs it into the subsequent modules.
4. A lightweight pedestrian detection method in a station based on RT-DETR according to claim 3, characterized in that: The bottleneck structure includes an inverted residual module, an SE module, a compression layer of convolution, and a residual connection layer.
5. A lightweight pedestrian detection method in a station based on RT-DETR according to claim 4, characterized in that: The inverted residual module includes an expansion layer of convolution,[[]] or depthwise separable convolution of and a compression layer of convolution. The expansion layer and depthwise separable convolution use the h-swish activation function. The SE module includes a global average pooling layer, a fully connected layer, a ReLU activation function, a fully connected layer, and a Sigmoid activation function.
6. A lightweight pedestrian detection method in a station based on RT-DETR according to claim 5, characterized in that: The depthwise separable convolutions in the 4th, 5th, 6th, 13th, 14th, and 15th bottleneck structures use convolutions, and the remaining bottleneck structures all use convolutions; The overall modules of the MobileNetV3 network are, in order, a convolutional layer, 3 layers of bottleneck structures without SE module, a bottleneck structure with ReLU as the activation function, 3 layers of bottleneck structures with SE module, a bottleneck structure with ReLU as the activation function, 4 layers of bottleneck structures without SE module, a bottleneck structure with h-swish as the activation function, 2 layers of bottleneck structures with SE module, a bottleneck structure with h-swish as the activation function, 3 layers of bottleneck structures with SE module, a bottleneck structure with h-swish as the activation function, a convolutional layer, a pooling layer, and 1 convolutional layer.
7. A lightweight pedestrian detection method in a station based on RT-DETR according to claim 2, characterized in that: The efficient hybrid encoder consists of attention-based intra-scale feature interaction and CNN-based cross-scale feature fusion; the attention-based intra-scale feature interaction decouples intra-scale interaction and cross-scale fusion by using a single-scale Transformer encoder for intra-scale interaction and a PANet-style structure for cross-scale fusion, and only uses a single-scale Transformer encoder for intra-scale interaction on the features at the last stage of the backbone network output.
8. A lightweight pedestrian detection method in a station based on RT-DETR according to claim 7, characterized in that: The cross-scale feature fusion based on CNN inserts two fusion blocks composed of convolutional layers in the fusion path; the fusion blocks fuse the features of two adjacent scales into a new feature, including two convolutions to adjust the number of channels, uses RepBlocks composed of two RepConv for feature fusion, and the outputs of the two paths are fused by element-wise addition.
9. A lightweight pedestrian detection method in a station based on RT-DETR according to claim 2, characterized in that: In query selection with low uncertainty, the joint latent variables of the encoder features are modeled; the feature uncertainty U is defined as the difference between the prediction distributions of localization P and classification C, and the uncertainty is integrated into the loss function for gradient-based optimization; the calculation formula for feature uncertainty is: , Among them, represents the encoder feature.
10. A lightweight pedestrian detection method in a station based on RT-DETR according to claim 2, characterized in that: The lightweight Transformer decoder consists of 2 decoder layers, and each decoder layer contains a masked multi-head self-attention mechanism, a multi-head cross-attention mechanism, and a feed-forward network.
11. A lightweight pedestrian detection method in a station based on RT-DETR according to claim 2, characterized in that: The auxiliary prediction head consists of a classification branch and a regression branch, and both branches are fully connected layers.
12. A lightweight pedestrian detection method in a station based on RT-DETR according to any one of claims 1-11, characterized in that: The loss function adopted by the lightweight pedestrian detection model in the station based on RT-DETR during training is: , Among them, represents the loss function of the lightweight pedestrian detection model in the station based on RT-DETR, represents the classification loss of the lightweight pedestrian detection model in the station based on RT-DETR, represents the regression loss of the lightweight pedestrian detection model in the station based on RT-DETR.