src.model.new_model module#
- class src.model.new_model.NewModel(*args: Any, **kwargs: Any)[source]#
Bases:
RelativeModelRevised model variant.
Inherits from RelativeModel. The main changes are: - the pedestrian feature encoder (ped_encoder) uses a residual connection - local environment features (sur_info) are injected directly into the
initial embedding instead of being fused later
- __init__(args)[source]#
Initialize model layers and embedding modules.
- Parameters:
args (Namespace) – Configuration object containing the standard model hyperparameters.
- set_ped_embedding(pos: torch.FloatTensor, vel: torch.FloatTensor, hst: torch.FloatTensor, des: torch.FloatTensor, spd: torch.FloatTensor)[source]#
Compute and store the joint pedestrian embedding.
Position, velocity, history, destination, and desired speed are mapped into a shared feature space and summed into the initial pedestrian representation.
Absolute position is not used directly. Instead, pos is encoded with FourierPositionalEncoding.
- Parameters:
pos (torch.FloatTensor) – Current pedestrian coordinates (x, y). Shape: (batch_size, num_peds, 2)
vel (torch.FloatTensor) – Current pedestrian velocity (vx, vy). Shape: (batch_size, num_peds, 2)
hst (torch.FloatTensor) – Pedestrian history trajectory sequence. Shape: (batch_size, num_peds, hist_step, 2)
des (torch.FloatTensor) – Pedestrian destination coordinates. Shape: (batch_size, num_peds, 2)
spd (torch.FloatTensor) – Pedestrian desired speed scalar. Shape: (batch_size, num_peds, 1)
- Side Effects:
Sets self.ped_embedding: fused pedestrian features. Sets self.pos: cached current positions for later map indexing. Sets self.pe: positional encoding features.
- set_sur_info()[source]#
Extract local environment features at each pedestrian’s current position.
Maps pedestrian world coordinates in self.pos to raster-map indices and retrieves the corresponding vectors from the dense map embedding.
- Side Effects:
Sets self.sur_info: environmental features under each pedestrian.
- forward(denoise_t: torch.LongTensor, noisy_acc: torch.FloatTensor, ped_length: torch.LongTensor, veh_length: torch.LongTensor, timer: NamedTimer | None = None)[source]#
Forward pass: predict denoised trajectories from noisy inputs.
This method must be called after the set_*_embedding methods. It fuses diffusion timestep, noisy acceleration, social interaction, pedestrian-vehicle interaction, and environment interaction.
- Parameters:
denoise_t (torch.LongTensor) – Current diffusion timestep t. Shape: (batch_size,)
noisy_acc (torch.FloatTensor) – Noisy future acceleration sequence, the diffusion input x_t. Shape: (batch_size, num_peds, pred_step, 2)
ped_length (torch.LongTensor) – Number of valid pedestrians per sample, used for masking. Shape: (batch_size,)
veh_length (torch.LongTensor) – Number of valid vehicles per sample, used for masking. Shape: (batch_size,)
timer (NamedTimer, optional) – Timer object for performance profiling.
- Returns:
- Model prediction.
If args.predict_noise is True, this is the predicted noise epsilon; otherwise it is the predicted original signal x_0 in acceleration space. Shape: (batch_size, num_peds, pred_step, 2)
- Return type:
torch.FloatTensor