-
Notifications
You must be signed in to change notification settings - Fork 62
/
load_dataset.py
63 lines (53 loc) · 1.96 KB
/
load_dataset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Copyright 2021 Toyota Research Institute. All rights reserved.
"""Simple example script to load a scene-dataset.
Usage:
$ python examples/load_dataset.py \
--scene-dataset-json tests/data/dgp/test_scene/scene_dataset_v1.0.json \
--split train
"""
import argparse
import logging
import time
from tqdm import tqdm
# Required for Parallel Domain scene metadata
import dgp.contribs.pd.metadata_pb2 # pylint: disable=unused-import
from dgp.datasets.synchronized_dataset import SynchronizedSceneDataset
def main():
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('--scene-dataset-json', type=str, required=True, help='Path to local SceneDataset JSON.')
parser.add_argument(
'--split',
type=str,
default='train',
required=False,
help='Split [train, val, test].',
choices=['train', 'val', 'test']
)
parser.add_argument( # pylint: disable=W0106
'--datum-names',
required=False,
default=['LIDAR', 'CAMERA_01'],
nargs='+',
help='Requested datum names (case-sensitive).'
),
parser.add_argument('--verbose', action='store_true')
args = parser.parse_args()
# Verbose prints.
if args.verbose:
logging.getLogger().setLevel(level=logging.INFO)
# Load the dataset and build an index into the annotations requested.
# If previously loaded/initialized, load the pre-built dataset.
st = time.time()
dataset = SynchronizedSceneDataset(
scene_dataset_json=args.scene_dataset_json,
split=args.split,
datum_names=args.datum_names,
requested_annotations=('bounding_box_3d', ),
only_annotated_datums=True
)
print('Loading dataset took {:.2f} s'.format(time.time() - st))
# Iterate through the dataset.
for _ in tqdm(dataset, desc='Loading samples from the dataset'):
pass
if __name__ == '__main__':
main()