-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
187 lines (177 loc) · 7.58 KB
/
utils.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import tensorflow as tf
import numpy as np
def get_state_features_description():
state_features = {
"state/id": tf.io.FixedLenFeature([128], tf.float32, default_value=None),
"state/type": tf.io.FixedLenFeature([128], tf.float32, default_value=None),
"state/is_sdc": tf.io.FixedLenFeature([128], tf.int64, default_value=None),
"state/tracks_to_predict": tf.io.FixedLenFeature(
[128], tf.int64, default_value=None
),
"state/current/bbox_yaw": tf.io.FixedLenFeature(
[128, 1], tf.float32, default_value=None
),
"state/current/height": tf.io.FixedLenFeature(
[128, 1], tf.float32, default_value=None
),
"state/current/length": tf.io.FixedLenFeature(
[128, 1], tf.float32, default_value=None
),
"state/current/timestamp_micros": tf.io.FixedLenFeature(
[128, 1], tf.int64, default_value=None
),
"state/current/valid": tf.io.FixedLenFeature(
[128, 1], tf.int64, default_value=None
),
"state/current/vel_yaw": tf.io.FixedLenFeature(
[128, 1], tf.float32, default_value=None
),
"state/current/velocity_x": tf.io.FixedLenFeature(
[128, 1], tf.float32, default_value=None
),
"state/current/velocity_y": tf.io.FixedLenFeature(
[128, 1], tf.float32, default_value=None
),
"state/current/speed": tf.io.FixedLenFeature(
[128, 1], tf.float32, default_value=None
),
"state/current/width": tf.io.FixedLenFeature(
[128, 1], tf.float32, default_value=None
),
"state/current/x": tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
"state/current/y": tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
"state/current/z": tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),
"state/future/bbox_yaw": tf.io.FixedLenFeature(
[128, 80], tf.float32, default_value=None
),
"state/future/height": tf.io.FixedLenFeature(
[128, 80], tf.float32, default_value=None
),
"state/future/length": tf.io.FixedLenFeature(
[128, 80], tf.float32, default_value=None
),
"state/future/timestamp_micros": tf.io.FixedLenFeature(
[128, 80], tf.int64, default_value=None
),
"state/future/valid": tf.io.FixedLenFeature(
[128, 80], tf.int64, default_value=None
),
"state/future/vel_yaw": tf.io.FixedLenFeature(
[128, 80], tf.float32, default_value=None
),
"state/future/velocity_x": tf.io.FixedLenFeature(
[128, 80], tf.float32, default_value=None
),
"state/future/velocity_y": tf.io.FixedLenFeature(
[128, 80], tf.float32, default_value=None
),
"state/future/speed": tf.io.FixedLenFeature(
[128, 80], tf.float32, default_value=None
),
"state/future/width": tf.io.FixedLenFeature(
[128, 80], tf.float32, default_value=None
),
"state/future/x": tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),
"state/future/y": tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),
"state/future/z": tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),
"state/past/bbox_yaw": tf.io.FixedLenFeature(
[128, 10], tf.float32, default_value=None
),
"state/past/height": tf.io.FixedLenFeature(
[128, 10], tf.float32, default_value=None
),
"state/past/length": tf.io.FixedLenFeature(
[128, 10], tf.float32, default_value=None
),
"state/past/timestamp_micros": tf.io.FixedLenFeature(
[128, 10], tf.int64, default_value=None
),
"state/past/valid": tf.io.FixedLenFeature([128, 10], tf.int64, default_value=None),
"state/past/vel_yaw": tf.io.FixedLenFeature(
[128, 10], tf.float32, default_value=None
),
"state/past/velocity_x": tf.io.FixedLenFeature(
[128, 10], tf.float32, default_value=None
),
"state/past/velocity_y": tf.io.FixedLenFeature(
[128, 10], tf.float32, default_value=None
),
"state/past/speed": tf.io.FixedLenFeature(
[128, 10], tf.float32, default_value=None
),
"state/past/width": tf.io.FixedLenFeature(
[128, 10], tf.float32, default_value=None
),
"state/past/x": tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
"state/past/y": tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
"state/past/z": tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
"scenario/id": tf.io.FixedLenFeature([1], tf.string, default_value=None),
}
return state_features
def get_roadgraph_features_description():
roadgraph_features = {
"roadgraph_samples/dir": tf.io.FixedLenFeature(
[20000, 3], tf.float32, default_value=None
),
"roadgraph_samples/id": tf.io.FixedLenFeature(
[20000, 1], tf.int64, default_value=None
),
"roadgraph_samples/type": tf.io.FixedLenFeature(
[20000, 1], tf.int64, default_value=None
),
"roadgraph_samples/valid": tf.io.FixedLenFeature(
[20000, 1], tf.int64, default_value=None
),
"roadgraph_samples/xyz": tf.io.FixedLenFeature(
[20000, 3], tf.float32, default_value=None
),
}
return roadgraph_features
def get_traffic_lights_features_description():
traffic_light_features = {
"traffic_light_state/current/state": tf.io.FixedLenFeature(
[1, 16], tf.int64, default_value=None
),
"traffic_light_state/current/valid": tf.io.FixedLenFeature(
[1, 16], tf.int64, default_value=None
),
"traffic_light_state/current/id": tf.io.FixedLenFeature(
[1, 16], tf.int64, default_value=None
),
"traffic_light_state/current/x": tf.io.FixedLenFeature(
[1, 16], tf.float32, default_value=None
),
"traffic_light_state/current/y": tf.io.FixedLenFeature(
[1, 16], tf.float32, default_value=None
),
"traffic_light_state/current/z": tf.io.FixedLenFeature(
[1, 16], tf.float32, default_value=None
),
"traffic_light_state/past/state": tf.io.FixedLenFeature(
[10, 16], tf.int64, default_value=None
),
"traffic_light_state/past/valid": tf.io.FixedLenFeature(
[10, 16], tf.int64, default_value=None
),
# "traffic_light_state/past/id":
# tf.io.FixedLenFeature([1, 16], tf.int64, default_value=None),
"traffic_light_state/past/x": tf.io.FixedLenFeature(
[10, 16], tf.float32, default_value=None
),
"traffic_light_state/past/y": tf.io.FixedLenFeature(
[10, 16], tf.float32, default_value=None
),
"traffic_light_state/past/z": tf.io.FixedLenFeature(
[10, 16], tf.float32, default_value=None
),
}
return traffic_light_features
def get_features_description():
roadgraph_features = get_roadgraph_features_description()
state_features = get_state_features_description()
traffic_light_features = get_traffic_lights_features_description()
features_description = {}
features_description.update(roadgraph_features)
features_description.update(state_features)
features_description.update(traffic_light_features)
return features_description