Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deepen_to_t4): add format version #106

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/convert_deepen_to_t4_sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ conversion:
input_bag_base: ./data/rosbag2
output_base: ./data/t4_format
topic_list: ./config/topic_list_sample.yaml
format_version: "1.2"
ignore_interpolate_label: True
dataset_corresponding:
Dataset_name: dataset_id_in_Deepen_AI
1 change: 1 addition & 0 deletions config/convert_deepen_to_t4_tlr_sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ conversion:
input_bag_base: ./data/rosbag2
output_base: ./data/t4_format
topic_list: ./config/topic_list_tlr.yaml
format_version: "1.2"
dataset_corresponding:
TLR_test: TyevxBgbnTplOa9A8NQXPuzp
2 changes: 2 additions & 0 deletions perception_dataset/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def main():
description = config_dict["description"]
input_bag_base = config_dict["conversion"]["input_bag_base"]
topic_list_yaml_path = config_dict["conversion"]["topic_list"]
format_version = config_dict["conversion"]["format_version"]
ignore_interpolate_label = False
if "ignore_interpolate_label" in config_dict["conversion"]:
ignore_interpolate_label = config_dict["conversion"]["ignore_interpolate_label"]
Expand All @@ -154,6 +155,7 @@ def main():
description=description,
input_bag_base=input_bag_base,
topic_list=topic_list_yaml,
format_version=format_version,
ignore_interpolate_label=ignore_interpolate_label,
)

Expand Down
8 changes: 8 additions & 0 deletions perception_dataset/deepen/deepen_to_t4_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(
description: Dict[str, Dict[str, str]],
input_bag_base: Optional[str],
topic_list: Union[Dict[str, List[str]], List[str]],
format_version: str,
t4_dataset_dir_name: str = "t4_dataset",
ignore_interpolate_label: bool = False,
):
Expand All @@ -45,6 +46,7 @@ def __init__(
self._ignore_interpolate_label: bool = ignore_interpolate_label

self._topic_list_yaml: Union[List, Dict] = topic_list
self._format_version: str = str(format_version)

def convert(self):
with open(self._input_anno_file) as f:
Expand All @@ -69,6 +71,7 @@ def convert(self):
if self._overwrite_mode or not is_dir_exist:
shutil.rmtree(output_dir, ignore_errors=True)
self._copy_data(input_dir, output_dir)
self._generate_format_version_file(output_dir)
if self._input_bag_base is not None:
self._find_start_end_time(input_dir)
self._make_rosbag(input_bag_dir, output_dir)
Expand All @@ -93,6 +96,11 @@ def convert(self):
modifier = KeyFrameConsistencyResolver()
modifier.inspect_and_fix_t4_segment(Path(output_dir))

def _generate_format_version_file(self, output_dir: str):
format_version_file_path = osp.join(output_dir, "format_version.txt")
with open(format_version_file_path, "w") as f:
f.write(self._format_version)

def _copy_data(self, input_dir: str, output_dir: str):
if input_dir != output_dir:
logger.info(f"Copying {input_dir} to {output_dir} ... ")
Expand Down
1 change: 1 addition & 0 deletions tests/config/convert_deepen_to_t4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ conversion:
input_bag_base: ./data/rosbag2
output_base: ./data/t4_format
topic_list: ./config/topic_list.yaml
format_version: "1.2"
ignore_interpolate_label: True
dataset_corresponding:
sample_bag: i3BpFG1vXknBto6q2vPZ3M1i
2 changes: 2 additions & 0 deletions tests/deepen/test_deepen_to_t4_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def converter_for_test(self):
description={},
input_bag_base="",
topic_list=[],
format_version="1.2",
ignore_interpolate_label=False,
)

Expand All @@ -165,6 +166,7 @@ def converter_for_interpolate_test(self):
description={},
input_bag_base="",
topic_list=[],
format_version="1.2",
ignore_interpolate_label=True,
)

Expand Down
Loading