-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(non_annotated_t4_tlr_to_deepen): add conversion tool (#142)
* feat(non_annotated_t4_tlr_to_deepen): add conversion tool Signed-off-by: kminoda <[email protected]> * update version Signed-off-by: kminoda <[email protected]> * remove camera_channels Signed-off-by: kminoda <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update tests Signed-off-by: kminoda <[email protected]> * update test Signed-off-by: kminoda <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update Signed-off-by: kminoda <[email protected]> * dummy fix Signed-off-by: kminoda <[email protected]> * dummy commit Signed-off-by: kminoda <[email protected]> * update pyproject.toml Signed-off-by: kminoda <[email protected]> --------- Signed-off-by: kminoda <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
9429830
commit 0cc8566
Showing
7 changed files
with
160 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
task: convert_non_annotated_t4_tlr_to_deepen | ||
conversion: | ||
input_base: ./data/non_annotated_t4_format | ||
output_base: ./data/deepen_format |
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
55 changes: 55 additions & 0 deletions
55
perception_dataset/deepen/non_annotated_t4_tlr_to_deepen_converter.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,55 @@ | ||
import glob | ||
import os | ||
import os.path as osp | ||
from pathlib import Path | ||
import shutil | ||
import time | ||
|
||
from nuscenes.nuscenes import NuScenes | ||
|
||
from perception_dataset.abstract_converter import AbstractConverter | ||
from perception_dataset.utils.logger import configure_logger | ||
|
||
logger = configure_logger(modname=__name__) | ||
|
||
|
||
class NonAnnotatedT4TlrToDeepenConverter(AbstractConverter): | ||
def __init__( | ||
self, | ||
input_base: str, | ||
output_base: str, | ||
): | ||
super().__init__(input_base, output_base) | ||
|
||
def convert(self): | ||
start_time = time.time() | ||
|
||
for scene_dir in glob.glob(osp.join(self._input_base, "*")): | ||
if not osp.isdir(scene_dir): | ||
continue | ||
|
||
out_dir = osp.join(self._output_base, osp.basename(scene_dir).replace(".", "-")) | ||
self._convert_one_scene( | ||
scene_dir, | ||
out_dir, | ||
) | ||
shutil.make_archive(f"{out_dir}", "zip", root_dir=out_dir) | ||
|
||
elapsed_time = time.time() - start_time | ||
logger.info(f"Elapsed time: {elapsed_time:.1f} [sec]") | ||
|
||
def _convert_one_scene(self, input_dir: str, output_dir: str): | ||
os.makedirs(output_dir, exist_ok=True) | ||
nusc = NuScenes(version="annotation", dataroot=input_dir, verbose=False) | ||
|
||
logger.info(f"Converting {input_dir} to {output_dir}") | ||
for sample in nusc.sample: | ||
for sample_data_token in sample["data"].values(): | ||
# Note: This conversion tool will convert all camera data included in the t4dataset | ||
sample_data = nusc.get("sample_data", sample_data_token) | ||
original_filename = sample_data["filename"] | ||
input_path: Path = Path(input_dir) / original_filename | ||
output_path: Path = Path(output_dir) / original_filename.replace("/", "_") | ||
shutil.copy(input_path, output_path) | ||
|
||
logger.info(f"Done Conversion: {input_dir} to {output_dir}") |
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 @@ | ||
[tool.poetry] | ||
name = "perception-dataset" | ||
version = "1.0.13" | ||
version = "1.0.14" | ||
description = "TIER IV Perception dataset has modules to convert dataset from rosbag to t4_dataset" | ||
authors = [ | ||
"Yusuke Muramatsu <[email protected]>", | ||
|
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,4 @@ | ||
task: convert_non_annotated_t4_to_deepen | ||
conversion: | ||
input_base: ./data/non_annotated_t4_format | ||
output_base: ./data/deepen_format |
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