Fine-grained multi-task driving risk prediction method fused with trajectory prediction auxiliary task

By integrating trajectory prediction auxiliary tasks into a multi-task traffic risk prediction method, which shares encoder feature representations and dynamically adjusts loss weights, the problem of insufficient feature granularity in traditional methods is solved, and high-precision traffic accident risk prediction is achieved.

CN121393151AActive Publication Date: 2026-01-23TONGJI UNIV

Patent Information

Application Number
CN202511935768.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-22
Publication Date
2026-01-23
Estimated Expiration
2045-12-22

AI Technical Summary

Technical Problem

Traditional traffic accident risk prediction methods suffer from insufficient accuracy because their feature granularity is too coarse to accurately depict the interaction between vehicles and individual differences.

Method used

A fine-grained multi-task driving risk prediction method is adopted, which integrates trajectory prediction auxiliary task. Risk labels are automatically labeled through trajectory data, and risk prediction main task and trajectory prediction auxiliary task are designed. The encoder feature representation is shared, and the loss weight is adjusted by dynamic weight averaging strategy to realize information collaboration and knowledge transfer between tasks.

Benefits of technology

It significantly improves the accuracy and robustness of driving risk prediction models, enabling them to more accurately capture dynamic interaction information between vehicles and enhance the ability to identify potential risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121393151A_ABST
    Figure CN121393151A_ABST
Patent Text Reader

Abstract

The invention relates to the field of automatic driving and traffic safety, in particular to a fine-grained multi-task driving risk prediction method fused with a trajectory prediction auxiliary task. Comprising the following steps: step 1, automatically labeling risk labels based on trajectory data; 2, designing a main task of the driving risk prediction model; 3, auxiliary task design of the driving risk prediction model; and 4, constructing and training a driving risk prediction model. An experiment result based on a disclosed NGSIM data set shows that the precision and robustness of a driving risk prediction model can be remarkably improved by introducing trajectory prediction as an auxiliary task.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of intelligent transportation and vehicle-road cooperation, and particularly relates to a fine-grained multi-task driving risk prediction method fusing a trajectory prediction auxiliary task. BACKGROUND

[0002] In the intelligent transportation system, traffic accident risk prediction, as an important part of active safety control, has been widely applied in various intelligent driving and traffic management scenarios. Traditional research usually constructs risk variables by extracting traffic flow, average speed, lane changing frequency and other macro statistical features from traffic data, and uses various regression models or classification models to predict accident risk. Such methods have the advantages of easy data acquisition and low computational complexity, but due to the coarse granularity of the features used, it is difficult to accurately describe the interaction between vehicles and individual differences, and the ability to identify abnormal driving behavior is limited, resulting in insufficient risk prediction accuracy.

[0003] With the advancement of smart highway construction and the development of sensor technology and deep learning methods, it is possible to obtain high-frequency and high-precision vehicle trajectory data, and micro-risk prediction based on fine-grained driving behavior features has gradually become a research hotspot. Such methods can more comprehensively capture dynamic interaction information between vehicles, thereby providing a new technical path for high-precision prediction of driving risk. SUMMARY

[0004] In view of the problems of insufficient feature expression and single task modeling in the prior art, the application proposes a fine-grained multi-task driving risk prediction method fusing a trajectory prediction auxiliary task. The method includes a risk prediction main task and a trajectory prediction auxiliary task, and the networks of the two tasks share feature representations in the encoding layer to realize information collaboration and knowledge transfer between tasks. In view of the problem of inconsistent loss scales in multi-task learning, a dynamic weight averaging strategy is adopted to adaptively adjust the loss weights of each task to improve the training stability and prediction performance of the model. Experimental results based on the public NGSIM dataset show that the introduction of trajectory prediction as an auxiliary task can significantly improve the accuracy and robustness of the driving risk prediction model.

[0005] TECHNICAL SCHEME The fine-grained multi-task driving risk prediction method fusing a trajectory prediction auxiliary task comprises the following steps: Step 1: Automatically labeling risk labels based on trajectory data; Collect trajectory data, calculate the Modified Time to Collision (MTTC) risk index, identify risk scenarios according to the MTTC index, and label risk labels.

[0006] Step 2: Design of risk prediction main task; The risk prediction main task is used for predicting whether there is a potential risk event after a current scene for a future n-second duration. The trajectory data is input, and first, a spatiotemporal behavior representation of a target vehicle and its surrounding environment is extracted by an encoder module, and then a risk prediction main task network is used to predict a probability of a risk existing in the input sample.

[0007] Step 3: Trajectory prediction auxiliary task design The trajectory prediction auxiliary task is an auxiliary task in the multi-task framework of the present application, and shares an encoder structure with the risk prediction main task. The trajectory prediction auxiliary task network takes the vehicle feature representation output by the encoder as input, combines the trajectory center point position information, and predicts a future trajectory coordinate sequence. Meanwhile, the trajectory prediction auxiliary task network participates in joint training in a total loss function with a dynamic weight.

[0008] Step 4: Construction and training of the driving risk prediction model The driving risk prediction model framework is constructed, including the risk judgment main task and the trajectory prediction auxiliary task. The model loss function considers the losses of the main task and the auxiliary task, and adopts a dynamic weight average (DWA) mechanism to adaptively adjust the loss weight of the main task and the auxiliary task. Iterative training is performed until the loss converges.

[0009] In the inference stage, the trained driving risk prediction model is used to predict the risk of the input trajectory data.

[0010] Further, step 1 is specifically as follows: Step 1.1: Calculate the modified TTC risk index The modified TTC risk index is calculated as follows: The time to collision (TTC) index is a commonly used risk index, and has been widely used in micro risk judgment tasks due to its simple calculation and clear physical meaning. Let the longitudinal position of the preceding vehicle be , the speed be ; the following vehicle position be , and the speed be (taking the positive direction along the driving direction, and ). Under the assumption that the speeds of the two vehicles remain constant, the longitudinal time to collision TTC is as follows: TTC describes the remaining time until the two vehicles collide in the future under the condition that no braking or acceleration measures are taken. The smaller the value, the higher the risk of a traffic accident.

