Compare commits

..

4 commits

Author SHA1 Message Date
Ruben van de Ven
1aff04d444 Revert to local dependency to debug training when using maps 2024-12-31 14:47:57 +01:00
Ruben van de Ven
8db0f2cf6c Tweak to have more trajectories to train from 2024-12-31 14:47:33 +01:00
Ruben van de Ven
71eadbeecf Lighter smoothing on tracks when using Kalman 2024-12-31 14:46:43 +01:00
Ruben van de Ven
4bc1e56dad Faster cv rendering with polylines 2024-12-31 14:46:27 +01:00
6 changed files with 28 additions and 34 deletions

View file

@ -5,9 +5,9 @@
"learning_rate": 0.01, "learning_rate": 0.01,
"min_learning_rate": 1e-05, "min_learning_rate": 1e-05,
"learning_decay_rate": 0.9999, "learning_decay_rate": 0.9999,
"prediction_horizon": 50, "prediction_horizon": 30,
"minimum_history_length": 10, "minimum_history_length": 5,
"maximum_history_length": 80, "maximum_history_length": 50,
"map_encoder": { "map_encoder": {
"PEDESTRIAN": { "PEDESTRIAN": {
"heading_state_index": [2, 3], "heading_state_index": [2, 3],
@ -74,7 +74,7 @@
"dynamic": { "dynamic": {
"PEDESTRIAN": { "PEDESTRIAN": {
"name": "SingleIntegrator", "name": "SingleIntegrator",
"distribution": false, "distribution": true,
"limits": {} "limits": {}
} }
}, },

10
poetry.lock generated
View file

@ -3692,7 +3692,7 @@ description = "This repository contains the code for Trajectron++: Dynamically-F
optional = false optional = false
python-versions = "^3.9,<3.12" python-versions = "^3.9,<3.12"
files = [] files = []
develop = false develop = true
[package.dependencies] [package.dependencies]
dill = "^0.3.7" dill = "^0.3.7"
@ -3719,10 +3719,8 @@ torch = [
tqdm = "^4.65.0" tqdm = "^4.65.0"
[package.source] [package.source]
type = "git" type = "directory"
url = "https://git.rubenvandeven.com/security_vision/Trajectron-plus-plus/" url = "../Trajectron-plus-plus"
reference = "HEAD"
resolved_reference = "4e883511d31c96f0a894afc714fed05e322cea5b"
[[package]] [[package]]
name = "tsmoothie" name = "tsmoothie"
@ -3929,4 +3927,4 @@ watchdog = ["watchdog (>=2.3)"]
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = "^3.10,<3.12," python-versions = "^3.10,<3.12,"
content-hash = "51023fede550e6a8066ed1689cfedfa01346d994e0dea773476609508dc9ee8b" content-hash = "716919f29853fc36b09594af35aa8ca09d4d3ceb7ad9cf54a85f4042569ecf1c"

View file

@ -16,8 +16,8 @@ rewrite_tracks = "trap.tools:rewrite_raw_track_files"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.10,<3.12," python = "^3.10,<3.12,"
#trajectron-plus-plus = { path = "../Trajectron-plus-plus/", develop = true } trajectron-plus-plus = { path = "../Trajectron-plus-plus/", develop = true }
trajectron-plus-plus = { git = "https://git.rubenvandeven.com/security_vision/Trajectron-plus-plus/" } #trajectron-plus-plus = { git = "https://git.rubenvandeven.com/security_vision/Trajectron-plus-plus/" }
torch = [ torch = [
{ version="1.12.1" }, { version="1.12.1" },
# { url = "https://download.pytorch.org/whl/cu113/torch-1.12.1%2Bcu113-cp38-cp38-linux_x86_64.whl", markers = "python_version ~= '3.8' and sys_platform == 'linux'" }, # { url = "https://download.pytorch.org/whl/cu113/torch-1.12.1%2Bcu113-cp38-cp38-linux_x86_64.whl", markers = "python_version ~= '3.8' and sys_platform == 'linux'" },

View file

@ -145,7 +145,7 @@ def process_data(src_dir: Path, dst_dir: Path, name: str, smooth_tracks: bool, c
print(max_frame_nr) print(max_frame_nr)
# separate call so cursor is kept during multiple loops # separate call so cursor is kept during multiple loops
seed(123) # seed(123)
shuffle(tracks) shuffle(tracks)
dt1 = RollingAverage() dt1 = RollingAverage()

View file

@ -200,7 +200,7 @@ def transition_path_points(path: np.array, t: float):
# distance = cum_lenghts[-1] * t # distance = cum_lenghts[-1] * t
# ts = np.concatenate((np.array([0.]), cum_lenghts / cum_lenghts[-1])) # ts = np.concatenate((np.array([0.]), cum_lenghts / cum_lenghts[-1]))
# print(cum_lenghts[-1]) # print(cum_lenghts[-1])
DRAW_SPEED = 30 # fixed speed (independent of lenght) TODO)) make variable DRAW_SPEED = 35 # fixed speed (independent of lenght) TODO)) make variable
ts = np.concatenate((np.array([0.]), cum_lenghts / DRAW_SPEED)) ts = np.concatenate((np.array([0.]), cum_lenghts / DRAW_SPEED))
new_path = [path[0]] new_path = [path[0]]
@ -235,6 +235,7 @@ def draw_track_predictions(img: cv2.Mat, track: Track, color_index: int, camera:
# if convert_points: # if convert_points:
# current_point = convert_points([current_point])[0] # current_point = convert_points([current_point])[0]
lines = []
for pred_i, pred in enumerate(track.predictions): for pred_i, pred in enumerate(track.predictions):
pred_coords = pred #cv2.perspectiveTransform(np.array([pred]), inv_H)[0].tolist() pred_coords = pred #cv2.perspectiveTransform(np.array([pred]), inv_H)[0].tolist()
# line_points = pred_coords # line_points = pred_coords
@ -249,23 +250,15 @@ def draw_track_predictions(img: cv2.Mat, track: Track, color_index: int, camera:
color = bgr_colors[color_index % len(bgr_colors)] color = bgr_colors[color_index % len(bgr_colors)]
color = tuple([int(c*opacity) for c in color]) color = tuple([int(c*opacity) for c in color])
line_points = line_points.reshape((-1,1,2))
for start, end in zip(line_points[:-1], line_points[1:]): lines.append(line_points)
# for ci in range(0, len(pred_coords)):
# if ci == 0: # draw in a single pass
# # TODO)) prev point cv2.polylines(img, lines, False, color, 2, cv2.LINE_AA)
# # continue # for start, end in zip(line_points[:-1], line_points[1:]):
# start = [int(p) for p in current_point] # cv2.line(img, start, end, color, 2, lineType=cv2.LINE_AA)
# # start = [int(p) for p in coords[-1]] # pass
# # start = [0,0]? # # cv2.circle(img, end, 2, color, 1, lineType=cv2.LINE_AA)
# # print(start)
# else:
# start = [int(p) for p in pred_coords[ci-1]]
# end = [int(p) for p in pred_coords[ci]]
# print(np.rint(start),np.rint(end).tolist())
cv2.line(img, start, end, color, 2, lineType=cv2.LINE_AA)
pass
# cv2.circle(img, end, 2, color, 1, lineType=cv2.LINE_AA)
def draw_trackjectron_history(img: cv2.Mat, track: Track, color_index: int, convert_points: Optional[Callable]): def draw_trackjectron_history(img: cv2.Mat, track: Track, color_index: int, convert_points: Optional[Callable]):
if not track.predictor_history: if not track.predictor_history:
@ -301,12 +294,15 @@ def draw_track_projected(img: cv2.Mat, track: Track, color_index: int, camera: C
point_color = bgr_colors[color_index % len(bgr_colors)] point_color = bgr_colors[color_index % len(bgr_colors)]
cv2.circle(img, to_point(history[0]), 3, point_color, 2) cv2.circle(img, to_point(history[0]), 3, point_color, 2)
points = np.rint(history.reshape((-1,1,2))).astype(np.int32)
cv2.polylines(img, [points], False, point_color, 1)
for j in range(len(history)-1): for j in range(len(history)-1):
a = history[j] # a = history[j]
b = history[j+1] b = history[j+1]
cv2.line(img, to_point(a), to_point(b), point_color, 1) # cv2.line(img, to_point(a), to_point(b), point_color, 1)
cv2.circle(img, to_point(b), 3, point_color, 2) cv2.circle(img, to_point(b), 3, point_color, 2)

View file

@ -691,7 +691,7 @@ class Smoother:
else: else:
# "Unlike Kalman filtering, which focuses on predicting and updating the current state using historical measurements, Kalman smoothing enhances the accuracy of past state values" # "Unlike Kalman filtering, which focuses on predicting and updating the current state using historical measurements, Kalman smoothing enhances the accuracy of past state values"
# see https://medium.com/@shahalkp1/kalman-smoothing-using-tsmoothie-0175260464e5 # see https://medium.com/@shahalkp1/kalman-smoothing-using-tsmoothie-0175260464e5
self.smoother = KalmanSmoother(component='level_trend', component_noise={'level':0.03, 'season': .02, 'trend':0.04},n_seasons = 2, copy=None) self.smoother = KalmanSmoother(component='level_trend', component_noise={'level':0.02, 'season': .01, 'trend':0.02},n_seasons = 2, copy=None)