Despite the implementation of numerous interventions to enhance urban traffic safety, the estimation of the risk of traffic crashes resulting in life-threatening and economic costs remains a significant challenge. In light of the above, an online inference method for traffic crash risk based on the self-developed TAR-DETR and WOA-SA-SVM methods is proposed. The method’s robust data inference capabilities can be applied to autonomous mobile robots and vehicle systems, enabling real-time road condition prediction, continuous risk monitoring, and timely roadside assistance. First, a self-developed dataset for urban traffic object detection, named TAR-1, is created by extracting traffic information from major roads around Hainan University in China and incorporating Russian car crash news. Secondly, we develop an innovative Context-Guided Reconstruction Feature Network-based Urban Traffic Objects Detection Model (TAR-DETR). The model demonstrates a detection accuracy of 76.8% for urban traffic objects, which exceeds the performance of other state-of-the-art object detection models. The TAR-DETR model is employed in TAR-1 to extract urban traffic risk features, and the resulting feature dataset was designated as TAR-2. TAR-2 comprises six risk features and three categories. A new inference algorithm based on WOA-SA-SVM is proposed to optimize the parameters (C, g) of the SVM, thereby enhancing the accuracy and robustness of urban traffic crash risk inference. The algorithm is developed by combining the Whale Optimization Algorithm (WOA) and Simulated Annealing (SA), resulting in a Hybrid Bionic Intelligent Optimization Algorithm. The TAR-2 dataset is inputted into a Support Vector Machine (SVM) optimized using a hybrid algorithm and used to infer the risk of urban traffic crashes. The proposed WOA-SA-SVM method achieves an average accuracy of 80% in urban traffic crash risk inference.