T-CPAD: A Transformer-Based Approach for Crowd Flow Prediction and Anomaly Detection
Junkai Yi, Ziyin Zhang, Fei Yang · IEEE Access · 2025
Crowd flow prediction and anomaly are critical issues in urban planning and public safety. However, existing research lacks a comprehensive analysis of crowd flow-related information and fails to address the high variability of crowd flow effectively. Therefore, this study proposes T-CPAD, a Transformer-based approach for crowd flow prediction and anomaly detection, to improve the accuracy of both crowd flow prediction and anomaly detection. Specifically, the Transformer encoder is used to perform a deep and comprehensive analysis of the external features related to crowd flow, achieving precise flow predictions. On this basis, a regularized anomaly discrimination function is designed, the parameters of which are adaptively optimized using gradient descent, enabling accurate anomaly detection and alarms. In practical applications, using an electronic fence dataset provided by a Hi-Tech Park, T-CPAD achieves a mean squared error of 12.5 for crowd flow prediction, a recall and an accuracy of 0.99 and 0.98 in anomaly detection experiments, significantly outperforming traditional methods. These results demonstrate the superior performance and reliability of the T-CPAD approach for crowd flow prediction and anomaly detection.