Git Product home page Git Product logo

gameformer's Introduction

GameFormer

This repository contains the code for the ICCV'23 paper:

GameFormer: Game-theoretic Modeling and Learning of Transformer-based Interactive Prediction and Planning for Autonomous Driving
Zhiyu Huang, Haochen Liu, Chen Lv
AutoMan Research Lab, Nanyang Technological University
[Paper] [arXiv] [Project Website]

Overview

In this repository, you can expect to find the following features:

Included 🤟:

  • Code for interaction prediction using a joint model on Waymo Open Motion Dataset (WOMD)
  • Code for open-loop planning on selected dynamic scenarios within WOMD

Not included 😵:

  • Code for the marginal model with EM ensemble for interaction prediction on WOMD
  • Code for closed-loop planning on WOMD. Please refer to our previous work DIPP for that.
  • Code for packaging and submitting prediction results to the WOMD Interaction Prediction Challenge

For those interested in the nuPlan dataset experimentation, we invite you to visit the GameFormer Planner repository, which provides a more comprehensive planning framework.

Dataset and Environment

1. Download

  • Download the Waymo Open Motion Dataset v1.1. Utilize data from scenario/training_20s or scenario/training for training, and data from scenario/validation and scenario/validation_interactive for testing.
  • Clone this repository and navigate to the directory:
git clone https://github.com/MCZhi/GameFormer.git && cd GameFormer

2. Environment Setup

  • Create a conda environment:
conda create -n gameformer python=3.8
  • Activate the conda environment:
conda activate gameformer
  • Install the required packages:
pip install -r requirements.txt

Interaction Prediction

Navigate to the interaction_prediction directory:

cd interaction_prediction

1. Data Process

NOTE: there might be some missing annoation issues in using training_20s as train set, so please download scenario/training instead. Preprocess data for model training using the following command:

python data_process.py \
--load_path path/to/your/dataset/scenario/set_path \
--save_path path/to/your/processed_data/set_path \
--use_multiprocessing \
--processes=8

Specify --load_path to the location of the downloaded set path, --save_path to the desired processed data path, and enable --use_multiprocessing for parallel data processing. You can perform this separately for the training and validation_interactive sets.

2. Training & Evaluation

Train the model using the command:

bash train.sh 4 #number of GPUs

NOTE: Before training, specify the processed paths for --train_set and --valid_set inside the script file. Set --name to save logs and checkpoints. As referred in train.py, you can also adjust other arguments like --seed, --train_epochs, --batch_size for customed training.

Open-loop Planning

Navigate to the open_loop_planning directory:

cd open_loop_planning

1. Data Process

Preprocess data for model training using the following command:

python data_process.py \
--load_path path/to/your/dataset/training_20s \
--save_path path/to/your/processed_data \
--use_multiprocessing \

Set --load_path to the location of the downloaded dataset, --save_path to the desired processed data path, and enable --use_multiprocessing for parallel data processing. You can perform this separately for the training and validation sets.

2. Training

Train the model using the command:

python train.py \
--train_set path/to/your/processed_data/train \
--valid_set path/to/your/processed_data/valid

Specify the paths for --train_set and --valid_set. You can set the --levels to determine the number of interaction levels. Adjust other parameters like --seed, --train_epochs, --batch_size, and --learning_rate as needed for training.

The training log and models will be saved in training_log/{name}.

3. Testing

For testing, run:

python open_loop_test.py \
--test_set path/to/your/dataset/validation \
--model_path path/to/your/saved/model

Specify --test_set as the path to the scenario/validation data, and --model_path as the path to your trained model. Use --render to visualize planning and prediction results.

The testing result will be saved in testing_log/{name}.

Citation

If you find this repository useful for your research, please consider giving us a star 🌟 and citing our paper.

@InProceedings{Huang_2023_ICCV,
    author    = {Huang, Zhiyu and Liu, Haochen and Lv, Chen},
    title     = {GameFormer: Game-theoretic Modeling and Learning of Transformer-based Interactive Prediction and Planning for Autonomous Driving},
    booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
    month     = {October},
    year      = {2023},
    pages     = {3903-3913}
}

gameformer's People

Contributors

georgeliu233 avatar mczhi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gameformer's Issues

does refline use the future information of ego

It seems that the calculation of refline use the future information of ego traj. In this function “find_route”:

def find_route(traj, timestep, cur_pos, map_lanes, map_signals):
    lane_polylines = get_polylines(map_lanes)
    end_lane, end_point = find_map_waypoint(np.array((traj[-1].center_x, traj[-1].center_y, traj[-1].heading)), lane_polylines)
    cur_lane, _ = find_map_waypoint(cur_pos, lane_polylines)
    
    path_waypoints = []
    for t in range(0, len(traj), 10):
        lane, point = find_map_waypoint(np.array((traj[t].center_x, traj[t].center_y, traj[t].heading)), lane_polylines)
        path_waypoints.append(lane_polylines[lane][point])

    after_waypoints = []
    for waypoint in lane_polylines[end_lane][end_point:]:
        after_waypoints.append(waypoint)
    if len(after_waypoints) < 100:
        if map_lanes[end_lane].exit_lanes:
            lane = map_lanes[end_lane].exit_lanes[0]
            for waypoint in lane_polylines[lane]:
                after_waypoints.append(waypoint)

    waypoints = np.concatenate([path_waypoints, after_waypoints[::5]], axis=0)

    # generate smooth route
    tx, ty, tyaw, tc, _ = generate_target_course(waypoints[:, 0], waypoints[:, 1])
    ref_line = np.column_stack([tx, ty, tyaw, tc])
    
    # get reference path at current timestep
    current_location = np.argmin(np.linalg.norm(ref_line[:, :2] - cur_pos[np.newaxis, :2], axis=-1))
    start_index = np.max([current_location, 0])
    ref_line = ref_line[start_index:start_index+1000]

    # add speed limit and traffic signal info to ref route
    line_info = np.zeros(shape=(ref_line.shape[0], 1))
    speed_limit = map_lanes[cur_lane].speed_limit_mph / 2.237
    ref_line = np.concatenate([ref_line, line_info], axis=-1)
    signals = [Point([signal.stop_point.x, signal.stop_point.y]) for signal in map_signals[timestep].lane_states if signal.state in [1, 4, 7]]

    for i in range(ref_line.shape[0]):
        if any([Point(ref_line[i, :2]).distance(signal) < 0.2 for signal in signals]):
            ref_line[i, 4] = 0 # red light
        else:
            ref_line[i, 4] = speed_limit

    return ref_line
    

For the calculation of variable "path_waypoints", it seem that the future traj of ego is included.

Encoding object_type in Class AgentEncoder

There may be a problem with encoding the object type in the Class AgentEncoder.
You are using

type = self.type_emb(inputs[:, -1, 8].int())

And since object_type is one hot vector, I think the vector should be transformed into an integer first as:

object_type = (inputs[:, -1, 8:].argmax(dim=-1)+1)* inputs[:, -1, 8:].sum(dim=-1).int() type = self.type_emb(object_type)

Question about the joint prediction

Thank you for your amazing work about the interactive prediction and planning!

I have a detail I'd like to consult about joint prediction.
In joint prediction, is the probability of the final output scene-level, i.e. it has a dimension of 1 * num_mode?
Are joint predictions made in the same way as in DIPP?

I have this question because in The gameformer planner paper, you mentioned that "The model also provides probabilities associated with the different modes of each agent’s trajectory, resulting in tensors of shape N ×6. ", which confuses me a bit, seems to mean that each agent has a different probability output instead of dimension of 1×6.

Or could you please provide the code for the core model of Gameformer? My email is [email protected]. Thanks a lot!

Data processing of training_20s

I am very interested in your work and have similar thoughts. When running your code, in the data processing stage, there is a problem with training_20s, it cannot process the results.

for int_id in objects_of_interest:
interact_list.append(id_list[int_id])

An error will be reported in this command, and id_list is empty.

Please Release Code

Hello MCZhi,
I appreciate your work and had similar ideas as yours, so I got very interesed in your work. I can't wait to see what you actually do in this code. I would be very appreciative if you could release the code soon.

ERROR: waymo-open-dataset-tf-2-11-0

Hello! I came across your paper and found it to be excellent – truly impressive and intriguing. If I can build on your work to achieve results, I will certainly cite your paper. However, I've encountered a problem at the moment: the installation of waymo-open-dataset-tf-2-11-0 is not successful. I'm getting the following error message:ERROR: Could not find a version that satisfies the requirement waymo-open-dataset-tf-2-11-0 (from versions: none)
ERROR: No matching distribution found for waymo-open-dataset-tf-2-11-0
I'm curious to know if this project is only compatible with Linux systems. I appreciate your response!Best regards.

arxiv link incorrect

Hey!

Thanks for quite interesting work, I was going through the project website and its quite appealing. I am not sure if you already have preprint available, but currently the arxiv link is point to old paper.

Hope you have a nice week!

Hyperparameters of the best interaction prediction model

What are the hyperparameters used for the best model on the Waymo Interaction Prediction challenge?
The one reported to have a minADE of 0.9161.

There are some discrepancies between the default code values and the ones reported in the paper appendix.
For example, do you consider 20 or 32 neighbors in the preprocessing code for the best results?

Also if you can share the model weights that would be very useful. Thanks :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.