-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
2425163
commit d1270b9
Showing
18 changed files
with
978 additions
and
61 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
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,51 @@ | ||
from collections import defaultdict | ||
|
||
from torch.utils.data import DataLoader | ||
from tqdm import tqdm | ||
|
||
from trajdata import AgentBatch, AgentType, UnifiedDataset | ||
from trajdata.augmentation import NoiseHistories | ||
from trajdata.visualization.vis import plot_scene_batch | ||
|
||
|
||
def main(): | ||
noise_hists = NoiseHistories() | ||
|
||
dataset = UnifiedDataset( | ||
desired_data=["nusc_mini-mini_train"], | ||
centric="scene", | ||
desired_dt=0.1, | ||
history_sec=(3.2, 3.2), | ||
future_sec=(4.8, 4.8), | ||
only_types=[AgentType.VEHICLE], | ||
agent_interaction_distances=defaultdict(lambda: 30.0), | ||
incl_robot_future=True, | ||
incl_map=True, | ||
map_params={"px_per_m": 2, "map_size_px": 224, "offset_frac_xy": (-0.5, 0.0)}, | ||
augmentations=[noise_hists], | ||
max_agent_num=20, | ||
num_workers=4, | ||
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_size=4, | ||
shuffle=True, | ||
collate_fn=dataset.get_collate_fn(), | ||
num_workers=4, | ||
persistent_workers=True, | ||
) | ||
|
||
batch: AgentBatch | ||
for batch in tqdm(dataloader): | ||
plot_scene_batch(batch, batch_idx=0) | ||
|
||
|
||
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
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 |
---|---|---|
@@ -1,18 +1,23 @@ | ||
import torch | ||
|
||
from trajdata.augmentation.augmentation import BatchAugmentation | ||
from trajdata.data_structures.batch import AgentBatch | ||
from trajdata.data_structures.batch import AgentBatch, SceneBatch | ||
|
||
|
||
class NoiseHistories(BatchAugmentation): | ||
def __init__(self, mean: float = 0.0, stddev: float = 0.1) -> None: | ||
self.mean = mean | ||
self.stddev = stddev | ||
|
||
def apply(self, agent_batch: AgentBatch) -> None: | ||
def apply_agent(self, agent_batch: AgentBatch) -> None: | ||
agent_batch.agent_hist[..., :-1, :] += torch.normal( | ||
self.mean, self.stddev, size=agent_batch.agent_hist[..., :-1, :].shape | ||
) | ||
agent_batch.neigh_hist[..., :-1, :] += torch.normal( | ||
self.mean, self.stddev, size=agent_batch.neigh_hist[..., :-1, :].shape | ||
) | ||
|
||
def apply_scene(self, scene_batch: SceneBatch) -> None: | ||
scene_batch.agent_hist[..., :-1, :] += torch.normal( | ||
self.mean, self.stddev, size=scene_batch.agent_hist[..., :-1, :].shape | ||
) |
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.