switch to not predict video, but training data

This commit is contained in:
Ruben van de Ven 2023-10-20 13:27:04 +02:00
parent f3ac903555
commit 2171dd459a
1 changed files with 69 additions and 60 deletions

View File

@ -214,13 +214,13 @@ class PredictionServer:
prev_run_time = 0
while self.is_running.is_set():
timestep += 1
this_run_time = time.time()
logger.debug(f'test {prev_run_time - this_run_time}')
time.sleep(max(0, prev_run_time - this_run_time + .5))
prev_run_time = time.time()
# for timestep in range(init_timestep + 1, eval_scene.timesteps):
# input_dict = eval_scene.get_clipped_input_dict(timestep, hyperparams['state'])
# this_run_time = time.time()
# logger.debug(f'test {prev_run_time - this_run_time}')
# time.sleep(max(0, prev_run_time - this_run_time + .5))
# prev_run_time = time.time()
# TODO: see process_data.py on how to create a node, the provide nodes + incoming data columns
# data_columns = pd.MultiIndex.from_product([['position', 'velocity', 'acceleration'], ['x', 'y']])
# x = node_values[:, 0]
@ -239,7 +239,9 @@ class PredictionServer:
# node_data = pd.DataFrame(data_dict, columns=data_columns)
# node = Node(node_type=env.NodeType.PEDESTRIAN, node_id=node_id, data=node_data)
if self.config.predict_training_data:
input_dict = eval_scene.get_clipped_input_dict(timestep, hyperparams['state'])
else:
data = self.trajectory_socket.recv()
frame: Frame = pickle.loads(data)
trajectory_data = frame.trajectories # TODO: properly refractor
@ -291,9 +293,11 @@ class PredictionServer:
if not len(input_dict):
# skip if our input is empty
# TODO: we want to send out empty result...
# And want to update the network
data = json.dumps({})
self.prediction_socket.send_string(data)
continue
maps = None
@ -311,10 +315,12 @@ class PredictionServer:
# robot_present_and_future += adjustment
start = time.time()
with warnings.catch_warnings():
warnings.simplefilter('ignore') # prevent deluge of UserWarning from torch's rrn.py
dists, preds = trajectron.incremental_forward(input_dict,
maps,
prediction_horizon=20, # TODO: make variable
num_samples=2, # TODO: make variable
prediction_horizon=25, # TODO: make variable
num_samples=20, # TODO: make variable
robot_present_and_future=robot_present_and_future,
full_dist=True)
end = time.time()
@ -365,6 +371,9 @@ class PredictionServer:
}
data = json.dumps(response)
if self.config.predict_training_data:
logger.info(f"Frame prediction: {len(trajectron.nodes)} nodes & {trajectron.scene_graph.get_num_edges()} edges. Trajectron: {end - start}s")
else:
logger.info(f"Total frame delay = {time.time()-frame.time}s ({len(trajectron.nodes)} nodes & {trajectron.scene_graph.get_num_edges()} edges. Trajectron: {end - start}s)")
self.prediction_socket.send_string(data)
logger.info('Stopping')