-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add nuScenes (lidar only) support (#6)
* Add nuScenes (lidar only) support * fix existing tests * bugfixes for loader * Basic docs --------- Co-authored-by: Kyle Vedder <kyle.c.vedder@gmail.com>
- Loading branch information
1 parent
965d924
commit 6d9fea5
Showing
20 changed files
with
1,260 additions
and
84 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
from .nuscenes_loader import NuScenesLoader, NuScenesSequence | ||
from .nuscenes_raw_data import ( | ||
NuScenesRawSequence, | ||
NuScenesRawSequenceLoader, | ||
) | ||
from .nuscenes_scene_flow import ( | ||
NuScenesNoFlowSequence, | ||
NuScenesNoFlowSequenceLoader, | ||
NuScenesSceneFlowSequence, | ||
NuScenesSceneFlowSequenceLoader | ||
) | ||
from .dataset import NuScenesCausalSceneFlow, NuScenesNonCausalSceneFlow | ||
|
||
__all__ = [ | ||
"NuScenesCausalSceneFlow", | ||
"NuScenesNonCausalSceneFlow", | ||
"NuScenesNoFlowSequence", | ||
"NuScenesNoFlowSequenceLoader", | ||
"NuScenesRawSequence", | ||
"NuScenesRawSequenceLoader", | ||
"NuScenesSceneFlowSequence", | ||
"NuScenesSceneFlowSequenceLoader", | ||
] |
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,134 @@ | ||
import copy | ||
from pathlib import Path | ||
from typing import Optional, Union | ||
|
||
from bucketed_scene_flow_eval.datastructures import * | ||
from bucketed_scene_flow_eval.eval import ( | ||
BucketedEPEEvaluator, | ||
Evaluator, | ||
ThreeWayEPEEvaluator, | ||
) | ||
from bucketed_scene_flow_eval.interfaces import ( | ||
CausalSeqLoaderDataset, | ||
EvalType, | ||
NonCausalSeqLoaderDataset, | ||
) | ||
|
||
from bucketed_scene_flow_eval.datasets.argoverse2.argoverse_raw_data import DEFAULT_POINT_CLOUD_RANGE, PointCloudRange | ||
from .nuscenes_scene_flow import ( | ||
CATEGORY_MAP, | ||
NuScenesNoFlowSequenceLoader, | ||
NuScenesSceneFlowSequenceLoader, | ||
) | ||
from .nuscenes_metacategories import BUCKETED_METACATAGORIES, THREEWAY_EPE_METACATAGORIES | ||
|
||
|
||
def _make_evaluator(eval_type: EvalType, eval_args: dict) -> Evaluator: | ||
eval_args_copy = copy.deepcopy(eval_args) | ||
# Builds the evaluator object for this dataset. | ||
if eval_type == EvalType.BUCKETED_EPE: | ||
if "meta_class_lookup" not in eval_args_copy: | ||
eval_args_copy["meta_class_lookup"] = BUCKETED_METACATAGORIES | ||
if "class_id_to_name" not in eval_args_copy: | ||
eval_args_copy["class_id_to_name"] = CATEGORY_MAP | ||
return BucketedEPEEvaluator(**eval_args_copy) | ||
elif eval_type == EvalType.THREEWAY_EPE: | ||
if "meta_class_lookup" not in eval_args_copy: | ||
eval_args_copy["meta_class_lookup"] = THREEWAY_EPE_METACATAGORIES | ||
if "class_id_to_name" not in eval_args_copy: | ||
eval_args_copy["class_id_to_name"] = CATEGORY_MAP | ||
return ThreeWayEPEEvaluator(**eval_args_copy) | ||
else: | ||
raise ValueError(f"Unknown eval type {eval_type}") | ||
|
||
|
||
class NuScenesCausalSceneFlow(CausalSeqLoaderDataset): | ||
def __init__( | ||
self, | ||
root_dir: Union[Path, list[Path]], | ||
nuscenes_version: str, | ||
subsequence_length: int = 2, | ||
with_ground: bool = True, | ||
with_rgb: bool = False, | ||
cache_root: Path = Path("/tmp/"), | ||
use_gt_flow: bool = True, | ||
flow_data_path: Optional[Union[Path, list[Path]]] = None, | ||
eval_type: str = "bucketed_epe", | ||
eval_args=dict(), | ||
expected_camera_shape: tuple[int, int, int] = (1550, 2048, 3), | ||
point_cloud_range: Optional[PointCloudRange] = DEFAULT_POINT_CLOUD_RANGE, | ||
use_cache=True, | ||
load_flow: bool = True, | ||
) -> None: | ||
if load_flow: | ||
self.sequence_loader = NuScenesSceneFlowSequenceLoader( | ||
raw_data_path=root_dir, | ||
nuscenes_version=nuscenes_version, | ||
with_rgb=with_rgb, | ||
use_gt_flow=use_gt_flow, | ||
flow_data_path=flow_data_path, | ||
expected_camera_shape=expected_camera_shape, | ||
point_cloud_range=point_cloud_range, | ||
) | ||
else: | ||
self.sequence_loader = NuScenesNoFlowSequenceLoader( | ||
raw_data_path=root_dir, | ||
nuscenes_version=nuscenes_version, | ||
with_rgb=with_rgb, | ||
expected_camera_shape=expected_camera_shape, | ||
point_cloud_range=point_cloud_range, | ||
) | ||
super().__init__( | ||
sequence_loader=self.sequence_loader, | ||
subsequence_length=subsequence_length, | ||
with_ground=with_ground, | ||
idx_lookup_cache_root=cache_root, | ||
eval_type=eval_type, | ||
eval_args=eval_args, | ||
use_cache=use_cache, | ||
) | ||
|
||
def evaluator(self) -> Evaluator: | ||
return _make_evaluator(self.eval_type, self.eval_args) | ||
|
||
|
||
class NuScenesNonCausalSceneFlow(NonCausalSeqLoaderDataset): | ||
def __init__( | ||
self, | ||
root_dir: Union[Path, list[Path]], | ||
subsequence_length: int = 2, | ||
with_ground: bool = True, | ||
with_rgb: bool = False, | ||
cache_root: Path = Path("/tmp/"), | ||
use_gt_flow: bool = True, | ||
flow_data_path: Optional[Union[Path, list[Path]]] = None, | ||
eval_type: str = "bucketed_epe", | ||
eval_args=dict(), | ||
expected_camera_shape: tuple[int, int, int] = (1550, 2048, 3), | ||
use_cache=True, | ||
load_flow: bool = True, | ||
) -> None: | ||
if load_flow: | ||
self.sequence_loader = NuScenesSceneFlowSequenceLoader( | ||
root_dir, | ||
with_rgb=with_rgb, | ||
use_gt_flow=use_gt_flow, | ||
flow_data_path=flow_data_path, | ||
expected_camera_shape=expected_camera_shape, | ||
) | ||
else: | ||
self.sequence_loader = NuScenesNoFlowSequenceLoader( | ||
root_dir, with_rgb=with_rgb, expected_camera_shape=expected_camera_shape | ||
) | ||
super().__init__( | ||
sequence_loader=self.sequence_loader, | ||
subsequence_length=subsequence_length, | ||
with_ground=with_ground, | ||
idx_lookup_cache_root=cache_root, | ||
eval_type=eval_type, | ||
eval_args=eval_args, | ||
use_cache=use_cache, | ||
) | ||
|
||
def evaluator(self) -> Evaluator: | ||
return _make_evaluator(self.eval_type, self.eval_args) |
48 changes: 48 additions & 0 deletions
48
bucketed_scene_flow_eval/datasets/nuscenes/nuscenes_metacategories.py
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,48 @@ | ||
BACKGROUND_CATEGORIES = ["background"] | ||
|
||
# These catagories are ignored because of labeling oddities | ||
STATIC_OBJECTS = [ | ||
"movable_object.barrier", | ||
"movable_object.debris", | ||
"movable_object.pushable_pullable", | ||
"movable_object.trafficcone", | ||
"static_object.bicycle_rack", | ||
] | ||
|
||
PEDESTRIAN_CATEGORIES = [ | ||
"animal", | ||
"human.pedestrian.adult", | ||
"human.pedestrian.child", | ||
"human.pedestrian.construction_worker", | ||
"human.pedestrian.personal_mobility", | ||
"human.pedestrian.police_officer", | ||
"human.pedestrian.stroller", | ||
"human.pedestrian.wheelchair", | ||
] | ||
|
||
WHEELED_VRU = ["vehicle.bicycle", "vehicle.motorcycle"] | ||
|
||
CAR = ["vehicle.car"] | ||
|
||
OTHER_VEHICLES = [ | ||
"vehicle.bus.bendy", | ||
"vehicle.bus.rigid", | ||
"vehicle.construction", | ||
"vehicle.emergency.ambulance", | ||
"vehicle.emergency.police", | ||
"vehicle.trailer", | ||
"vehicle.truck", | ||
] | ||
|
||
BUCKETED_METACATAGORIES = { | ||
"BACKGROUND": BACKGROUND_CATEGORIES, | ||
"CAR": CAR, | ||
"PEDESTRIAN": PEDESTRIAN_CATEGORIES, | ||
"WHEELED_VRU": WHEELED_VRU, | ||
"OTHER_VEHICLES": OTHER_VEHICLES, | ||
} | ||
|
||
THREEWAY_EPE_METACATAGORIES = { | ||
"BACKGROUND": BACKGROUND_CATEGORIES, | ||
"FOREGROUND": PEDESTRIAN_CATEGORIES + WHEELED_VRU + CAR + OTHER_VEHICLES, | ||
} |
Oops, something went wrong.