[0011] TTC has a constant speed assumption, and in order to overcome the shortcomings of this assumption, a longitudinal acceleration correction is introduced into TTC to form a modified TTC index (MTTC). Considering the constant acceleration of the following vehicle , and the constant acceleration of the preceding vehicle , the relative displacement of the two vehicles satisfies: The minimum positive real root of the equation that makes the longitudinal distance between the two vehicles reduce to the set minimum safety distance is the MTTC: The advantage of MTTC is that it allows vehicles to move at a constant acceleration, thereby distinguishing between typical traffic conflict situations such as "deceleration while following a vehicle but still maintaining a safe distance" and "acceleration leading to a rear-end collision". When , it is determined as a potential conflict event. Where is a pre-set threshold value.

[0012] Step 1.2 automatically identify the risk of the scene; In actual vehicle operation scenarios, in order to be able to take risk-avoiding behavior in time, it is usually necessary to give a risk warning m seconds in advance. That is, using the trajectory data of the past n seconds to predict the accident risk value m seconds later. The past n seconds and the future m seconds form a scene sample with a time length of n+m seconds, and the MTTC index at the time of the future m seconds needs to be calculated as a substitute index for the risk value.

[0013] Assuming that the risk time is t, considering that the trajectory data has noise, the instantaneous data at time t cannot be used to calculate the MTTC index, so the last L frames of MTTC set before time t are taken If the elements of the set satisfy: then the scene is defined as a high-risk state, and is given a label , otherwise it is recorded as low risk, and the label is .

[0014] Process the collected trajectory data, identify the risk scene according to the MTTC index, and label the risk label.

[0015] Further, step 2 is as follows: Step 2.1 Vehicle trajectory feature extraction; An encoder module is designed to extract the spatio-temporal behavior representation of the target vehicle and its surrounding environment. The encoder includes a two-stage structure: a single vehicle trajectory feature extraction network and an inter-vehicle interaction module.

[0016] The model input is the trajectory tensor of all effective vehicles in the past frames , where represents the batch size, is the number of frames of historical trajectory, ​2 represents the maximum number of vehicles per frame, and 2 represents the dimension of the trajectory data. The input is first multiplied by a mask tensor. The missing trajectories are masked to obtain the effective trajectory tensor. : Valid vehicle trajectory data for each sample scene in the batch Trajectory feature extraction is performed, where For the first The number of valid vehicles in each sample scenario.

[0017] The single-vehicle trajectory feature extraction network employs a three-layer stacked Res1D network to perform one-dimensional convolutional modeling on the trajectory of each vehicle, extracting local temporal features. The outputs from each scale are fused to a unified dimension via lateral connections, and then passed through a residual module to output vehicle feature codes. in, This refers to the specified vehicle representation dimension, i.e., the sample scene. The effective vehicle characterization combination is as follows: in, For single vehicles The temporal features obtained after encoding the historical trajectory sequence have the following center position: .

[0018] The vehicle-to-vehicle interaction module uses a two-layer attention mechanism to model the mutual influence between vehicles, performing spatial attention modeling on each vehicle and its neighboring vehicles. Using the aligned vehicle center position as the geometric reference, each pair of center positions is then sequentially... and target vehicle and surrounding vehicles (The surrounding vehicles refer to those that meet the distance constraints) The model aggregates information from vehicles. At each layer, it constructs a contextual representation based on the relative positions of vehicles, the query vector, and neighbor features, and updates the target vehicle features through residual connections and normalization. in, and These represent the first and second layer attention aggregation modules, respectively. Indicates to vehicles The temporal features obtained after encoding the historical trajectory sequence. Indicates vehicle The central location, , They represent the target vehicles respectively. After the aggregation of the double-layer attention, the intermediate features of the target vehicle and the final interaction features, represent the target vehicle The feature set of all neighboring vehicles in the neighborhood.

[0019] The final output of represent the target vehicle The feature representation of the target vehicle fused with multi-order neighbor information, as a shared input for subsequent risk judgment and trajectory prediction tasks.

[0020] Step 2.2 Network structure design of the risk prediction main task; The risk prediction main task is used to predict whether there is a potential risk event after the current scene for n seconds. This task not only makes judgments based on the feature representation of a single vehicle, but also introduces inter-vehicle context information through a multi-head attention mechanism to capture potential collaborative risk relationships.

[0021] The input of the risk prediction main task network is the vehicle feature information obtained from the encoder, denoted as: where, is the number of effective target vehicles in the current input sample, is the feature dimension, and the feature representation of the th target vehicle is The task first updates each using itself and other target vehicles for self-attention, i.e., where, represents the standard multi-head attention mechanism, Query, Key, Value matrices of the multi-head attention mechanism, input and output dimensions are . Then, the updated representation is mapped through two layers of fully connected layers to obtain the logit value of risk prediction , as follows: In the inference stage, to obtain the probability output of the existence of risk for this sample, further Sigmoid mapping is performed: where, represents the Sigmoid function, is the fully connected layer weight, is the bias term.

[0022] In model design, the multi-head attention mechanism enables the model to perceive the global semantic relationship between target vehicles, improving the ability to model collaborative risk behaviors in the scene.

[0023] Step 2.3 Loss function design for risk prediction main task During training, risk prediction uses binary cross-entropy loss: wherein, is the true label of the th sample , taking values 0 or 1. The true label is obtained in step 1, with 1 indicating a high-risk state and 0 indicating a low-risk state; is the "logit" value of the th sample in the model output; is the sigmoid function output of , representing the probability that the model predicts the sample to be at risk (label 1), calculated as follows: Further, step 3 is as follows: Step 3.1 Network structure design for trajectory prediction auxiliary task The trajectory prediction auxiliary task is used to regress the trajectory position of each target vehicle within a future time window, and is constructed as a multi-time step position prediction task.

