Newer
Older
""" Helper function used for augmentation of images in the dataset.
Returns:
tf.data.Dataset mappable function for image augmentation
"""
times = tf.random.uniform(minval=1, maxval=4, dtype=tf.int32, shape=[])
return (tf.image.rot90(data, times),
tf.image.rot90(label, times))
def flip_fn(data, label):
return (tf.image.flip_left_right(data),
tf.image.flip_left_right(label))
# Randomly returning unchanged data (~20%)
return tf.cond(
tf.less_equal(tf.random.uniform([]), 0.2),