From 3f490e858e2461d019c2052e99d6d060e3c88b8b Mon Sep 17 00:00:00 2001 From: sergiopaniego Date: Tue, 9 Jan 2024 17:31:34 +0100 Subject: [PATCH] Update controllers for new shapes and solve multiple experiments error --- ...in_carla_bird_eye_deep_learning_70_km_h.py | 2 +- ...n_carla_bird_eye_deep_learning_V_MAX_30.py | 3 +- ...rla_bird_eye_deep_learning_broken_input.py | 4 +- ...a_bird_eye_deep_learning_broken_input_2.py | 2 +- ...carla_bird_eye_deep_learning_previous_v.py | 4 +- ...rd_eye_deep_learning_previous_v_70_km_h.py | 4 +- ...e_deep_learning_previous_v_broken_input.py | 6 +-- ...deep_learning_previous_v_broken_input_2.py | 4 +- ...ng_x3_previous_v_t_t-4_t-9_broken_input.py | 2 +- ..._x3_previous_v_t_t-4_t-9_broken_input_2.py | 5 +-- ..._eye_deep_learning_x3_t_t-4_t-9_70_km_h.py | 9 ++-- behavior_metrics/driver_carla.py | 41 +++++++++++-------- 12 files changed, 46 insertions(+), 40 deletions(-) diff --git a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_70_km_h.py b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_70_km_h.py index 80e75693..1e8d8b65 100644 --- a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_70_km_h.py +++ b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_70_km_h.py @@ -134,7 +134,7 @@ def execute(self): self.update_pose(self.pose.getPose3d()) - image_shape=(50, 150) + image_shape=(66, 200) img_base = cv2.resize(bird_eye_view_1, image_shape) AUGMENTATIONS_TEST = Compose([ diff --git a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_V_MAX_30.py b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_V_MAX_30.py index bda34764..4e7bea2b 100644 --- a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_V_MAX_30.py +++ b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_V_MAX_30.py @@ -131,11 +131,10 @@ def execute(self): self.update_pose(self.pose.getPose3d()) - image_shape=(50, 150) + image_shape=(66, 200) img_base = cv2.resize(bird_eye_view_1, image_shape) AUGMENTATIONS_TEST = Compose([ - #ChannelDropout(p=1.0), Normalize() ]) image = AUGMENTATIONS_TEST(image=img_base) diff --git a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_broken_input.py b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_broken_input.py index 37fcd41e..0448a2d1 100644 --- a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_broken_input.py +++ b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_broken_input.py @@ -125,7 +125,7 @@ def execute(self): ] AUGMENTATIONS_TEST = Compose([ - GridDropout(p=1.0, ratio=0.9) + GridDropout(p=1.0) ]) bird_eye_view_1 = AUGMENTATIONS_TEST(image=bird_eye_view_1) @@ -139,7 +139,7 @@ def execute(self): self.update_pose(self.pose.getPose3d()) - image_shape=(50, 150) + image_shape=(66, 200) img_base = cv2.resize(bird_eye_view_1, image_shape) AUGMENTATIONS_TEST = Compose([ diff --git a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_broken_input_2.py b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_broken_input_2.py index 37fcd41e..a9eab9b0 100644 --- a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_broken_input_2.py +++ b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_broken_input_2.py @@ -139,7 +139,7 @@ def execute(self): self.update_pose(self.pose.getPose3d()) - image_shape=(50, 150) + image_shape=(66, 200) img_base = cv2.resize(bird_eye_view_1, image_shape) AUGMENTATIONS_TEST = Compose([ diff --git a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v.py b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v.py index 9ab3105a..1db1f353 100644 --- a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v.py +++ b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v.py @@ -133,7 +133,7 @@ def execute(self): self.update_pose(self.pose.getPose3d()) - image_shape=(50, 150) + image_shape=(66, 200) img_base = cv2.resize(bird_eye_view_1, image_shape) AUGMENTATIONS_TEST = Compose([ @@ -147,7 +147,7 @@ def execute(self): self.bird_eye_view_unique_images += 1 self.previous_bird_eye_view_image = img - velocity_dim = np.full((150, 50), self.previous_speed/30) + velocity_dim = np.full((200, 66), self.previous_speed/30) new_img_vel = np.dstack((img, velocity_dim)) img = new_img_vel diff --git a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v_70_km_h.py b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v_70_km_h.py index 62952e24..70100b04 100644 --- a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v_70_km_h.py +++ b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v_70_km_h.py @@ -135,7 +135,7 @@ def execute(self): self.update_pose(self.pose.getPose3d()) - image_shape=(50, 150) + image_shape=(66, 200) img_base = cv2.resize(bird_eye_view_1, image_shape) AUGMENTATIONS_TEST = Compose([ @@ -149,7 +149,7 @@ def execute(self): self.bird_eye_view_unique_images += 1 self.previous_bird_eye_view_image = img - velocity_dim = np.full((150, 50), self.previous_speed/30) + velocity_dim = np.full((200, 66), self.previous_speed/30) new_img_vel = np.dstack((img, velocity_dim)) img = new_img_vel diff --git a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v_broken_input.py b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v_broken_input.py index 2ac2ae31..c5bf0edc 100644 --- a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v_broken_input.py +++ b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v_broken_input.py @@ -126,7 +126,7 @@ def execute(self): ] AUGMENTATIONS_TEST = Compose([ - GridDropout(p=1.0, ratio=0.9) + GridDropout(p=1.0) ]) bird_eye_view_1 = AUGMENTATIONS_TEST(image=bird_eye_view_1) @@ -140,7 +140,7 @@ def execute(self): self.update_pose(self.pose.getPose3d()) - image_shape=(50, 150) + image_shape=(66, 200) img_base = cv2.resize(bird_eye_view_1, image_shape) AUGMENTATIONS_TEST = Compose([ @@ -154,7 +154,7 @@ def execute(self): self.bird_eye_view_unique_images += 1 self.previous_bird_eye_view_image = img - velocity_dim = np.full((150, 50), self.previous_speed/30) + velocity_dim = np.full((200, 66), self.previous_speed/30) new_img_vel = np.dstack((img, velocity_dim)) img = new_img_vel diff --git a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v_broken_input_2.py b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v_broken_input_2.py index 2ac2ae31..ae23f5fb 100644 --- a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v_broken_input_2.py +++ b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_previous_v_broken_input_2.py @@ -140,7 +140,7 @@ def execute(self): self.update_pose(self.pose.getPose3d()) - image_shape=(50, 150) + image_shape=(66, 200) img_base = cv2.resize(bird_eye_view_1, image_shape) AUGMENTATIONS_TEST = Compose([ @@ -154,7 +154,7 @@ def execute(self): self.bird_eye_view_unique_images += 1 self.previous_bird_eye_view_image = img - velocity_dim = np.full((150, 50), self.previous_speed/30) + velocity_dim = np.full((200, 66), self.previous_speed/30) new_img_vel = np.dstack((img, velocity_dim)) img = new_img_vel diff --git a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_x3_previous_v_t_t-4_t-9_broken_input.py b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_x3_previous_v_t_t-4_t-9_broken_input.py index 373c55e8..53399b98 100644 --- a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_x3_previous_v_t_t-4_t-9_broken_input.py +++ b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_x3_previous_v_t_t-4_t-9_broken_input.py @@ -147,7 +147,7 @@ def execute(self): AUGMENTATIONS_TEST = Compose([ - GridDropout(p=1.0, ratio=0.9) + GridDropout(p=1.0) ]) bird_eye_view_1 = AUGMENTATIONS_TEST(image=bird_eye_view_1) diff --git a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_x3_previous_v_t_t-4_t-9_broken_input_2.py b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_x3_previous_v_t_t-4_t-9_broken_input_2.py index 469d3055..373c55e8 100644 --- a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_x3_previous_v_t_t-4_t-9_broken_input_2.py +++ b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_x3_previous_v_t_t-4_t-9_broken_input_2.py @@ -9,7 +9,7 @@ import carla from os import path from albumentations import ( - Compose, Normalize, RandomRain, RandomBrightness, RandomShadow, RandomSnow, RandomFog, RandomSunFlare, GridDropout, ChannelDropout, GaussNoise + Compose, Normalize, RandomRain, RandomBrightness, RandomShadow, RandomSnow, RandomFog, RandomSunFlare, GridDropout, ChannelDropout ) from utils.constants import PRETRAINED_MODELS_DIR, ROOT_PATH from utils.logger import logger @@ -147,8 +147,7 @@ def execute(self): AUGMENTATIONS_TEST = Compose([ - #GridDropout(p=1.0, ratio=0.5), - GaussNoise(p=1.0, var_limit=(500.0, 1500.0)) + GridDropout(p=1.0, ratio=0.9) ]) bird_eye_view_1 = AUGMENTATIONS_TEST(image=bird_eye_view_1) diff --git a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_x3_t_t-4_t-9_70_km_h.py b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_x3_t_t-4_t-9_70_km_h.py index 93ce6163..9ee732b9 100644 --- a/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_x3_t_t-4_t-9_70_km_h.py +++ b/behavior_metrics/brains/CARLA/tensorflow/brain_carla_bird_eye_deep_learning_x3_t_t-4_t-9_70_km_h.py @@ -172,9 +172,11 @@ def execute(self): self.image_8 = img elif type(self.image_9) is int: self.image_9 = img + elif type(self.image_10) is int: + self.image_10 = img else: self.bird_eye_view_images += 1 - if (self.image_9==img).all() == False: + if (self.image_10==img).all() == False: self.bird_eye_view_unique_images += 1 self.image_1 = self.image_2 self.image_2 = self.image_3 @@ -184,9 +186,10 @@ def execute(self): self.image_6 = self.image_7 self.image_7 = self.image_8 self.image_8 = self.image_9 - self.image_9 = img + self.image_9 = self.image_10 + self.image_10 = img - img = [self.image_1, self.image_4, self.image_9] + img = [self.image_1, self.image_5, self.image_10] img = np.expand_dims(img, axis=0) start_time = time.time() diff --git a/behavior_metrics/driver_carla.py b/behavior_metrics/driver_carla.py index 0f9c2ed7..699d9d49 100644 --- a/behavior_metrics/driver_carla.py +++ b/behavior_metrics/driver_carla.py @@ -127,7 +127,7 @@ def is_config_correct(app_configuration): return is_correct -def generate_agregated_experiments_metrics(experiments_starting_time, experiments_elapsed_times): +def generate_agregated_experiments_metrics(experiments_starting_time, experiments_elapsed_times, app_configuration): result = metrics_carla.get_aggregated_experiments_list(experiments_starting_time) experiments_starting_time_dt = datetime.fromtimestamp(experiments_starting_time) @@ -252,28 +252,33 @@ def generate_agregated_experiments_metrics(experiments_starting_time, experiment 'metric': 'suddenness_distance_speed_per_km', 'title': 'Suddenness distance speed per km per experiment' }, - { - 'metric': 'dangerous_distance_pct_km', - 'title': 'Percentage of dangerous distance per km' - }, - { - 'metric': 'close_distance_pct_km', - 'title': 'Percentage of close distance per km' - }, - { - 'metric': 'medium_distance_pct_km', - 'title': 'Percentage of medium distance per km' - }, - { - 'metric': 'great_distance_pct_km', - 'title': 'Percentage of great distance per km' - }, + { 'metric': 'completed_laps', 'title': 'Completed laps per experiment' }, ] + if app_configuration.task == 'follow_lane_traffic': + experiments_metrics_and_titles.append( + { + 'metric': 'dangerous_distance_pct_km', + 'title': 'Percentage of dangerous distance per km' + }, + { + 'metric': 'close_distance_pct_km', + 'title': 'Percentage of close distance per km' + }, + { + 'metric': 'medium_distance_pct_km', + 'title': 'Percentage of medium distance per km' + }, + { + 'metric': 'great_distance_pct_km', + 'title': 'Percentage of great distance per km' + }, + ) + metrics_carla.get_all_experiments_aggregated_metrics(result, experiments_starting_time_str, experiments_metrics_and_titles) metrics_carla.get_per_model_aggregated_metrics(result, experiments_starting_time_str, experiments_metrics_and_titles) metrics_carla.get_all_experiments_aggregated_metrics_boxplot(result, experiments_starting_time_str, experiments_metrics_and_titles) @@ -413,7 +418,7 @@ def main(): logger.info('Invalid task type. Try "follow_route", "follow_lane" or "follow_lane_traffic". Killing program...') sys.exit(-1) experiments_elapsed_times['total_experiments_elapsed_time'] = time.time() - experiments_starting_time - generate_agregated_experiments_metrics(experiments_starting_time, experiments_elapsed_times) + generate_agregated_experiments_metrics(experiments_starting_time, experiments_elapsed_times, app_configuration) if app_configuration.experiment_random_spawn_point == True or app_configuration.task == 'follow_route': if os.path.isfile('tmp_circuit.launch'): os.remove('tmp_circuit.launch')