I am using Tensorflow Dataset API and reading data from TFRecord files. I can use the map function and use method like random_flip_left_right, random_crop for data augmentation.
However when I am trying to replicate AlexNet paper I am facing an issue. I need to flip each image and then take 5 crops ( left, top, bottom, right & middle).
So the input dataset size will increase by 10 times. Is there anyway to do this using tensorflow dataset API? The map() function just returns the one image and I am not able to increase the number of images.
Please see the code I have now.
dataset = dataset.map(parse_image, num_parallel_calls=tf.data.experimental.AUTOTUNE) \
.map(lambda image, label: (tf.image.random_flip_left_right(image), label), num_parallel_calls=tf.data.experimental.AUTOTUNE) \
.map(lambda image, label: (tf.image.random_crop(image, size=[227, 227, 3]), label), num_parallel_calls=tf.data.experimental.AUTOTUNE) \
.shuffle(buffer_size=1000) \
.repeat() \
.batch(256) \
.prefetch(tf.data.experimental.AUTOTUNE)