2023-05-13 15:15:31 +01:00
|
|
|
import pkg_resources # for suppress warning
|
2023-05-08 13:26:41 +01:00
|
|
|
import argparse
|
2023-05-06 20:33:47 +01:00
|
|
|
import logging
|
2023-05-06 14:12:10 +01:00
|
|
|
import os
|
2023-05-08 13:26:41 +01:00
|
|
|
|
2023-05-13 15:15:31 +01:00
|
|
|
from scenarionet import SCENARIONET_DATASET_PATH, SCENARIONET_REPO_PATH
|
2023-05-06 20:33:47 +01:00
|
|
|
from scenarionet.converter.utils import write_to_directory
|
|
|
|
|
from scenarionet.converter.waymo.utils import convert_waymo_scenario, get_waymo_scenarios
|
2023-05-06 14:12:10 +01:00
|
|
|
|
2023-05-06 20:33:47 +01:00
|
|
|
logger = logging.getLogger(__name__)
|
2023-05-06 14:12:10 +01:00
|
|
|
|
2023-05-06 20:33:47 +01:00
|
|
|
if __name__ == '__main__':
|
2023-05-08 13:26:41 +01:00
|
|
|
parser = argparse.ArgumentParser()
|
2023-05-08 17:15:58 +01:00
|
|
|
parser.add_argument(
|
2023-05-19 13:51:18 +01:00
|
|
|
"--database_path",
|
2023-05-13 15:15:31 +01:00
|
|
|
"-d",
|
|
|
|
|
default=os.path.join(SCENARIONET_DATASET_PATH, "waymo"),
|
|
|
|
|
help="A directory, the path to place the converted data"
|
2023-05-08 17:15:58 +01:00
|
|
|
)
|
2023-05-19 13:51:18 +01:00
|
|
|
parser.add_argument(
|
|
|
|
|
"--dataset_name", "-n", default="waymo", help="Dataset name, will be used to generate scenario files"
|
|
|
|
|
)
|
2023-05-08 17:15:58 +01:00
|
|
|
parser.add_argument("--version", "-v", default='v1.2', help="version")
|
2023-05-19 13:51:18 +01:00
|
|
|
parser.add_argument("--overwrite", action="store_true", help="If the database_path exists, whether to overwrite it")
|
2023-05-08 16:26:26 +01:00
|
|
|
parser.add_argument("--num_workers", type=int, default=8, help="number of workers to use")
|
2023-05-13 15:15:31 +01:00
|
|
|
parser.add_argument(
|
|
|
|
|
"--raw_data_path",
|
|
|
|
|
default=os.path.join(SCENARIONET_REPO_PATH, "waymo_origin"),
|
|
|
|
|
help="The directory stores all waymo tfrecord"
|
|
|
|
|
)
|
2023-05-08 13:26:41 +01:00
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
2023-05-13 15:15:31 +01:00
|
|
|
overwrite = args.overwrite
|
2023-05-08 13:26:41 +01:00
|
|
|
dataset_name = args.dataset_name
|
2023-05-19 13:51:18 +01:00
|
|
|
output_path = args.database_path
|
2023-05-08 13:26:41 +01:00
|
|
|
version = args.version
|
2023-05-06 14:12:10 +01:00
|
|
|
|
2023-05-13 15:15:31 +01:00
|
|
|
waymo_data_directory = os.path.join(SCENARIONET_DATASET_PATH, args.raw_data_path)
|
2023-05-08 13:53:57 +01:00
|
|
|
scenarios = get_waymo_scenarios(waymo_data_directory)
|
2023-05-06 14:12:10 +01:00
|
|
|
|
2023-05-06 22:10:58 +01:00
|
|
|
write_to_directory(
|
|
|
|
|
convert_func=convert_waymo_scenario,
|
|
|
|
|
scenarios=scenarios,
|
|
|
|
|
output_path=output_path,
|
|
|
|
|
dataset_version=version,
|
|
|
|
|
dataset_name=dataset_name,
|
2023-05-13 15:15:31 +01:00
|
|
|
overwrite=overwrite,
|
2023-05-08 16:26:26 +01:00
|
|
|
num_workers=args.num_workers
|
2023-05-06 22:10:58 +01:00
|
|
|
)
|