-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interactive visualizations with Bokeh (+ Animations), the SceneTimeBa…
…tcher, and bugfixes.
- Loading branch information
1 parent
34048dc
commit 5a0567b
Showing
16 changed files
with
1,775 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from collections import defaultdict | ||
|
||
from torch.utils.data import DataLoader | ||
from tqdm import tqdm | ||
|
||
from trajdata import AgentBatch, AgentType, UnifiedDataset | ||
from trajdata.utils.batch_utils import SceneTimeBatcher | ||
from trajdata.visualization.vis import plot_agent_batch_all | ||
|
||
|
||
def main(): | ||
""" | ||
Here, we use SceneTimeBatcher to loop through an | ||
Agent-centric dataset with batches grouped by scene and timestep | ||
""" | ||
dataset = UnifiedDataset( | ||
desired_data=["nusc_mini-mini_train"], | ||
centric="agent", | ||
desired_dt=0.1, | ||
history_sec=(3.2, 3.2), | ||
future_sec=(4.8, 4.8), | ||
only_predict=[AgentType.VEHICLE], | ||
agent_interaction_distances=defaultdict(lambda: 30.0), | ||
incl_robot_future=False, | ||
incl_raster_map=True, | ||
raster_map_params={ | ||
"px_per_m": 2, | ||
"map_size_px": 224, | ||
"offset_frac_xy": (-0.5, 0.0), | ||
}, | ||
num_workers=0, | ||
verbose=True, | ||
data_dirs={ # Remember to change this to match your filesystem! | ||
"nusc_mini": "~/datasets/nuScenes", | ||
}, | ||
) | ||
|
||
print(f"# Data Samples: {len(dataset):,}") | ||
|
||
dataloader = DataLoader( | ||
dataset, | ||
batch_sampler=SceneTimeBatcher(dataset), | ||
collate_fn=dataset.get_collate_fn(), | ||
num_workers=4, | ||
) | ||
|
||
batch: AgentBatch | ||
for batch in tqdm(dataloader): | ||
plot_agent_batch_all(batch) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from collections import defaultdict | ||
|
||
from torch.utils.data import DataLoader | ||
from tqdm import tqdm | ||
|
||
from trajdata import AgentBatch, AgentType, UnifiedDataset | ||
from trajdata.visualization.interactive_animation import ( | ||
InteractiveAnimation, | ||
animate_agent_batch_interactive, | ||
) | ||
from trajdata.visualization.interactive_vis import plot_agent_batch_interactive | ||
from trajdata.visualization.vis import plot_agent_batch | ||
|
||
|
||
def main(): | ||
dataset = UnifiedDataset( | ||
desired_data=["nusc_mini"], | ||
centric="agent", | ||
desired_dt=0.1, | ||
# history_sec=(3.2, 3.2), | ||
# future_sec=(4.8, 4.8), | ||
only_predict=[AgentType.VEHICLE], | ||
state_format="x,y,z,xd,yd,h", | ||
obs_format="x,y,z,xd,yd,s,c", | ||
# agent_interaction_distances=defaultdict(lambda: 30.0), | ||
incl_robot_future=False, | ||
incl_raster_map=True, | ||
raster_map_params={ | ||
"px_per_m": 2, | ||
"map_size_px": 224, | ||
"offset_frac_xy": (-0.5, 0.0), | ||
}, | ||
num_workers=4, | ||
verbose=True, | ||
data_dirs={ # Remember to change this to match your filesystem! | ||
"nusc_mini": "~/datasets/nuScenes", | ||
"lyft_sample": "~/datasets/lyft/scenes/sample.zarr", | ||
"nuplan_mini": "~/datasets/nuplan/dataset/nuplan-v1.1", | ||
}, | ||
) | ||
|
||
print(f"# Data Samples: {len(dataset):,}") | ||
|
||
dataloader = DataLoader( | ||
dataset, | ||
batch_size=4, | ||
shuffle=True, | ||
collate_fn=dataset.get_collate_fn(), | ||
num_workers=0, | ||
) | ||
|
||
batch: AgentBatch | ||
for batch in tqdm(dataloader): | ||
plot_agent_batch_interactive(batch, batch_idx=0, cache_path=dataset.cache_path) | ||
plot_agent_batch(batch, batch_idx=0) | ||
|
||
animation = InteractiveAnimation( | ||
animate_agent_batch_interactive, | ||
batch=batch, | ||
batch_idx=0, | ||
cache_path=dataset.cache_path, | ||
) | ||
animation.show() | ||
# break | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ pyarrow | |
torch | ||
zarr | ||
kornia | ||
bokeh | ||
|
||
# nuScenes devkit | ||
nuscenes-devkit==1.1.9 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[metadata] | ||
name = trajdata | ||
version = 1.2.1 | ||
version = 1.3.0 | ||
author = Boris Ivanovic | ||
author_email = [email protected] | ||
description = A unified interface to many trajectory forecasting datasets. | ||
|
@@ -30,6 +30,7 @@ install_requires = | |
zarr>=2.11.0 | ||
kornia>=0.6.4 | ||
seaborn>=0.12 | ||
bokeh>=3.0.3 | ||
|
||
[options.packages.find] | ||
where = src | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.