[0024] The trajectory prediction auxiliary task network takes the vehicle feature representation output by the encoder as input, combines the trajectory center point position information, and predicts the future trajectory coordinate sequence. In order to make the predicted trajectory have multi-modal characteristics, K different predicted trajectories are generated simultaneously.

[0025] The feature representation of the th target vehicle is , and the corresponding historical trajectory center point is . K independent multi-layer perceptrons (MLP) are used to model in parallel, outputting the relative displacement sequence of K predicted trajectories: wherein, denotes the predicted relative displacement sequence. Adding it to the historical last-frame center point , we get the predicted position of each trajectory: This structure avoids directly regressing absolute positions, improving the stability of the prediction.

[0026] Step 3.2 Loss function design for trajectory prediction auxiliary task In the training phase, the model first computes the average Euclidean distance between all predicted trajectories and the real trajectory , and selects the trajectory with the smallest error as the optimal mode, denoted as . Only for this optimal trajectory, the smooth L1 loss is calculated as the regression loss term: where denotes the number of target vehicles in the current training batch. To enhance the model's ability to distinguish multiple modal outputs, the classification branch simultaneously scores the confidence of all candidate trajectories. The maximum margin classification loss encourages the model to give higher scores to the optimal mode;. The total loss of the final trajectory prediction task is defined as: where is the loss weight balancing coefficient. The maximum margin classification loss is defined as follows: where denotes the number of vehicles, denotes the number of modes, denotes the margin, denotes the score of the non-optimal mode trajectory of vehicle v, denotes the score of the optimal mode trajectory of vehicle m.

[0027] Further, step 4 is specifically as follows: Step 4.1 overall structure design of driving risk prediction model; The overall framework of the driving risk prediction model adopts an end-to-end structure, including a risk judgment main task, a trajectory prediction auxiliary task, and a shared encoder. The input historical trajectory first extracts local time sequence features through the encoder, and then introduces an attention mechanism to model the interaction between the target vehicle and the surrounding vehicles, capturing potential dynamic influence relationships; on the shared features output by the encoder, two decoding paths are established respectively: the main task is a binary classification risk judgment, outputting the accident probability; the auxiliary task is a trajectory point regression, outputting a trajectory prediction sequence for a certain number of time steps in the future.

[0028] Step 4.2 loss function design of driving risk prediction model; In order to improve the training stability and multi-task collaboration efficiency, the model loss function considers the weighted loss sum of the main and auxiliary tasks, and adopts a dynamic weight average (DWA) algorithm to adaptively adjust the loss weights of the main and auxiliary tasks, realizing the unified modeling process of feature sharing and target decoupling.

[0029] wherein , These are the loss functions for the primary and secondary tasks, respectively. and Calculated using the DWA algorithm.

[0030] Specifically, the DWA algorithm automatically adjusts the optimization intensity of each task. If the loss of a task decreases slowly, it indicates that the training is difficult, so its weight is increased to make the model pay more attention to the task; conversely, it indicates that the training is easy, so its weight is reduced accordingly.

[0031] The specific formula for weight update is as follows: in, Indicates task Loss of (main task or auxiliary task) in the (t-1)th iteration The loss at the (t-2)th time The ratio reflects the convergence speed of the task loss. Indicates to Softmax normalization is performed, and the loss weights assigned to task i in the t-th iteration are used. I represents the number of tasks, and T is the temperature coefficient.

[0032] Step 4.3 Training the driving risk prediction model; The specific process of iterative training is as follows: (1) Input is the trajectory data of the target vehicle and its neighboring vehicles within a straight distance of less than D meters for m seconds. Identify risk scenarios based on the MTTC index and label them with risk tags. (2) Calculate the loss function of the main task. Calculate the loss function of the auxiliary task. The loss weights are dynamically adjusted using a dynamic weighted averaging algorithm. and Calculate the total loss of the model ; (3) Save the magnitude of risk loss and trajectory loss in this batch to prepare for the loss weight calculation of the next batch; (4) According to Backpropagation updates the driving risk prediction model parameters ; (5) Repeat (1)-(4) until the loss converges, then return to the driving risk prediction model. .

[0033] Beneficial effects By taking trajectory prediction as an auxiliary task and sharing the encoder with risk judgment, the application not only utilizes the inherent connection between the two types of tasks to achieve effective feature sharing and knowledge transfer, but also injects the regularization of physical consistency into the model through auxiliary loss, ultimately improving the accuracy and robustness of risk prediction. The specific reasons for the performance advantages are as follows: (1) Essential correlation: The driving risk is essentially determined by the future motion trend of the vehicle and the interaction with the surrounding targets (such as physical quantities such as speed change, acceleration, relative displacement, and collision time). Trajectory prediction directly models these future motion states, so there is a close semantic connection with risk judgment.

[0034] (2) Representation learning and knowledge transfer: The main task (risk classification) and the auxiliary task (trajectory generation) share the same encoder, and the trajectory prediction task forces the encoder to learn more complete vehicle dynamics and vehicle interaction features from trajectory data during training. This multi-task sharing enables the encoder to transfer fine-grained features useful for motion evolution to risk discrimination, complementing the single risk classification loss that is difficult to capture temporal causal relationships.

[0035] (3) Inductive bias and regularization effect: Trajectory prediction as an auxiliary loss introduces the inductive bias of physical consistency into the model, reducing overfitting and improving generalization ability. More accurate future trajectory representation makes risk judgment based on physical quantities (such as TTC, relative speed, path intersection distance, etc.) more reliable, thereby improving the accuracy and stability of risk prediction. BRIEF DESCRIPTION OF DRAWINGS

