-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathcmd2caption.py
162 lines (158 loc) · 4.19 KB
/
cmd2caption.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
import random
plain_caption_dict = {
0: "Go straight.",
1: "Pass the intersection.",
2: "Turn left.",
3: "Turn right.",
4: "Change to the left lane.",
5: "Change to the right lane.",
6: "Go to the left lane branch.",
7: "Go to the right lane branch.",
8: "Pass the crosswalk.",
9: "Pass the railroad.",
10: "Merge.",
11: "Make a U-turn.",
12: "Stop.",
13: "Deviate."
}
diverse_caption_dict = {
0: [
"Move forward.",
"Move steady.",
"Go forward.",
"Go straight.",
"Proceed.",
"Drive forward.",
"Drive straight.",
"Drive steady.",
"Keep the direction.",
"Maintain the direction.",
],
1: [
"Pass the intersection.",
"Cross the intersection.",
"Traverse the intersection.",
"Drive through the intersection.",
"Move past the intersection.",
"Pass the junction.",
"Cross the junction.",
"Traverse the junction.",
"Drive through the junction.",
"Move past the junction.",
"Pass the crossroad.",
"Cross the crossroad.",
"Traverse the crossroad.",
"Drive through the crossroad.",
"Move past the crossroad.",
],
2: [
"Turn left.",
"Turn to the left.",
"Make a left turn.",
"Take a left turn.",
"Turn to the left.",
"Left turn.",
"Steer left.",
"Steer to the left.",
],
3: [
"Turn right.",
"Turn to the right.",
"Make a right turn.",
"Take a right turn.",
"Turn to the right.",
"Right turn.",
"Steer right.",
"Steer to the right.",
],
4: [
"Make a left lane change.",
"Change to the left lane.",
"Switch to the left lane.",
"Shift to the left lane.",
"Move to the left lane.",
],
5: [
"Make a right lane change.",
"Change to the right lane.",
"Switch to the right lane.",
"Shift to the right lane.",
"Move to the right lane.",
],
6: [
"Go to the left lane branch.",
"Take the left lane branch.",
"Move into the left lane branch.",
"Follow the left lane branch.",
"Follow the left side road.",
],
7: [
"Go to the right lane branch.",
"Take the right lane branch.",
"Move into the right lane branch.",
"Follow the right lane branch.",
"Follow the right side road.",
],
8: [
"Pass the crosswalk.",
"Cross the crosswalk.",
"Traverse the crosswalk.",
"Drive through the crosswalk.",
"Move past the crosswalk.",
"Pass the crossing area.",
"Cross the crossing area.",
"Traverse the crossing area.",
"Drive through the crossing area.",
"Move past the crossing area.",
],
9: [
"Pass the railroad.",
"Cross the railroad.",
"Traverse the railroad.",
"Drive through the railroad.",
"Move past the railroad.",
"Pass the railway.",
"Cross the railway.",
"Traverse the railway.",
"Drive through the railway.",
"Move past the railway.",
],
10: [
"Merge.",
"Merge traffic.",
"Merge into traffic.",
"Merge into the traffic.",
"Join the traffic.",
"Merge into the traffic flow.",
"Join the traffic flow.",
"Merge into the traffic stream.",
"Join the traffic stream.",
"Merge into the lane.",
],
11: [
"Make a U-turn.",
"Make a 180-degree turn.",
"Turn 180 degree.",
"Turn around.",
"Drive in a U-turn.",
],
12: [
"Stop.",
"Halt.",
"Decelerate.",
"Slow down.",
"Brake.",
],
13: [
"Deviate.",
"Deviate from the path.",
"Deviate from the lane.",
"Change the direction.",
"Shift the direction.",
]
}
def map_category_to_caption(category_index, diverse=True):
if diverse:
return random.choice(diverse_caption_dict[category_index])
else:
return plain_caption_dict[category_index]