beexplainable.preprocessing package
Submodules
beexplainable.preprocessing.dataset_transformers module
beexplainable.preprocessing.parsers module
Library for parsing image inputs before feeding them into the model.
- beexplainable.preprocessing.parsers.parse_image(file_id: str, img_lookup, img_w: int, img_h: int, root: str = './')[source]
Read image file and resize it to (img_w, img_h, 3).
- Parameters
file_id (str) – ID of the image to read.
img_lookup (tf.lookup.StaticHashTable) – Lookup table assigning file ID to file name.
img_w (int) – Image width after resizing.
img_h (int) – Image height after resizing.
root (str) – Root path where the image is stored. Defaults to current folder ./.
- Returns
Decoded image.
- Return type
Tensor
- beexplainable.preprocessing.parsers.parse_image_and_mask(file_id: str, img_lookup, img_w: int, img_h: int, root_img: str = './', root_mask: str = './masks/')[source]
Read image file, resize it to (img_w, img_h, 3) and read object mask and resize it to (img_w, img_h, 1).
- Parameters
file_id (str) – ID of the image to read.
img_lookup (tf.lookup.StaticHashTable) – Lookup table assigning file ID to file name.
img_w (int) – Image width after resizing.
img_h (int) – Image height after resizing.
root_img (str) – Root path where the image is stored. Defaults to current folder ./.
root_mask (str) – Root path where the mask is stored. Defaults to current folder ./masks/.
- Returns
Decoded image and binary mask
- Return type
Tuple[Tensor, Tensor]
- beexplainable.preprocessing.parsers.parse_to_dataset(file_ids: List[str], labels: List[int], dataset_map)[source]
Retrieves file names from file_ids, decodes and stores them along with labels in a tf.Dataset.
- Parameters
file_ids (list of strings) – File IDs to parse images from (will be keys of a dictionary mapping to the file names).
labels (list of integers) – Class labels corresponding to the images.
dataset_map – Function that maps a tuple of filenames and labels to a tuple of parsed images and labels.
- Returns
Dataset of decoded images and labels.
- Return type
tf.Dataset