utils/SegmentationDataLoader.py
def data_batch(self, shuffle=False, one_hot_encode=True, batch_size=16, num_threads=2, buffer=32):
        """
        Reads data, normalizes it, shuffles it, then batches it, returns a
        the next element in dataset op and the dataset initializer op.
        :param shuffle: Boolean, whether to shuffle data in buffer or not.
        :param batch_size: Number of images/masks in each batch returned.
        :param one_hot_encode: Boolean, whether to one hot encode the mask image or not.
            Encoding will done according to the palette specified when
            initializing the object.
        :param num_threads: Number of parallel subprocesses to load data.
        :param buffer: Number of images to prefetch in buffer.
        :return:
            next_element: A tensor with shape [2], where next_element[0]
                          is image batch, next_element[1] is the corresponding
                          mask batch.
            init_op: Data initializer op, needs to be executed in a session
                     for the data queue to be filled up and the next_element op
                     to yield batches.
        """

        # Create dataset out of the 2 files:
        data = tf.data.Dataset.from_tensor_slices(
            (self.image_paths_tensor, self.mask_paths_tensor))

        # Parse images and labels
        data = data.map(
            self._parse_data, num_parallel_calls=num_threads).prefetch(buffer)

        # One hot encode the mask
        if one_hot_encode:
            if self.palette is None:
                raise ValueError('No Palette for one-hot encoding specified in the data loader!')
            data = data.map(self._one_hot_encode, num_parallel_calls=num_threads).prefetch(buffer)

        # Batch the data
        data = data.batch(batch_size)

        # Normalize
        data = data.map(self._normalize_data,
                        num_parallel_calls=num_threads).prefetch(buffer)

        if shuffle:
            data = data.shuffle(buffer)

        # Create iterator
        iterator = tf.data.Iterator.from_structure(
            data.output_types, data.output_shapes)

        # Next element Op
        next_element = iterator.get_next()

        # Data set init. op
        init_op = iterator.make_initializer(data)

        return next_element, init_op

        Reads data, normalizes it, shuffles it, then batches it, returns a
        the next element in dataset op and the dataset initializer op.
        :param shuffle: Boolean, whether to shuffle data in buffer or not.
        :param batch_size: Number of images/masks in each batch returned.
        :param one_hot_encode: Boolean, whether to one hot encode the mask image or not.
            Encoding will done according to the palette specified when
            initializing the object.
        :param num_threads: Number of parallel subprocesses to load data.
        :param buffer: Number of images to prefetch in buffer.
        :return:
            next_element: A tensor with shape [2], where next_element[0]
                          is image batch, next_element[1] is the corresponding
                          mask batch.
            init_op: Data initializer op, needs to be executed in a session
                     for the data queue to be filled up and the next_element op
                     to yield batches.
        
Reads data, normalizes it, shuffles it, then batches it, returns a
the next element in dataset op and the dataset initializer op.
Reads data normalizes it shuffles it then batches it returns a the next element in dataset op and the dataset initializer op .
def data_batch(self, shuffle=False, one_hot_encode=True, batch_size=16, num_threads=2, buffer=32):
        data = tf.data.Dataset.from_tensor_slices(
            (self.image_paths_tensor, self.mask_paths_tensor))
        data = data.map(
            self._parse_data, num_parallel_calls=num_threads).prefetch(buffer)
        if one_hot_encode:
            if self.palette is None:
                raise ValueError('No Palette for one-hot encoding specified in the data loader!')
            data = data.map(self._one_hot_encode, num_parallel_calls=num_threads).prefetch(buffer)
        data = data.batch(batch_size)
        data = data.map(self._normalize_data,
                        num_parallel_calls=num_threads).prefetch(buffer)
        if shuffle:
            data = data.shuffle(buffer)
        iterator = tf.data.Iterator.from_structure(
            data.output_types, data.output_shapes)
        next_element = iterator.get_next()
        init_op = iterator.make_initializer(data)
        return next_element, init_op
def data_batch ( self , shuffle = False , one_hot_encode = True , batch_size = 16 , num_threads = 2 , buffer = 32 ) : data = tf . data . Dataset . from_tensor_slices ( ( self . image_paths_tensor , self . mask_paths_tensor ) ) data = data . map ( self . _parse_data , num_parallel_calls = num_threads ) . prefetch ( buffer ) if one_hot_encode : if self . palette is None : raise ValueError ( 'No Palette for one-hot encoding specified in the data loader!' ) data = data . map ( self . _one_hot_encode , num_parallel_calls = num_threads ) . prefetch ( buffer ) data = data . batch ( batch_size ) data = data . map ( self . _normalize_data , num_parallel_calls = num_threads ) . prefetch ( buffer ) if shuffle : data = data . shuffle ( buffer ) iterator = tf . data . Iterator . from_structure ( data . output_types , data . output_shapes ) next_element = iterator . get_next ( ) init_op = iterator . make_initializer ( data ) return next_element , init_op
Reads data, normalizes it, shuffles it, then batches it, returns a
the next element in dataset op and the dataset initializer op.
Reads data normalizes it shuffles it then batches it returns a the next element in dataset op and the dataset initializer op .
"""
        Reads data, normalizes it, shuffles it, then batches it, returns a
        the next element in dataset op and the dataset initializer op.
        :param shuffle: Boolean, whether to shuffle data in buffer or not.
        :param batch_size: Number of images/masks in each batch returned.
        :param one_hot_encode: Boolean, whether to one hot encode the mask image or not.
            Encoding will done according to the palette specified when
            initializing the object.
        :param num_threads: Number of parallel subprocesses to load data.
        :param buffer: Number of images to prefetch in buffer.
        :return:
            next_element: A tensor with shape [2], where next_element[0]
                          is image batch, next_element[1] is the corresponding
                          mask batch.
            init_op: Data initializer op, needs to be executed in a session
                     for the data queue to be filled up and the next_element op
                     to yield batches.
        """ # Create dataset out of the 2 files: # Parse images and labels # One hot encode the mask # Batch the data # Normalize # Create iterator # Next element Op # Data set init. op
A tensor with shape [2], where next_element[0]
is image batch, next_element[1] is the corresponding
mask batch.
init_op: Data initializer op, needs to be executed in a session
for the data queue to be filled up and the next_element op
to yield batches.
A tensor with shape [ 2 ] where next_element [ 0 ] is image batch next_element [ 1 ] is the corresponding mask batch . init_op : Data initializer op needs to be executed in a session for the data queue to be filled up and the next_element op to yield batches .
self
shuffle
Boolean, whether to shuffle data in buffer or not.
Boolean whether to shuffle data in buffer or not .
one_hot_encode
Boolean, whether to one hot encode the mask image or not.
Encoding will done according to the palette specified when
initializing the object.
Boolean whether to one hot encode the mask image or not . Encoding will done according to the palette specified when initializing the object .
batch_size
Number of images/masks in each batch returned.
Number of images / masks in each batch returned .
num_threads
Number of parallel subprocesses to load data.
Number of parallel subprocesses to load data .
buffer
Number of images to prefetch in buffer.
Number of images to prefetch in buffer .