Train Test Helpers

src.pipelines.tensorflow_v2.helpers.train_test.get_filepath_list(base_dir, leaf_ext, mask_ext, incl_aug=True)[source]

Gets a list of leaf and mask file paths. The folder structure needs to have been created using this code base.

Parameters
  • base_dir (str) – base directory file path

  • leaf_ext (str) – the leaf extension

  • mask_ext (str) – the mask extension

  • incl_aug (bool) – whether augmented images should be used

Return type

Tuple[List[str], List[str]]

Returns

a list of leaf and mask file paths, as two separate lists

src.pipelines.tensorflow_v2.helpers.train_test.get_tf_dataset(base_dir, leaf_ext, mask_ext, incl_aug=False, cfp=True, batch_size=2, buffer_size=200, leaf_shape=(512, 512, 1), mask_shape=(512, 512, 1), test=False, shift_256=False, transform_uint8=False)[source]

Creates a tf dataset, which has samples consisited of leaf, mask pairs. The dataset is also configured for performance. Both the dataset and list of leaf names are returned.

Parameters
  • base_dir (str) – the base directory; the subfolders in this directory should contain the leaf and mask images the dataset will use

  • leaf_ext (str) – the leaf extensions

  • mask_ext (str) – the mask extensions

  • incl_aug (bool) – whether augmented images should be included

  • cfp (bool) – whether to configure the datasest for performance

  • batch_size (int) – the batch size

  • buffer_size (int) – the buffer size; this controls the extent of shuffling in the dataset

  • leaf_shape (Tuple[int, int, int]) – the leaf shape

  • mask_shape (Tuple[int, int, int]) – the mask shape

  • test (bool) – whether a test set dataset is being configured

  • shift_256 (bool) – whether the leaf images should be shifted by 256

  • transform_uint8 (bool) – whether the leaf images should be transformed to a uint8 format

Return type

Tuple[DatasetV2, List[str]]

Returns

a tf dataset and a list of leaf file paths