TfRecordSegmentationReader
TfRecordSegmentationReader class
dlf.data_generators.tf_record_segmentation_reader.TfRecordSegmentationReader(
path,
labelmap,
background_as_zero=True,
shuffle=True,
ignore=None,
remap=None,
preprocess_list=None,
shuffle_buffer=2000,
)
A data generator for segmentation tasks which uses the TFRecord format
Arguments
- path: str. Path to TFRecord file
- labelmap: str. Path to labelmap related to TFRecord file
- background_as_zero: bool. If true, the ID 0 is discribing the background. Defaults to True.
- shuffle: bool. If true, dataset is shuffled. Defaults to True.
- ignore: list of int. A list of integers where each number is ignored during validation e.g. label 255 in PascalVOC. Defaults to None.
- remap: dict[int, int]. Dictionary where the key is the source category which is remaped to the value, target id. Defaults to None.
- preprocess_list: dict. Dictionary where the value describes a preprocessing method and the values are the arguments. Defaults to None.
- shuffle_buffer: int. Size of shuffle buffer. For details check: tf.data.Dataset. Defaults to 2000.
Raises
- FileNotFoundError: If TFRecord file is not found
- FileNotFoundError: If Labelmap file is not found
YAML Configuration
Sample configuration for a segmentation reader that applies remapping and uses a list of pre-processing functions before passing the image to CNN.
input_reader:
training_reader:
name: tf_record_segmentation_reader
path: /mnt/data/datasets/wheeled_walker_100k_8fps_25switch/25k_sample_4_mask/training.tfrecord
labelmap: &labelmap /mnt/data/datasets/wheeled_walker_100k_8fps_25switch/label_map.pbtxt
ignore:
remap:
1:0
2:0
3:0
5:1
6:1
7:1
preprocess_list:
h_flip:
v_flip:
resize:
output_shape:
- 512
- 512
saturation:
brightness:
max_delta: 0.6
blur:
noise:
mean: 0
std: 5