Skip to content

Commit

Permalink
Fix augmentations and matplotlib (#1179)
Browse files Browse the repository at this point in the history
* * 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.
  • Loading branch information
DocGarbanzo authored May 25, 2024
1 parent 45dc516 commit 8b96b7a
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 16 deletions.
3 changes: 1 addition & 2 deletions donkeycar/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
5 changes: 3 additions & 2 deletions donkeycar/management/ui/common.kv
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -226,7 +227,7 @@
current_field: data_spinner.text
BoxLayout:
size_hint_y: None
height: 20
height: reduced_height
spacing: 2
MyLabel:
id: label
Expand Down
6 changes: 3 additions & 3 deletions donkeycar/management/ui/pilot_screen.kv
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion donkeycar/management/ui/train_screen.kv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion donkeycar/management/ui/ui.kv
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ BoxLayout:
ActionView:
id: av
size_hint_y: None
height: 20
height: reduced_height

ActionPrevious:
with_previous: False
Expand Down
2 changes: 2 additions & 0 deletions donkeycar/pipeline/augmentations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion donkeycar/pipeline/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion donkeycar/tests/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def on_pi():
if 'arm' in platform.machine():
if 'aarch64' in platform.machine():
return True
return False

Expand Down
10 changes: 5 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pi =
flatbuffers==24.3.*
tensorflow-aarch64==2.15.*
opencv-contrib-python
matplotlib
matplotlib==3.8.*
kivy
kivy-garden.matplotlib
pandas
Expand All @@ -73,24 +73,24 @@ nano =

pc =
tensorflow==2.15.*
matplotlib
matplotlib==3.8.*
kivy
kivy-garden.matplotlib
pandas
plotly
albumentations

macos =
tensorflow-macos==2.15.*
matplotlib
tensorflow==2.15.*
matplotlib==3.8.*
kivy
kivy-garden.matplotlib
pandas
plotly
albumentations

dev =
pytest
pytest==8.1.*
pytest-cov
responses
mypy
Expand Down

0 comments on commit 8b96b7a

Please sign in to comment.