Skip to content

shrenik-jain/Interaction-Aware-Motion-Prediction

Repository files navigation

Interaction-Aware Motion Prediction

Learning an interaction-aware motion predictor for autonomous driving: the model forecasts neighboring agents’ future trajectories conditioned on the ego vehicle’s candidate plans, and pairs with a sampling-based planner for collision-aware trajectory selection in SMARTS.


Overview

Component What it does
Interaction-aware predictor Predicts neighbors’ futures using ego plan + scene context (optional interaction path via --use_interaction).
Sampling-based planner Generates candidate trajectories, queries the predictor, scores comfort/safety/goal progress, selects a plan.

Decoders (same encoder stack, different recurrent / attention decoder):

Decoder Module Notes
LSTM iamp/predictors/lstm.py LSTMCell, hidden size 384
GRU iamp/predictors/gru.py GRUCell, fewer parameters than LSTM
Transformer iamp/predictors/transformer.py Attention-based decoder

Select with --decoder lstm|gru|transformer (no file renaming).

Training scenarios (rotated during training): 1_to_2lane_left_turn_c, 3lane_merge_single_agent, 3lane_overtake.

Metrics: ADE / FDE on predicted trajectories; episode success and collision in logs.


Results (Visual)

Unsignalized intersection

Unsignalized intersection demo

Merge

Merge demo

Overtake

Overtake demo


Installation

1. Prerequisites

  • Python 3.9+ (see pyproject.toml). Older SMARTS setups may use 3.7; align versions with your SMARTS install.
  • SMARTS comp-1 branch and its system dependencies (SUMO, etc.). This repo includes helper scripts; see smarts.sh.
  • GPU recommended for training (PyTorch + CUDA matching your driver).

2. Environment and dependencies

# From the repository root
python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate

# PyTorch: install the build that matches your CUDA/CPU
# https://pytorch.org/get-started/locally/

pip install -r requirements.txt
pip install -e .
  • SMARTS is installed separately (not in requirements.txt). Example:

    pip install "smarts[camera-obs] @ git+https://github.com/huawei-noah/SMARTS.git@comp-1"

    Use the project’s smarts.sh for the full clone + install flow.

  • Legacy Docker / pinned stack: source_installations.sh shows an example PyTorch 1.12.0+cu113 install and extra pins used with older environments.

3. Optional: container workflow

run.sh assumes paths like /src/code and sources start.sh, smarts.sh, and source_installations.sh. Adapt paths or run train.py / test.py directly on your machine after SMARTS is installed.


Usage

Training

python train.py --use_exploration --use_interaction --decoder lstm

Common flags:

Flag Meaning
--decoder {lstm,gru,transformer} Trajectory decoder (default: lstm)
--use_interaction Interaction-aware predictor path
--use_exploration Exploration schedule during rollouts
--name NAME Subfolder under training_log/
--epochs, --batch_size, --learning_rate Training hyperparameters
--device cuda Device (default cuda)
--envision_gui, --sumo_gui GUIs (off by default)

Evaluation

Use the same --decoder as training and point to your checkpoint:

python test.py \
  --model_path models/transformer_1500epochs_predictor_0.6500.pth \
  --use_interaction \
  --decoder transformer \
  --name Test1
Flag Meaning
--model_path Path to .pth checkpoint
--decoder Must match the trained architecture
--episodes Number of test episodes per scenario

Script driver

Edit run.sh to switch between the train.py and test.py lines as needed.


References

About

Interaction Aware Motion Prediction For Traffic Systems

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors