This repository implements VectorNet, a two-stasge Graph Neural Network for motion forecasting in autonomous driving. It covers:
- Hand-crafted feature extraction from raw Argoverse CSVs
- Construction of per-scenario graph datasets
- Local polyline GNN (“SubGraph”) + global self-attention
- End-to-end training & evaluation on Argoverse
- Visualization utilities for maps, graphs, and predictions
.
├── preprocess_data.py # orchestrates feature extraction → .pkl
├── dataset.py # builds PyG GraphDataset → .pt shards
├── modeling/
│ ├── vectornet.py # HGNN model (SubGraph + Attention + MLP)
│ ├── subgraph.py # local GNN layers & pooling
│ ├── selfatten.py # global self-attention modules
│ ├── predmlp.py # prediction MLP head
├── train.py # training & validation loop
├── utils/
│ ├── feature_utils.py # raw-to-feature functions
│ ├── lane_utils.py # lane boundary computations & featurization
│ ├── object_utils.py # moving-object feature extraction
│ ├── agent_utils.py # ego vehicle feature extraction
│ └── config.py # global settings (paths, thresholds)
├── graphs/ # example, loss, and evaluation visualization
└── README.md # this file- Clone this repo and
cdinto it:git clone https://github.com/jshon88/VectorNet.git cd VectorNet - Create environment
conda env create -f environment.yml
- Dwonload Argoverse Motion Forecasting CSVs:
# Place them under data/train/ and data/val/ (or adjust paths in config.py) - Instsall argoverse-api
-
Extract hand-crafted features -> .pkl
python preprocess_data.py
- Reads raw CSV and builds per-scenario features (agent, lanes, objects)
- Saves one .pkl per scenario for fast downstream loading
-
Build GraphDataset -> shards of dataset.pt
python dataset.py
- Loads each .pkl in manageable batches
- Wraps scenario as torch_geometric.data.GraphData
- collates into dataset_part_*.pt
python dataset.py- Graph_viz.ipynb
- Contains per scenario graph dataset visualization, sub-graph level visualization
- Plots vectorized representation of a sample scenario
- Plots vectorized representation of predicted vs ground truth of ego vehicle
- Feature extractor -> node faetures
- SubGraph (local GNN):
- 3x GraphLayerProp for Message Passing
- Gloabl self-attention (Global GNN):
- Prediction head:
- Extract ego vehicle embedding -> MLP -> prediction
See modeling/ for full implementation
- With limited computing power of my local machine, I was able to use only 0.3% of training dataset for training for 12 epochs
Paper: VectorNet: Encoding HD Maps and Agent Dynamics from Vectorized Representation
Reference Github repo source: yet-another-vectornet