The TrafficRiskClassifier model introduced in this study adopts an innovative approach that incorporates migration learning, image classification, and self-supervised learning, aiming to significantly improve the accuracy and efficiency of traffic accident risk analysis. Compared with traditional traffic safety analysis techniques, this model focuses on utilizing contextual information and situational data of traffic accidents to achieve a higher level of risk classification accuracy. The core of this approach is to deeply mine and analyze the detailed information in the accident environment, to provide more scientific and effective support for traffic accident risk prevention and response. Initially, by integrating migration learning with image classification techniques, the model proficiently extracts pivotal features from intricate traffic scenarios and formulates initial assessments of accident risks. Subsequently, self-supervised learning is incorporated in this study, augmenting the model's capability to comprehend and categorize accident imagery. The TrafficRiskClassifier model exhibits a generalization ability of 91.82%, 85.16%, and 80.92% on individual classification tasks, respectively, signifying its robust learning capacity and proficiency in managing unseen data. Furthermore, the TrafficRiskClassifier model delineates a functional nexus between accident risk and variables such as weather, road conditions, and personal factors, employing a polynomial regression approach. This methodology not only amplifies the predictive precision of the model but also renders it versatile across diverse scenarios. Through the analysis of various polynomial functions, the model achieves enhanced accuracy in classifying disparate risk levels. The outcomes demonstrate that the TrafficRiskClassifier model can efficaciously amalgamate contextual information within traffic scenarios, thereby achieving more precise classification of traffic accident risks, and consequently serving as an invaluable instrument for urban traffic safety management.