我正在尝试使用Tensorflow将弹性变形应用于张量,
ds = tf.data.Dataset.from_tensor_slices((images, masks))
ds = ds.map(lambda x, y: self._preproc_samples(x, y, augment=True))
return ds
我的预处理功能如下:
def _preproc_samples(self, x, y):
flow = ...
x = tf.contrib.image.dense_image_warp(x, flow)
y = tf.contrib.image.dense_image_warp(y, flow)
...
return (x,y)
我的问题是:如何生成随机流,以便每对图像和标签都可以以相同的方式变形?
编辑:为清楚起见,我正在尝试实现类似https://www.kaggle.com/ori226/data-augmentation-with-elastic-deformations但使用张量的方法