How should I implement an augmentation pipeline in which my dataset gets extended instead of replacing the images with the augmented ones, that means, how to use map calls to augment and preserve the original samples?
Code I'm currently using:
records_path = DATA_DIR+'/'+'TFRecords'+TRAIN+'train_0.tfrecord'
# Create a dataset
dataset = tf.data.TFRecordDataset(filenames=records_path)
dataset = dataset.map(parsing_fn).cache().map(lambda image, label: (tf.image.central_crop(image,0.5),label))
dataset = dataset.shuffle(100)
dataset = dataset.batch(2)
iterator = tf.compat.v1.data.make_one_shot_iterator(dataset)
I was expecting from the code above that by iterating through batches I would get the original image and its cropped version, besides that i guess that i haven't properly understand how the cache method behaves.
Then I have used the code below to exhibit the images, that plots random cropped images.
iterator = tf.compat.v1.data.make_one_shot_iterator(dataset)
for i in range(10):
image,label = iterator.get_next()
img_array = image[0].numpy()
plt.imshow(img_array)
plt.show()
print('label: ', label[0])
img_array = image[1].numpy()
plt.imshow(img_array)
plt.show()
print('label: ', label[1])