Skip to content

Yuxin45/Adv-BMT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Adv-BMT: Bidirectional Motion Transformer for Safety-Critical Traffic Scenario Generation (NeurIPS 2025)

Yuxin Liu1*, Zhenghao Peng1*, Xuanhao Cui1, Bolei Zhou1
1UCLA  *Equal contribution

Adv-BMT Example Demo

Getting started

Setup environment

note: Please refer to FAQ section for any issues.

# Create virtual environment
conda create -n adv-bmt "python=3.10" -y
conda activate adv-bmt


# Install Metadrive
git clone https://github.com/metadriverse/metadrive.git
cd ~/metadrive
pip install -e .
cd ~/

# Install ScenarioNet
git clone https://github.com/metadriverse/scenarionet.git
cd ~/scenarionet
pip install -e .
cd ~/


# Clone the code to local and Install basic dependency for this project
git clone https://github.com/Yuxin45/Adv-BMT.git
pip install -e .

# Install Waymo Open Dataset
pip uninstall -y waymo-open-dataset-tf-2-11-0
pip uninstall -y waymo-open-dataset-tf-2-12-0
pip install waymo-open-dataset-tf-2-12-0==1.6.4

# Verify pytorch, expect True.
python -c "import torch;print(torch.cuda.is_available())"


# (Optional) If your torch is not installed properly.
# That is, torch.cuda.is_available() is False, then:
# Install pytorch by yourself to make them compatible with your GPU: https://pytorch.org/
# Note: First checkout which cuda you have at your 
ls /usr/local
# For cuda 11.7:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
# For cuda 11.8:
pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
# For cuda 12.1:
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia -y

Running Adv-BMT

Gradio demo

We provide a user interface for testing our method. Running the following command starts the demo.

python bmt/gradio_ui/new_ui.py --share

Generate Adv-BMT Scenarios

We provide a script for running Adv-BMT.

bash scripts/ADV-BMT_dataset_generate.sh

BMT Checkpoint and dataset

We provide 500 WOMD scenarios and our BMT checkpoint reference purposes. Link Please put your checkpoint under ./bmt/ckpt

Evaluation

We provide scripts for running scenario evaluations.

python bmt/eval/evaluate_scenario_metrics.py eval_mode={your_eval_mode}

Argument:

eval_mode meaning
SCGEN Adv-BMT generation
GPTmodel BMT with forward prediction
Backward BMT with reverse prediction
Backward_Forward BMT with bidirectional prediction
CAT or STRIVE or SEAL baseline generated scenario

RL Experiment

We provide scripts for running open-loop and closed-loop reinforcement learning.

bash bmt/rl_train/scripts/0511_CLRL_SCGEN.sh

FAQ

Q: ImportError: cannot import name 'COMMON_SAFE_ASCII_CHARACTERS' from 'charset_normalizer.constant

A:

pip install chardet

Q: AttributeError: partially initialized module 'charset_normalizer' has no attribute 'md__mypyc' (most likely due to a circular import)

A:

pip install -U --force-reinstall charset-normalizer

Q: RuntimeError: The detected CUDA version (10.1) mismatches the version that was used to compile PyTorch (11.7). Please make sure to use the same CUDA versions.

A: Try:

export CUDA_HOME=/usr/local/cuda-11.7
python setup.py develop

Q: When compiling MTR's CUDA code (e.g. python setup.py) locally: RuntimeError: The detected CUDA version (11.7) mismatches the version that was used to compile PyTorch (12.1). Please make sure to use the same CUDA versions.

A: Try:

# Download CUDA first: https://developer.nvidia.com/cuda-12-1-0-download-archive

export CUDA_HOME=/usr/local/cuda-12.1
python setup.py develop

Reference

If you use our code in your research, please cite the following work.

@misc{liu2025advbmtbidirectionalmotiontransformer,
      title={Adv-BMT: Bidirectional Motion Transformer for Safety-Critical Traffic Scenario Generation}, 
      author={Yuxin Liu and Zhenghao Peng and Xuanhao Cui and Bolei Zhou},
      year={2025},
      eprint={2506.09485},
      archivePrefix={arXiv},
      primaryClass={cs.RO},
      url={https://arxiv.org/abs/2506.09485}, 
}

You can find our paper in the NeurIPS 2025 Proceedings with the full BibTex citation here.

About

Bidirectional Motion Transformer for Safety-Critical Traffic Scenario Generation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors