### Install DiffusionDriveV2 Packages Source: https://github.com/hustvl/diffusiondrivev2/blob/master/docs/install.md Installs the required Python packages for DiffusionDriveV2 using pip within the NAVSIM conda environment. ```bash conda activate navsim pip install diffusers einops ``` -------------------------------- ### Initialize SceneLoader and SceneFilter Source: https://github.com/hustvl/diffusiondrivev2/blob/master/tutorial/tutorial_visualization.ipynb Sets up the environment for loading NAVSIM scenes and sensor data. Requires specifying the data split and filter configuration. ```python import os from pathlib import Path import hydra from hydra.utils import instantiate import numpy as np import matplotlib.pyplot as plt from navsim.common.dataloader import SceneLoader from navsim.common.dataclasses import SceneFilter, SensorConfig SPLIT = "mini" # ["mini", "test", "trainval"] FILTER = "all_scenes" hydra.initialize(config_path="../navsim/planning/script/config/common/scene_filter") cfg = hydra.compose(config_name=FILTER) scene_filter: SceneFilter = instantiate(cfg) openscene_data_root = Path(os.getenv("OPENSCENE_DATA_ROOT")) scene_loader = SceneLoader( openscene_data_root / f"navsim_logs/{SPLIT}", openscene_data_root / f"sensor_blobs/{SPLIT}", scene_filter, sensor_config=SensorConfig.build_all_sensors(), ) ``` -------------------------------- ### Training DiffusionDrive with Reinforcement Learning Source: https://github.com/hustvl/diffusiondrivev2/blob/master/docs/train_eval.md Initiates the training process for the DiffusionDrive RL agent. Ensure the agent checkpoint path and other parameters are correctly set. ```bash python $NAVSIM_DEVKIT_ROOT/navsim/planning/script/run_training.py \ agent=diffusiondrivev2_rl_agent \ experiment_name=training_diffusiondrivev2_rl_agent \ train_test_split=navtrain \ agent.checkpoint_path=ckpts/diffusiondrive_navsim_88p1_PDMS \ split=trainval \ trainer.params.max_epochs=10 \ cache_path="${NAVSIM_EXP_ROOT}/training_cache/" \ use_cache_without_dataset=True \ force_cache_computation=False ``` -------------------------------- ### Plot camera frames with annotations Source: https://github.com/hustvl/diffusiondrivev2/blob/master/tutorial/tutorial_visualization.ipynb Visualizes bounding-box annotations within the camera images for a specific frame. Requires `frame_idx`. ```python from navsim.visualization.plots import plot_cameras_frame_with_annotations fig, ax = plot_cameras_frame_with_annotations(scene, frame_idx) plt.show() ``` -------------------------------- ### Cache Dataset for Fast Evaluation (Optional) Source: https://github.com/hustvl/diffusiondrivev2/blob/master/docs/train_eval.md Caches the dataset for faster evaluation. This is an optional step for performance optimization. ```bash python navsim/planning/script/run_dataset_caching.py agent=diffusiondrivev2_rl_agent experiment_name=diffusiondrivev2_cache train_test_split=navtest cache_path=$NAVSIM_EXP_ROOT/metric_feature_cache ``` -------------------------------- ### Fast Evaluation of Trained Model Source: https://github.com/hustvl/diffusiondrivev2/blob/master/docs/train_eval.md Evaluates the trained DiffusionDriveV2 model rapidly using a fast PDM score script. Ensure all checkpoint and cache paths are correctly configured. ```bash python $NAVSIM_DEVKIT_ROOT/navsim/planning/script/run_pdm_score_fast.py \ agent=diffusiondrivev2_sel_agent \ experiment_name=diffusiondrivev2_agent_eval \ train_test_split=navtest \ agent.checkpoint_path=ckpts/diffusiondrivev2_sel.ckpt \ +metric_cache_path="${NAVSIM_EXP_ROOT}/metric_cache/" \ +test_cache_path="${NAVSIM_EXP_ROOT}/metric_feature_cache/" ``` -------------------------------- ### Accelerated Data Download Source: https://github.com/hustvl/diffusiondrivev2/blob/master/docs/install.md Uses a provided script to parallelize data downloads, enabling faster acquisition of necessary files. ```bash cd /path/to/DiffusionDriveV2/download bash super_download.sh ``` -------------------------------- ### Cache Dataset for Training Source: https://github.com/hustvl/diffusiondrivev2/blob/master/docs/train_eval.md Caches the dataset for training purposes. Ensure the agent and experiment names are correctly specified. ```bash python navsim/planning/script/run_dataset_caching.py agent=diffusiondrivev2_rl_agent experiment_name=diffusiondrivev2_cache train_test_split=navtrain ``` -------------------------------- ### Load a random scene Source: https://github.com/hustvl/diffusiondrivev2/blob/master/tutorial/tutorial_visualization.ipynb Selects a random scene token from the loaded scenes and retrieves the corresponding scene data. ```python token = np.random.choice(scene_loader.tokens) scene = scene_loader.get_scene_from_token(token) ``` -------------------------------- ### Cache Dataset for Evaluation Source: https://github.com/hustvl/diffusiondrivev2/blob/master/docs/train_eval.md Caches the dataset for evaluation. The cache path should point to the metric cache directory. ```bash python navsim/planning/script/run_metric_caching.py train_test_split=navtest cache.cache_path=$NAVSIM_EXP_ROOT/metric_cache ``` -------------------------------- ### Download GTRS Trajectories Source: https://github.com/hustvl/diffusiondrivev2/blob/master/docs/install.md Downloads simulated ground-truth trajectories for GTRS vocabulary, used for data augmentation in mode selector training. ```bash cd gtrs_traj wget https://huggingface.co/Zzxxxxxxxx/gtrs/resolve/main/navtrain_16384.pkl ``` -------------------------------- ### Generate GIF from Scene Frames Source: https://github.com/hustvl/diffusiondrivev2/blob/master/tutorial/tutorial_visualization.ipynb Use `frame_plot_to_gif` to create an animated GIF from a scene's frames. This function requires a file name for the output GIF, a plotting function (e.g., `plot_cameras_frame_with_annotations`), the scene object, and a list of frame indices to include. ```python from navsim.visualization.plots import frame_plot_to_gif frame_indices = [idx for idx in range(len(scene.frames))] # all frames in scene file_name = f"./{token}.gif" images = frame_plot_to_gif(file_name, plot_cameras_frame_with_annotations, scene, frame_indices) ``` -------------------------------- ### Training Mode Selector Source: https://github.com/hustvl/diffusiondrivev2/blob/master/docs/train_eval.md Trains the mode selector agent. This script requires the RL-trained DiffusionDrive model checkpoint. ```bash python $NAVSIM_DEVKIT_ROOT/navsim/planning/script/run_training.py \ agent=diffusiondrivev2_sel_agent \ experiment_name=training_diffusiondrivev2_sel_agent \ train_test_split=navtrain \ agent.checkpoint_path=ckpts/diffusiondrivev2_rl.ckpt \ split=trainval \ trainer.params.max_epochs=20 \ cache_path="${NAVSIM_EXP_ROOT}/training_cache/" \ use_cache_without_dataset=True \ force_cache_computation=False ``` -------------------------------- ### Plot camera frames with LiDAR Source: https://github.com/hustvl/diffusiondrivev2/blob/master/tutorial/tutorial_visualization.ipynb Overlays the LiDAR point cloud onto the camera images for a given frame. Requires `frame_idx`. ```python from navsim.visualization.plots import plot_cameras_frame_with_lidar fig, ax = plot_cameras_frame_with_lidar(scene, frame_idx) plt.show() ``` -------------------------------- ### Plot BEV with agent trajectory Source: https://github.com/hustvl/diffusiondrivev2/blob/master/tutorial/tutorial_visualization.ipynb Visualizes the Birds-Eye-View of the scene along with the predicted trajectory of an agent compared to the human driver. Requires an instantiated agent object. ```python from navsim.visualization.plots import plot_bev_with_agent from navsim.agents.constant_velocity_agent import ConstantVelocityAgent agent = ConstantVelocityAgent() fig, ax = plot_bev_with_agent(scene, agent) plt.show() ``` -------------------------------- ### Plot camera frames Source: https://github.com/hustvl/diffusiondrivev2/blob/master/tutorial/tutorial_visualization.ipynb Displays all eight surrounding camera views in a 3x3 grid, with the BEV plot in the center. Uses `frame_idx` to select the specific frame. ```python from navsim.visualization.plots import plot_cameras_frame fig, ax = plot_cameras_frame(scene, frame_idx) plt.show() ``` -------------------------------- ### Cache Dataset for PDMS Calculation Source: https://github.com/hustvl/diffusiondrivev2/blob/master/docs/train_eval.md Caches the dataset for calculating PDMS during training. Specify the appropriate train test split and cache path. ```bash python navsim/planning/script/run_metric_caching.py train_test_split=navtrain cache.cache_path=$NAVSIM_EXP_ROOT/train_pdm_cache ``` -------------------------------- ### Create custom BEV plot with annotations and LiDAR Source: https://github.com/hustvl/diffusiondrivev2/blob/master/tutorial/tutorial_visualization.ipynb Constructs a custom Birds-Eye-View plot by manually adding annotations and LiDAR data to a matplotlib Axes object. Utilizes helper functions for configuration. ```python from navsim.visualization.plots import configure_bev_ax from navsim.visualization.bev import add_annotations_to_bev_ax, add_lidar_to_bev_ax fig, ax = plt.subplots(1, 1, figsize=(6, 6)) ax.set_title("Custom plot") add_annotations_to_bev_ax(ax, scene.frames[frame_idx].annotations) add_lidar_to_bev_ax(ax, scene.frames[frame_idx].lidar) # configures frame to BEV view configure_bev_ax(ax) plt.show() ``` -------------------------------- ### Official Evaluation Script Source: https://github.com/hustvl/diffusiondrivev2/blob/master/docs/train_eval.md Uses the official evaluation script for evaluating the trained model. This may require uncommenting a specific line in the model's Python file. ```bash python $NAVSIM_DEVKIT_ROOT/navsim/planning/script/run_pdm_score.py \ train_test_split=navtest \ agent=diffusiondrivev2_sel_agent \ worker=ray_distributed \ agent.checkpoint_path=ckpts/diffusiondrivev2_sel.ckpt \ experiment_name=diffusiondrivev2_agent_eval ``` -------------------------------- ### Plot Birds-Eye-View (BEV) frame Source: https://github.com/hustvl/diffusiondrivev2/blob/master/tutorial/tutorial_visualization.ipynb Visualizes a single frame of the scene in a Birds-Eye-View. Use `frame_idx` to specify which historical or future frame to display. ```python from navsim.visualization.plots import plot_bev_frame frame_idx = scene.scene_metadata.num_history_frames - 1 # current frame fig, ax = plot_bev_frame(scene, frame_idx) plt.show() ``` -------------------------------- ### DiffusionDriveV2 BibTeX Citation Source: https://github.com/hustvl/diffusiondrivev2/blob/master/README.md Use this BibTeX entry to cite DiffusionDriveV2 in academic publications. Ensure your LaTeX environment supports BibTeX. ```bibtex @article{zou2025diffusiondrivev2, title={DiffusionDriveV2: Reinforcement Learning-Constrained Truncated Diffusion Modeling in End-to-End Autonomous Driving}, author={Zou, Jialv and Chen, Shaoyu and Liao, Bencheng and Zheng, Zhiyu and Song, Yuehao and Zhang, Lefei and Zhang, Qian and Liu, Wenyu and Wang, Xinggang}, journal={arXiv preprint arXiv:2512.07745}, year={2025} } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.