[0036] Figure 1 The method processing flowchart of the application; Figure 2 The network structure diagram of the driving risk prediction model of the embodiment of the application; Figure 3 The network structure diagram of the trajectory prediction auxiliary task of the embodiment of the application; Figure 4 The ROC curve diagram of the model of the embodiment of the application. DETAILED DESCRIPTION

[0037] The technical solutions provided by the application will be further described below in conjunction with specific embodiments and their accompanying drawings. The advantages and features of the application will become clearer in conjunction with the following description.

[0038] This invention proposes a fine-grained multi-task vehicle risk prediction method that integrates trajectory prediction as an auxiliary task. The method includes a main risk prediction task and a trajectory prediction auxiliary task. The networks for both tasks share feature representations at the encoding layer, achieving information collaboration and knowledge transfer between tasks. To address the issue of inconsistent loss scales in multi-task learning, a dynamic weight averaging strategy is adopted to adaptively adjust the loss weights for each task, thereby improving the model's training stability and prediction performance. The network structure of the vehicle risk prediction model used in this invention is as follows: Figure 2 .

[0039] Example A fine-grained multi-task driving risk prediction method integrating trajectory prediction assistance includes the following steps: (e.g.) Figure 1 ) Step 1: Automatically label risk data When collecting trajectory data, the target vehicle is the center, and the movement trajectories of surrounding vehicles are also recorded. Trajectory data is collected on a vehicle-by-vehicle basis, recording its motion state over continuous time slices. Core fields typically include vehicle ID, vehicle size parameters, timestamp (or frame number), and two-dimensional plane coordinates. Using a specific risk prediction time point as a boundary, trajectories before that time point are defined as historical trajectories, while trajectories after that point (whether to be predicted or actually observed) are defined as future trajectories.

[0040] A frame represents a snapshot of a traffic scene at a specific timestamp, including trajectory data of all observed vehicles and related road environment information at that moment. Road environment information may include lane number, lane geometry, lane topology, lane type, various semantic information, relationships between vehicles, and key vehicle interaction features such as distance between vehicles, used to describe the local traffic structure and the interactions between vehicles. Because the number of participating vehicles in different time frames changes dynamically, the vehicle dimension needs to be padded with a uniform length during tensor quantization.

[0041] To support modeling of a dynamic number of vehicles, a binary mask tensor is introduced. The mask indicates whether a vehicle slot in a frame corresponds to a real vehicle trajectory. Model computation only performs feature extraction and network forward propagation at the position where Mask=1, thus effectively shielding invalid trajectories generated by padding while maintaining the uniformity of the tensor structure.

[0042] A sample or scenario refers to a spatio-temporal segment extracted from a continuous sequence of frames by a sliding window. Its spatial range is centered on the target vehicle and contains multi-vehicle trajectory data and corresponding road environment information within the neighborhood of the target vehicle. Its temporal range covers a traffic segment of m+n seconds before and after the risk prediction time point, i.e., a historical scenario of m seconds before the prediction time and a future scenario of n seconds after the prediction time. Each sample is associated with a driving risk label indicating whether the target vehicle will have a potential collision risk after n seconds, thereby used for training and performance evaluation of the driving risk prediction model.

[0043] Step 1.1. Calculate the modified TTC risk indicator The time to collision (TTC) indicator is a commonly used risk indicator that has been widely used in micro-risk judgment tasks due to its simplicity and clear physical meaning. Let the longitudinal position of the preceding vehicle be , the speed be ; the following vehicle position be , the speed be (taking the positive direction along the driving direction, and ). Under the assumption that the speeds of the two vehicles remain constant, the longitudinal collision time TTC is as follows: TTC describes the remaining time until the two vehicles collide in the future under the condition of not taking any braking or acceleration measures. The smaller the value, the higher the risk of traffic accidents. TTC has a constant speed assumption. To overcome the shortcomings of this assumption, a longitudinal acceleration correction can be introduced into TTC to form a modified TTC indicator (MTTC). Considering the constant acceleration of the following vehicle and the constant acceleration of the preceding vehicle , the relative displacement of the two vehicles satisfies: Solving the minimum positive real root that makes the longitudinal distance between the two vehicles reduce to a set minimum safety distance is the MTTC: The advantage of MTTC is that it allows vehicles to move at constant acceleration, thereby distinguishing between typical traffic conflict situations such as "deceleration while following but still in a safe distance" and "acceleration leading to rear-end collision". When , it is determined as a potential conflict event.

[0044] In this embodiment, the trajectory collection frequency is 10 Hz, and MTTC has better robustness for trajectory data with a sampling frequency of 5-10 Hz, effectively smoothing out errors caused by instantaneous speed fluctuations. The MTTC threshold for risk events is set to 2s.

[0045] Step 1.2 Automatic identification of scene risk For a certain vehicle v, in order to take timely risk-avoiding behavior, it is usually necessary to give a risk warning m seconds in advance. That is, using the trajectory data of the past n seconds to predict the accident risk value m seconds later. Here, the past n seconds and the future m seconds form a scene sample with a time length of n+m seconds, and the MTTC index at the time of the future m seconds needs to be calculated as a substitute index of the risk value.

[0046] Assuming that the risk time is t, considering that the trajectory data has noise, the MTTC index cannot be calculated with the instantaneous data at time t, so the last L frame MTTC set before time t is taken If the set element satisfies: Then define the scene as a high-risk state, and give the label , otherwise, it is low risk, and the label is .

[0047] In this embodiment, m=3, n=2, that is, using the vehicle trajectory data of the past 3 seconds to predict whether a risk event will occur 2 seconds later. The complete scene sample length is 5 seconds, and L=3 is taken to determine whether a risk event occurs.

[0048] Step 2 Risk prediction main task design Step 2.1 Vehicle trajectory feature extraction module design An encoder module is designed to extract the spatio-temporal behavior representation of the target vehicle and its surrounding environment, which includes a two-stage structure: single vehicle trajectory feature extraction network and vehicle interaction module.

[0049] The model input is the trajectory tensor of all effective vehicles in the past frames , where represents the Batch size, is the number of frames of historical trajectory, is the maximum number of vehicles per frame. The input is first multiplied by the mask tensor to shield the missing trajectory, and the effective trajectory tensor is obtained: The trajectory feature extraction is performed on the effective vehicle trajectory data in the scene of each sample in the Batch , where is the number of effective vehicles of the th sample scene.

[0050] The trajectory feature extraction network is designed, and a three-layer stacked Res1D network is adopted to perform one-dimensional convolution modeling on each vehicle trajectory to extract local time sequence features. The features of each scale are fused into a unified dimension through lateral connection, and then output through a residual module to obtain vehicle feature encoding: wherein, is the specified vehicle representation dimension. That is, the representation combination of the effective vehicles in the sample scene is as follows: wherein, is the time sequence feature obtained after encoding the historical trajectory sequence of a single vehicle , and the center position is .

[0051] Then, a double-layer attention mechanism is designed to model the mutual influence between vehicles, and spatial attention modeling is performed on each vehicle and its adjacent vehicles. The aligned vehicle center position is taken as a geometric reference, and information aggregation is performed on each pair of target vehicle and surrounding vehicles (the surrounding vehicles refer to vehicles satisfying the distance constraint ). In each layer, the model constructs a context representation according to the relative position between vehicles, the query vector and the neighbor feature, and updates the target vehicle feature through residual connection and normalization: wherein, and respectively represent the first layer and the second layer attention aggregation module, represents the time sequence feature obtained after encoding the historical trajectory sequence of the vehicle , represents the center position of the vehicle , , respectively represent the intermediate feature and the final interaction feature of the target vehicle after double-layer attention aggregation, represents the feature set of all neighbor vehicles in the neighborhood of the target vehicle .

[0052] The final output represents the feature representation of the target vehicle fused with multi-order neighbor information, which is used as a shared input for subsequent risk judgment and trajectory prediction tasks.

[0053] In this embodiment, C=128, =100.

[0054] Step 2.2 Network structure design of risk prediction main task The main task is used to predict whether there is a potential risk event after the current scene for n seconds. This task not only makes judgments based on the feature representation of a single vehicle, but also introduces inter-vehicle context information through a multi-head attention mechanism to capture potential collaborative risk relationships.

[0055] The input of the risk prediction main task is the vehicle feature information obtained from the encoder (vehicle embedding information), denoted as wherein, is the number of effective target vehicles in the current input sample, is the feature dimension.

[0056] The task first updates each using self-attention and other target vehicles, that is: wherein, represents a standard multi-head attention mechanism, and the input and output dimensions are . Then, the updated representation is mapped through two fully connected layers to obtain the logit value of risk prediction , as follows: In the inference stage, to obtain the probability output, further Sigmoid mapping can be performed: wherein, represents a Sigmoid function, is a fully connected layer weight, is a bias term.

[0057] In model design, the multi-head attention mechanism enables the model to perceive the global semantic relationship between target vehicles, improving the modeling ability of collaborative risk behavior in the scene.

[0058] In this embodiment, n = 2, and in the multi-head attention mechanism, the number of attention heads is set to 4.

[0059] Step 2.3 Loss function design of risk prediction main task In the training process, the risk prediction uses a binary cross-entropy loss: wherein, is the true label of the th sample , taking a value of 0 (low risk) or 1 (high risk). is the th sample The "logit" value in the model output; is the sigmoid function output, representing the probability that the model predicts the sample to be high-risk (label 1), calculated as follows: Step 3 Trajectory prediction auxiliary task design The trajectory prediction task as an auxiliary task in the multi-task framework shares the encoder structure with the main task, and participates in joint training in the total loss function with a dynamic weight.

[0060] Step 3.1 Network structure design of trajectory prediction auxiliary task The trajectory prediction auxiliary task is used to regress the trajectory position of each target vehicle within a future time window, and is constructed as a multi-time step position prediction task. This module takes the vehicle feature representation (vehicle embedding information) output by the encoder as input, combines the trajectory center point position information, and predicts the future trajectory coordinate sequence. The network structure design of the auxiliary task is shown in Figure 3 .

[0061] The th feature representation of the target vehicle is , and the corresponding historical trajectory center point is In order to make the predicted trajectory have a multi-modal characteristic, K independent multi-layer perceptrons (MLP) are used to model in parallel, outputting K relative displacement sequences of the predicted trajectory: Wherein, represents the predicted relative displacement sequence. Adding it to the historical last frame center point , the predicted position of each trajectory is obtained: This structure avoids directly regressing the absolute position, improving the stability of the prediction.

[0062] In this embodiment, K=6, taking 6 modes.

[0063] Step 3.2 Loss function design of trajectory prediction auxiliary task In the training stage, the model first calculates the average Euclidean distance between all predicted trajectories and the real trajectory , and selects the trajectory with the smallest error as the optimal mode, denoted as . Only the optimal trajectory is calculated as the regression loss term: in, This represents the number of target vehicles in the current training batch. To enhance the model's ability to discriminate multimodal outputs, the classification branch simultaneously scores the confidence of all candidate trajectories. Maximum margin classification loss is used. The model is encouraged to award higher scores to the optimal mode. The total loss for the final trajectory prediction task is defined as: in, This represents the loss weight balancing coefficient. The maximum margin classification loss is defined as follows: in, Indicates the number of vehicles. Indicates the number of modes. Indicates interval, This represents the score of the non-optimal mode trajectory of vehicle v. This represents the score of the optimal modal trajectory of vehicle m.

[0064] In this embodiment , .

