Abstract
In public spaces, monitoring pedestrian flow can effectively avoid the occurrence of crowding and stampede incidents, and can effectively improve public safety. To improve the accuracy and efficiency of small target tracking in pedestrian flow detection from a top-down perspective, this study integrates the Vision Transformer architecture and the Deep SORT tracking algorithm to improve the YOLOv5 model. This method aims to achieve efficient detection in complex pedestrian flow scenarios by enhancing the recognition ability and tracking accuracy of small targets. In the experiment, the improved YOLOv5-V-D model quickly converged after 61 iterations, achieving excellent operational efficiency with an average delay of only 7.2ms. Compared to CenterNet and RetinaNet, it has increased by 3.9ms and 6.4ms, respectively. In addition, the model performed outstandingly in terms of accuracy in predicting pedestrian flow, reaching 98.72%, which is superior to the comparison model of 20.59%-28.61%. In summary, the improved YOLOv5 model not only provided faster detection speed, but also significantly improved the accuracy of pedestrian flow detection. This progress provides an effective solution for high-density crowd monitoring, laying a solid foundation for the development of future real-time monitoring systems and effectively improving public safety.
Introduction
Monitoring pedestrian flow in public spaces is critical for preventing stampedes and optimizing traffic. However, performing this task from a "top-down" (overhead) view presents significant challenges. From this perspective, pedestrians appear as "small targets" with minimal distinguishing features. Traditional computer vision models often struggle with low resolution, where pedestrians occupy only a few pixels, and complex backgrounds where pavement patterns or shadows can be mistaken for targets. Furthermore, high-density crowds lead to frequent occlusions, making it difficult for standard detectors to differentiate between individuals. This research addresses these issues by bridging the gap between high-speed detection and high-precision feature extraction.
Methodology and System Overview
The researchers developed a hybrid pipeline termed YOLOv5-V-D. The system is designed to handle both the training of the detection model and its real-time application.
As illustrated in the system flowchart, the workflow involves capturing video from an overhead camera, which is then processed through two main paths:
- Training Path: Graphics are annotated and used to train the model using an improved YOLOv5 architecture.
- Detection Path: The trained model is deployed for real-time target detection on live video streams, outputting pedestrian flow analysis results.
The model was validated using several prominent crowd-counting benchmarks, including UCF_CC_50 (high-resolution images with up to 4,500 individuals) and NWPU Crowd (over 2.1 million annotations). Generalization testing was conducted on the ShanghaiTech and Qnrf datasets to ensure robustness under extreme densities and varied environmental conditions like rain or fog.
Model Architecture
The YOLOv5-V-D architecture relies on the integration of a Token-to-Token Vision Transformer (T2T-ViT) and Deep SORT tracking.
Standard Vision Transformers often lose local structural information when tokenizing images into fixed blocks. The T2T mechanism addresses this by recursively merging adjacent tokens, preserving local details while capturing global context through a Self-Attention Mechanism (SAM). The authors further enhanced this with a custom attention module using Mean and Max pooling followed by a 1x1 convolution to better distinguish similar-looking pedestrians.
The backbone of the model utilizes multiple stages of "Improved T2T" blocks. This multi-scale approach generates feature maps (P2 through P5) at various resolutions, which is essential for detecting targets of different sizes, particularly the "small targets" characteristic of top-down views. Finally, Deep SORT (Simple Online and Realtime Tracking) is employed to turn detections into consistent tracks using Kalman Filtering and the Hungarian algorithm.
Results and Discussion
The experimental results demonstrate that YOLOv5-V-D significantly outperforms industry-standard baselines:
- Accuracy: The model achieved a pedestrian flow prediction accuracy of 98.72%, vastly superior to CenterNet and RetinaNet, which scored between 20.59% and 28.61%.
- Efficiency: The average latency was recorded at 7.2ms, making it 3.9ms faster than CenterNet and 6.4ms faster than RetinaNet.
- Convergence: The model reached an optimal F1 score of 0.952 in just 61 iterations, indicating a very stable and fast training convergence.
- Robustness: In simulated adverse weather (rain, fog, snow), detection accuracy dropped by only approximately 3%.
The "token-to-token" approach effectively solves the resolution problem by aggregating local features before applying self-attention. This allows the model to recognize the structure of a pedestrian even when represented by a small cluster of pixels.
Conclusion
The improved YOLOv5-V-D model provides a high-speed, high-accuracy solution for real-time pedestrian monitoring in complex, high-density scenarios. While performance can degrade in near-total darkness or with extremely rapid motion, the current framework lays a solid foundation for future smart city safety systems. Future work may involve integrating infrared or depth sensor data and exploring adaptive image enhancement techniques to further improve reliability under severe lighting changes.
Summary updated