From 8b96b7a6b3c1beeadd59aa2959caea4ac9e3996e Mon Sep 17 00:00:00 2001 From: DocGarbanzo <47540921+DocGarbanzo@users.noreply.github.com> Date: Sat, 25 May 2024 19:38:57 +0100 Subject: [PATCH] Fix augmentations and matplotlib (#1179) * * skip augmentations when list is empty * replacye spurios __file__ in load_config with os.getcwd() * pin matplotlib versions to 3.8.* * fix log statement in training * * fix layout height for ui widgets in macos (i.e. platform darwin) * * pin pytest to 8.1 for non-backwards compatible change * Fix test selection to correctly identify RPi hardware as 'aarch64' and not 'arm64' which is what Apple Silicon is now reporting. --- donkeycar/config.py | 3 +-- donkeycar/management/ui/common.kv | 5 +++-- donkeycar/management/ui/pilot_screen.kv | 6 +++--- donkeycar/management/ui/train_screen.kv | 2 +- donkeycar/management/ui/ui.kv | 2 +- donkeycar/pipeline/augmentations.py | 2 ++ donkeycar/pipeline/training.py | 2 +- donkeycar/tests/setup.py | 2 +- setup.cfg | 10 +++++----- 9 files changed, 18 insertions(+), 16 deletions(-) diff --git a/donkeycar/config.py b/donkeycar/config.py index 921dc7a07..29b31b904 100644 --- a/donkeycar/config.py +++ b/donkeycar/config.py @@ -66,8 +66,7 @@ def to_pyfile(self, path): def load_config(config_path=None, myconfig="myconfig.py"): if config_path is None: - import __main__ as main - main_path = os.path.dirname(os.path.realpath(main.__file__)) + main_path = os.getcwd() config_path = os.path.join(main_path, 'config.py') if not os.path.exists(config_path): local_config = os.path.join(os.path.curdir, 'config.py') diff --git a/donkeycar/management/ui/common.kv b/donkeycar/management/ui/common.kv index 9499dc8c4..5f9e2df96 100644 --- a/donkeycar/management/ui/common.kv +++ b/donkeycar/management/ui/common.kv @@ -1,6 +1,7 @@ #:import platform sys.platform -#:set common_height 30 +#:set reduced_height 40 if platform == 'darwin' else 20 +#:set common_height 60 if platform == 'darwin' else 30 #:set spacing 10 #:set layout_height common_height + spacing @@ -226,7 +227,7 @@ current_field: data_spinner.text BoxLayout: size_hint_y: None - height: 20 + height: reduced_height spacing: 2 MyLabel: id: label diff --git a/donkeycar/management/ui/pilot_screen.kv b/donkeycar/management/ui/pilot_screen.kv index 511ae3743..d04532c10 100644 --- a/donkeycar/management/ui/pilot_screen.kv +++ b/donkeycar/management/ui/pilot_screen.kv @@ -104,7 +104,7 @@ pilot_loader: pilot_loader DataPanel: size_hint_y: None - height: 20 + (self.minimum_height - 20) * 15 + height: reduced_height + (self.minimum_height - reduced_height) * 15 id: data_panel is_linked: True font_color: [0.2, 0.2, 1, 1] @@ -126,7 +126,7 @@ BackgroundBoxLayout: orientation: 'vertical' size_hint_y: None - height: self.minimum_height +60 + height: self.minimum_height + 2 * common_height Header: title: 'Multi Pilot Loader' description: @@ -217,7 +217,7 @@ BackgroundBoxLayout: orientation: 'vertical' size_hint_y: None - height: self.minimum_height + 90 + height: self.minimum_height + 3 * common_height Slider: size_hint_y: None height: common_height diff --git a/donkeycar/management/ui/train_screen.kv b/donkeycar/management/ui/train_screen.kv index e085d1937..b1cce87de 100644 --- a/donkeycar/management/ui/train_screen.kv +++ b/donkeycar/management/ui/train_screen.kv @@ -123,7 +123,7 @@ orientation: 'vertical' spacing: spacing size_hint_y: None - height: self.minimum_height + 80 + height: self.minimum_height + 4 * reduced_height Header: size_hint_y: 1.5 id: cfg_header diff --git a/donkeycar/management/ui/ui.kv b/donkeycar/management/ui/ui.kv index 44675e874..fdef8c6f6 100644 --- a/donkeycar/management/ui/ui.kv +++ b/donkeycar/management/ui/ui.kv @@ -13,7 +13,7 @@ BoxLayout: ActionView: id: av size_hint_y: None - height: 20 + height: reduced_height ActionPrevious: with_previous: False diff --git a/donkeycar/pipeline/augmentations.py b/donkeycar/pipeline/augmentations.py index 0842c9a75..a421d0e4c 100644 --- a/donkeycar/pipeline/augmentations.py +++ b/donkeycar/pipeline/augmentations.py @@ -40,6 +40,8 @@ def create(cls, aug_type: str, config: Config, prob, always) -> \ # Parts interface def run(self, img_arr): + if len(self.augmentations) == 0: + return img_arr aug_img_arr = self.augmentations(image=img_arr)["image"] return aug_img_arr diff --git a/donkeycar/pipeline/training.py b/donkeycar/pipeline/training.py index 09d027cb6..d58276cf6 100644 --- a/donkeycar/pipeline/training.py +++ b/donkeycar/pipeline/training.py @@ -153,7 +153,7 @@ def train(cfg: Config, tub_paths: str, model: str = None, assert val_size > 0, "Not enough validation data, decrease the batch " \ "size or add more data." logger.info(f'Train with image caching: ' - f'{getattr(cfg, "CACHE_IMAGES", True)}') + f'{getattr(cfg, "CACHE_IMAGES", "ARRAY")}') history = kl.train(model_path=model_path, train_data=dataset_train, train_steps=train_size, diff --git a/donkeycar/tests/setup.py b/donkeycar/tests/setup.py index 19d850b80..3555fce9c 100644 --- a/donkeycar/tests/setup.py +++ b/donkeycar/tests/setup.py @@ -7,7 +7,7 @@ def on_pi(): - if 'arm' in platform.machine(): + if 'aarch64' in platform.machine(): return True return False diff --git a/setup.cfg b/setup.cfg index e08f42596..7c5700e22 100644 --- a/setup.cfg +++ b/setup.cfg @@ -52,7 +52,7 @@ pi = flatbuffers==24.3.* tensorflow-aarch64==2.15.* opencv-contrib-python - matplotlib + matplotlib==3.8.* kivy kivy-garden.matplotlib pandas @@ -73,7 +73,7 @@ nano = pc = tensorflow==2.15.* - matplotlib + matplotlib==3.8.* kivy kivy-garden.matplotlib pandas @@ -81,8 +81,8 @@ pc = albumentations macos = - tensorflow-macos==2.15.* - matplotlib + tensorflow==2.15.* + matplotlib==3.8.* kivy kivy-garden.matplotlib pandas @@ -90,7 +90,7 @@ macos = albumentations dev = - pytest + pytest==8.1.* pytest-cov responses mypy