[0065] Step 4: Construction and Training of the Driving Risk Prediction Model Step 4.1 Overall Model Structure Design The overall framework of the driving risk prediction model adopts an end-to-end structure, including a main task of risk prediction, an auxiliary task of trajectory prediction, and a shared encoder. The input historical trajectory first extracts local temporal features through the encoder module, then introduces an attention mechanism to model the interaction between the target vehicle and surrounding vehicles, capturing potential dynamic influence relationships. Based on the shared features output by the encoder, two decoding paths are established: the main task is binary risk classification, outputting the accident probability; the auxiliary task is trajectory point regression, outputting a trajectory prediction sequence for several future time steps. The model structure is as follows: Figure 2 As shown.

[0066] Step 4.2 Loss Function Design To improve training stability and multi-task collaboration efficiency, the model loss function consists of binary cross-entropy, margin contrastive loss, and regression loss. The Dynamic Weighted Average (DWA) mechanism is used to adaptively adjust the loss weights of the main and auxiliary tasks, realizing a unified modeling process that combines feature sharing and target decoupling.

[0067] in, and Calculated using the DWA algorithm.

[0068] Step 4.3 Training the driving risk prediction model The specific process of iterative training is as follows: (1) Input is the trajectory data of the target vehicle and its neighboring vehicles within a straight distance of less than D meters for m seconds, and label the risk according to the MTTC index; (2) Calculate the loss function of the main task. Calculate the loss function of the auxiliary task. The loss weights are dynamically adjusted using a dynamic weighted averaging algorithm. and Calculate the total loss of the model ; (3) Save the magnitude of risk loss and trajectory loss in this batch to prepare for the loss weight calculation of the next batch; (4) According to Backpropagation updates the driving risk prediction model parameters ; (5) Repeat (1)-(4) until the loss converges, then return to the driving risk prediction model. .

[0069] The dynamic weight averaging algorithm automatically adjusts the optimization intensity of each task. If the loss of a task decreases slowly, it indicates high training difficulty, so its weight is increased to allow the model to focus more on that task; conversely, if the loss decreases slowly, it indicates easy training, so its weight is decreased accordingly. The specific formula for weight updates is shown below: in, Indicates task The ratio of the loss in the (t-1)th iteration to the loss in the (t-2)th iteration reflects the convergence speed of the task loss. Indicates to Softmax normalization is performed, and the loss weights assigned to task i in the t-th iteration are used. I represents the number of tasks, and T is the temperature coefficient.

[0070] In this embodiment, D=200, m=3. When calculating the dynamic weights, I is 2 and T is 5.

[0071] Step 5: Comparative Experiment and Advancement Analysis Step 5.1 Verification of the effectiveness and necessity of the model design The verification experiment of the method of the present application is carried out based on the trajectory data set NGSIM. The NGSIM (Next Generation Simulation) trajectory data is from the United States Federal Highway Administration, collected from the Los Angeles US-101 highway, and a plurality of overhead cameras are arranged on 5 main lines and 1 auxiliary road. The video collected is processed to obtain lane-level high-precision trajectory data of about 6150 vehicles with a sampling frequency of 10 Hz, covering various typical traffic scenarios such as free flow, traffic merging and congestion.

[0072] The 5-second scene sample is divided into a training set, a validation set and a test set in a ratio of 7:1.5:1.5. The performance indicators are calculated on the test set, including AUC (Area Under Curve), precision, recall and F1 value. The ROC curve (Receiver Operating Characteristic Curve) of the model on the test set is as shown in Figure 4 It can be seen that the curve is close to the upper left corner as a whole, indicating that the model has strong discriminant ability in predicting risk. The corresponding AUC (area under the ROC curve) value is 0.9305, which is significantly higher than the level of random guess (AUC=0.5), indicating that the model effectively captures the potential traffic risk features from the trajectory data.

[0073] To verify the contribution of each key module in the proposed model to the overall performance, a plurality of ablation experiments are designed. From the perspectives of task structure, weight scheduling mechanism and interaction modeling method, specific components are gradually stripped or replaced to observe the changes in model performance. All experiments are carried out on the same data set and training configuration, and the results are shown in Table 1.

[0074] Table 1 Comparison of risk judgment performance of different model configurations It can be seen that the overall performance of the model using multi-task learning is better than that of the single-task model, and the performance is more stable in the four indicators. This shows that the unified modeling of risk judgment and trajectory prediction tasks can effectively play the synergistic effect between the two, enabling the model to perceive the trend of vehicle motion while enhancing the ability to identify potential risk states. In contrast, the single-task model only focuses on risk output and lacks the supplementary modeling of scene dynamics by auxiliary tasks, resulting in insufficient understanding of complex interactive scenarios and difficulty in forming a stable and generalizable risk judgment boundary.

[0075] It is worth noting that the decrease in AUC and recall after removing DWA is relatively limited (AUC is still 0.91, and recall is even slightly higher), which indicates that the learning conflict between the two tasks is not significant under the current data distribution and loss scale, and a certain degree of multi-task collaborative training effect can be maintained even with fixed weights. In a more complex and task-different multi-task scenario, the dynamic weight mechanism may play a greater role. Step 5.2 Baseline method selection To verify the advancement of the driving risk prediction model proposed in the present application, a representative baseline method is selected for comparison. Specifically, the Vehicle Group (VG) based crash risk prediction framework proposed in the paper “Vehicle-Group-Based Crash Risk Prediction and Interpretation on Highways” is selected, and the prediction time is 1 second.

[0076] Step 5.3 Performance index comparison Table 2 summarizes the performance of the present application and the baseline methods (including the VGRL (Vehicle Group’s Risk Level) method and the TRSC (Trend of Risk Scale Change) method). The indicators of the baseline methods are derived from the paper, and the indicators of the present application method are derived from the experimental results.

[0077] Table 2 Comparison of performance of different methods in risk judgment task As can be seen from the table, the AUC performance index of the present method is 0.93, which is the best. Although the result of the VGRL method at a prediction time of 1 second is comparable, the present method has a prediction time twice that of the VGRL method (the longer the prediction time, the more difficult the prediction). In summary, the comparison of AUC indicators reflects the advantages of the present method.

