Skip to content

Commit 9a3154b

Browse files
committed
new files
2 parents b5bc270 + 0752cbf commit 9a3154b

File tree

10 files changed

+329
-19
lines changed

10 files changed

+329
-19
lines changed

.commitlintrc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extends:
2+
- '@commitlint/config-conventional'
3+
rules:
4+
type-enum: [2, 'always', ['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'refactor', 'revert', 'perf', 'schema', 'style', 'test']]

.github/workflows/pre-merge.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ on:
33
push:
44
branches:
55
- master
6+
- agent
67
pull_request:
78
branches:
89
- master
10+
- agent
911

1012
jobs:
1113
pre-merge-tests:
@@ -17,6 +19,8 @@ jobs:
1719
- name: Lint commit message with commitlint
1820
# Documentation: https://github.com/wagoid/commitlint-github-action
1921
uses: wagoid/commitlint-github-action@v4
22+
with:
23+
configFile: .commitlintrc.yml
2024
- name: Install Python 3.6
2125
uses: actions/setup-python@v1
2226
with:
@@ -45,6 +49,7 @@ jobs:
4549
VALIDATE_ALL_CODEBASE: false # Only new or edited files will be parsed for validation.
4650
VALIDATE_DOCKERFILE_HADOLINT: false
4751
VALIDATE_JSCPD: false
52+
VALIDATE_PROTOBUF: false
4853
VALIDATE_PYTHON_BLACK: false
4954
VALIDATE_PYTHON_FLAKE8: false # Formatted by YAPF.
5055
VALIDATE_PYTHON_ISORT: false # Formatted by YAPF.

dgp/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
# String identifiers for feature types
3636
ALL_FEATURE_TYPES = tuple(FEATURE_KEY_TO_TYPE_ID.keys())
3737

38+
3839
#EGO AGENT DIMENSIONS
3940
vehicle_name = 'lexus'
4041
vehicle_length = 5.234
@@ -49,3 +50,4 @@
4950
vehicle_applanix_origin_to_cg_dist = 1.53
5051
vehicle_applanix_origin_to_r_bumper = 1.164
5152
vehicle_applanix_origin_height = 0.000
53+

dgp/datasets/synchronized_dataset.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,21 @@ def _item_index_for_scene(scene_idx, scene, backward_context, forward_context, o
132132
st = time.time()
133133
logging.debug(f'Indexing scene items for {scene.scene_path}')
134134

135-
# Define a safe sample range given desired context
136-
sample_range = np.arange(backward_context, len(scene.datum_index) - forward_context)
137135
if not only_annotated_datums:
136+
# Define a safe sample range given desired context
137+
sample_range = np.arange(backward_context, len(scene.datum_index) - forward_context)
138138
# Build the item-index of selected samples for an individual scene.
139139
scene_item_index = [(scene_idx, sample_idx, scene.selected_datums) for sample_idx in sample_range]
140140
logging.debug(f'No annotation filter--- Scene item index built in {time.time() - st:.2f}s.')
141141
else:
142142
# Filter out samples that do not have annotations.
143143
# A sample is considered annotated if ANY selected datum in the sample contains ANY requested annotation.
144+
sample_range = np.arange(0, len(scene.datum_index))
144145
annotated_samples = scene.annotation_index[scene.datum_index[sample_range]].any(axis=(1, 2))
145-
scene_item_index = [(scene_idx, sample_idx, scene.selected_datums)
146-
for sample_idx, annotated_sample in zip(sample_range, annotated_samples)
147-
if annotated_sample]
146+
scene_item_index = []
147+
for idx in range(backward_context, len(scene.datum_index) - forward_context):
148+
if all(annotated_samples.data[idx - backward_context:idx + 1 + forward_context]):
149+
scene_item_index.append((scene_idx, sample_range[idx], scene.selected_datums))
148150
logging.debug(f'Annotation filter -- Scene item index built in {time.time() - st:.2f}s.')
149151
return scene_item_index
150152

dgp/proto/annotations.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ enum AnnotationType {
7171
// 2D bounding box
7272
message BoundingBox2D {
7373
// (x, y) is top left corner (in absolute pixel coordinates)
74-
uint32 x = 1;
75-
uint32 y = 2;
74+
int32 x = 1;
75+
int32 y = 2;
7676

7777
// (w, h) is width and height (in absolute pixel coordinates)
7878
uint32 w = 3;
@@ -157,8 +157,8 @@ message BoundingBox3DAnnotation {
157157
// 2D point.
158158
message KeyPoint2D {
159159
// (x, y) point (in absolute pixel coordinates).
160-
uint32 x = 1;
161-
uint32 y = 2;
160+
int32 x = 1;
161+
int32 y = 2;
162162
}
163163

164164
// 2D point annotation.

dgp/proto/annotations_pb2.py

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dgp/utils/datasets.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2021 Toyota Research Institute. All rights reserved.
2+
import os
3+
from collections import OrderedDict
4+
5+
from dgp.proto import dataset_pb2
6+
7+
8+
def get_split_to_scenes(dataset):
9+
"""
10+
Retrieve a dictionary of split to scenes of a DGP-compliant scene dataset.
11+
12+
Parameters
13+
----------
14+
dataset: dgp.proto.dataset_pb2.SceneDataset
15+
SceneDataset proto object.
16+
17+
Returns
18+
-------
19+
split_to_scene_json: dict
20+
A dictionary of split to a list of scene JSONs.
21+
22+
split_to_scene_dir: dict
23+
A dictionary of split to a list of scene_dirs.
24+
"""
25+
split_to_scene_json = OrderedDict()
26+
split_to_scene_dir = OrderedDict()
27+
for k, v in dataset_pb2.DatasetSplit.DESCRIPTOR.values_by_number.items():
28+
scene_jsons = dataset.scene_splits[k].filenames
29+
split_to_scene_json[v.name] = scene_jsons
30+
split_to_scene_dir[v.name] = [os.path.dirname(scene_json) for scene_json in scene_jsons]
31+
assert len(set(split_to_scene_dir[v.name])) == len(split_to_scene_dir[v.name])
32+
return split_to_scene_json, split_to_scene_dir

0 commit comments

Comments
 (0)