[0078] The above description is only a description of the preferred embodiments of the present application, and does not limit the scope of the present application in any way. Any modification or modification made by any person skilled in the art based on the above disclosed technical content should be regarded as an equivalent effective embodiment, and belongs to the scope of protection of the technical scheme of the present application.

Claims

1. A fine-grained multi-task driving risk prediction method fused with trajectory prediction auxiliary tasks, characterized in that, The method comprises the following steps: Step 1: automatically labeling risk labels based on trajectory data; Collect trajectory data, calculate the modified time to collision (MTTC) risk index, identify risk scenarios according to the MTTC index, and label risk labels; Step 2: design of the main task of risk prediction; The main task of risk prediction is used to predict whether there is a potential risk event after n seconds in the future in the current scene; input the trajectory data, first extract the spatio-temporal behavior representation of the target vehicle and its surrounding environment by the encoder module, and then predict the probability of the existence of risk of the input sample by the risk prediction main task network; Step 3: design of the auxiliary task of trajectory prediction; The trajectory prediction auxiliary task is an auxiliary task in the multi-task framework, which shares the encoder structure with the main task of risk prediction; the trajectory prediction auxiliary task network takes the vehicle feature representation output by the encoder as input, combines the position information of the trajectory center point, predicts the future trajectory coordinate sequence, and participates in joint training in the total loss function with a dynamic weight; Step 4: construction and training of the driving risk prediction model; Construct the driving risk prediction model framework, including the main task of risk judgment and the auxiliary task of trajectory prediction; the model loss function considers the losses of the main task and the auxiliary task, and adopts a dynamic weight average mechanism to adaptively adjust the loss weight of the main task and the auxiliary task; iteratively train until the loss converges; In the inference stage, the trained driving risk prediction model is used to predict the risk of the input trajectory data.

2. The method according to claim 1, wherein the fusion trajectory prediction auxiliary task is a fine-grained multi-task driving risk prediction method. Step 1 is as follows: Step 1.1: Calculate the modified TTC risk index; Calculate the modified time to collision (TTC) risk index as follows: Let the longitudinal position of the preceding vehicle be , the speed ; the following vehicle position , the speed , take the positive direction along the direction of travel, and ; under the assumption that the speed of the two vehicles remains constant, the longitudinal collision time TTC is as follows: A longitudinal acceleration correction is introduced into TTC to form the modified TCC index MTTC; constant acceleration while following the vehicle is considered. The car in front has constant acceleration. The relative displacements of the two vehicles satisfy: to reduce the longitudinal distance between the two vehicles to a set minimum safety distance the minimum positive real root is the MTTC: When a potential conflict event is determined, wherein is a predetermined threshold value; Step 1.2: automatically identify scene risks; The last L frames of the MTTC set before time t are taken: If the set element satisfies: then define the scenario as high risk state, assign label , otherwise record as low risk, label is ; Process the collected trajectory data, identify risk scenarios according to the MTTC index, and label risk labels.

3. The method according to claim 1, wherein the fusion trajectory prediction auxiliary task is a fine-grained multi-task driving risk prediction method. Step 2 is as follows: Step 2.1: vehicle trajectory feature extraction; Design an encoder module to extract the spatio-temporal behavior representation of the target vehicle and its surrounding environment; the encoder includes a two-stage structure: a single vehicle trajectory feature extraction network and an inter-vehicle interaction module; The model input is the trajectory tensor of all valid vehicles in the past frames where denotes the batch size, is the number of frames of historical trajectories, is the maximum number of vehicles per frame, and 2 is the trajectory data dimension; the input is first multiplied by a mask tensor to mask out missing trajectories, resulting in a valid trajectory tensor : valid vehicle trajectory data in each sample scene in Batch performing trajectory feature extraction, wherein the number of valid vehicles for the sample scene; The single vehicle trajectory feature extraction network adopts a three-layer stacked Res1D network to model the one-dimensional convolution of each vehicle's trajectory and extract local time sequence features; the outputs of each scale are fused to a unified dimension through horizontal connection, and then output the vehicle feature encoding through a residual module, as follows: wherein, is a specified vehicle representation dimension; i.e. sample scenario The representation of the valid vehicles is combined as follows: wherein, is the time sequence feature obtained after encoding the historical trajectory sequence of a single vehicle , and the center position is ; The inter-vehicle interaction module uses a double-layer attention mechanism to model the mutual influence between vehicles, and models the spatial attention of each vehicle and its adjacent vehicles. The aligned vehicle center positions are used as geometric reference, and information aggregation is performed on each pair of center positions in turn and target vehicle and surrounding vehicles . In each layer, the model constructs a context representation according to the relative position between vehicles, the query vector and the neighbor features, and updates the target vehicle features through residual connection and normalization: wherein, and respectively represent the first layer and the second layer attention aggregation module, represents the historical trajectory sequence encoding of the vehicle , represents the center position of the vehicle , , respectively represent the intermediate feature and the final interaction feature of the target vehicle after double-layer attention aggregation, represents the feature set of all neighbor vehicles within the neighborhood of the target vehicle ; The final output a feature representation of the target vehicle fusing multi-order neighbor information, as shared input for subsequent risk assessment and trajectory prediction tasks; Step 2.2: network structure design of the main task of risk prediction; The main task of risk prediction is used to predict whether there is a potential risk event after n seconds in the future in the current scene; this task not only makes judgments based on the feature representation of a single vehicle, but also introduces inter-vehicle context information through a multi-head attention mechanism to capture potential collaborative risk relationships; The input of the risk prediction main task network is the vehicle feature information obtained from the encoder, denoted as: wherein, is the number of valid target vehicles in the current input sample, is the feature dimension, the feature representation of the th target vehicle is denoted as The task first updates each target vehicle using self-attention with itself and other target vehicles, i.e.: wherein, denotes a standard multi-head attention mechanism, are the Query, Key, Value matrices of the multi-head attention mechanism, respectively, with input and output dimensions ; the updated representation is then mapped through two fully connected layers to obtain the logit values for the risk prediction as follows: In the inference stage, to obtain the probability output of the existence of risk of the sample, further Sigmoid mapping is performed: wherein, represents a Sigmoid function, are fully connected layer weights, is a bias term; Step 2.3: loss function design of the main task of risk prediction; In the training process, the risk prediction uses binary cross-entropy loss: in, It is the first Sample The true label is either 0 or 1; the true label is obtained in step 1, where 1 indicates a high-risk state and 0 indicates a low-risk state. It is the first Sample The logit value in the model output; yes The output of the sigmoid function represents the probability that the model predicts the sample to be at risk, calculated as follows: 。 4. The method of claim 1, wherein the fusion trajectory prediction auxiliary task is a fine-grained multi-task driving risk prediction method. Step 3 is as follows: Step 3.1: network structure design of the auxiliary task of trajectory prediction; The trajectory prediction auxiliary task is used to regress the trajectory position of each target vehicle within a future time window, and is constructed as a multi-time step position prediction task; The trajectory prediction auxiliary task network takes the vehicle feature representation output by the encoder as input, combines the trajectory center point position information, and predicts a sequence of future trajectory coordinates; in order to make the predicted trajectory have a multi-modal characteristic, K different predicted trajectories are generated at the same time; No. The characteristics of each target vehicle are represented as follows: The corresponding historical trajectory center point is Using K independent multilayer perceptrons to Parallel modeling outputs a sequence of relative displacements for K predicted trajectories: where, represents the predicted relative displacement sequence; adding this to the history end-frame center point yields the predicted position for each trajectory: Step 3.2 Loss function design of trajectory prediction auxiliary task; In the training phase, the model first computes the average Euclidean distance of all predicted trajectories to the true trajectory and selects the trajectory with the smallest error as the optimal mode, denoted as ; only for this trajectory, the smooth L1 loss is calculated as the regression loss term: wherein, represents the number of target vehicles in the current training batch; to enhance the discriminative ability of the model for multi-modal output, the classification branch simultaneously scores the confidence of all candidate trajectories; the maximum margin classification loss encourages the model to give higher scores to the optimal modality; the total loss of the final trajectory prediction task is defined as: wherein, is a loss weight balancing coefficient; wherein the max-margin classification loss is defined as follows: wherein, denotes the number of vehicles, denotes the number of modes, denotes the interval, denotes the score of the non-optimal modal trajectory of vehicle v, denotes the score of the optimal modal trajectory of vehicle m.

5. The method of claim 1, wherein the fusion trajectory prediction auxiliary task is a fine-grained multi-task driving risk prediction method. Step 4 is as follows: Step 4.1 Overall structure design of driving risk prediction model; The overall framework of the driving risk prediction model adopts an end-to-end structure, including a risk judgment main task, a trajectory prediction auxiliary task, and a shared encoder; the input historical trajectory is first extracted by the encoder to extract local time sequence features, and then an attention mechanism is introduced to model the interaction between the target vehicle and the surrounding vehicles, capturing potential dynamic influence relationships; on the shared features output by the encoder, two decoding paths are established respectively: the main task is a binary classification risk judgment, outputting an accident probability; The auxiliary task is a trajectory point regression, outputting a trajectory prediction sequence for a number of future time steps; Step 4.2 Loss function design of driving risk prediction model; In order to improve the training stability and multi-task coordination efficiency, the model loss function considers the weighted loss sum of the main and auxiliary tasks, and adopts a dynamic weight average (DWA) algorithm to adaptively adjust the loss weights of the main and auxiliary tasks, realizing a unified modeling process of feature sharing and target decoupling; wherein, , are the loss functions of the main and auxiliary tasks, respectively, and are calculated by the DWA algorithm. Step 4.3 Training of driving risk prediction model; The specific process of iterative training is as follows: (1) The input is the trajectory data of the target vehicle and its surrounding vehicles within a straight-line distance of D meters for m consecutive seconds, and the risk scene is identified according to the MTTC index, and the risk label is labeled; (2) calculating the loss function of the main task , calculating the loss function of the auxiliary task , dynamically adjusting the loss weight by using a dynamic weight average algorithm and , calculating the total loss of the model ; (3) Save the size of the risk loss and trajectory loss in this batch, and prepare for the loss weight calculation of the next batch; (4) according to updating the driving risk prediction model by back propagation parameters of the driving risk prediction model ; (5) repeat (1)-(4) until loss converges, return driving risk prediction model .

6. The method of claim 5, wherein the trajectory prediction auxiliary task is fused. The specific formula for updating the loss weights of the main and auxiliary tasks by the DWA algorithm is as follows: wherein, representing the task loss in the t-1th iteration the ratio of the loss in the t-2th iteration reflects the convergence speed of the task loss; representing the softmax normalization of is the loss weight assigned to the task i in the tth iteration; I represents the number of tasks, and T is a temperature coefficient.

Citation Information

Patent Citations

  • Intelligent vehicle risk assessment method based on vehicle trajectory prediction

    CN112258841A

  • Method for predicting short-time traffic risk of road section by utilizing roadside observation data

    CN113436432A

  • Vehicle collision risk prediction method based on trajectory data

    CN115588310A

  • Data-driven scene generation method, multi-vehicle joint trajectory generator and evaluation method

    CN117931375A

  • Interactive vehicle trajectory prediction and driving intention recognition method based on multi-task learning

    CN119293450A

Cited By

  • Vehicle track prediction and monitoring method based on discriminator implicit future interactive learning guidance

    CN121744243A

  • A vehicle trajectory prediction and monitoring method based on discriminator implicit future interaction learning guidance

    CN121744243B