如何在 Keras 更改 ImageDataGenerator 的 pre_processing 函数执行顺序?
How to change pre_processing function execution order for ImageDataGenerator at Keras?
我正在使用 Keras 的“ImageDataGenerator”class 进行数据扩充。由于图像具有相关对象的边界框,因此我想在增强图像之前将图像裁剪到相关部分。 class 在其参数中有一个名为“preprocessing_function”的参数,它允许我们在扩充和调整大小后实现所需的功能。我要求相反的情况发生。首先,让函数 运行,然后进行扩充。我如何在代码中实现它?
tf.keras.preprocessing.image.ImageDataGenerator(
featurewise_center=False,
samplewise_center=False,
featurewise_std_normalization=False,
samplewise_std_normalization=False,
zca_whitening=False,
zca_epsilon=1e-06,
rotation_range=0,
width_shift_range=0.0,
height_shift_range=0.0,
brightness_range=None,
shear_range=0.0,
zoom_range=0.0,
channel_shift_range=0.0,
fill_mode="nearest",
cval=0.0,
horizontal_flip=False,
vertical_flip=False,
rescale=None,
preprocessing_function=None,
data_format=None,
validation_split=0.0,
dtype=None,
)
preprocessing_function: a function that will be applied to each input. The function will run after the image is resized and augmented. The function should take one argument: one image (Numpy tensor with rank 3) and should output a Numpy tensor with the same shape.
Keras 团队成员说 ImageDataGenerator class 是遗留的。他们建议我使用转换层。它们可以在训练时随时使用。
转换层的用法示例:Keras Transformation layers example page
Github 问题(已关闭):GitHub Issues
我正在使用 Keras 的“ImageDataGenerator”class 进行数据扩充。由于图像具有相关对象的边界框,因此我想在增强图像之前将图像裁剪到相关部分。 class 在其参数中有一个名为“preprocessing_function”的参数,它允许我们在扩充和调整大小后实现所需的功能。我要求相反的情况发生。首先,让函数 运行,然后进行扩充。我如何在代码中实现它?
tf.keras.preprocessing.image.ImageDataGenerator(
featurewise_center=False,
samplewise_center=False,
featurewise_std_normalization=False,
samplewise_std_normalization=False,
zca_whitening=False,
zca_epsilon=1e-06,
rotation_range=0,
width_shift_range=0.0,
height_shift_range=0.0,
brightness_range=None,
shear_range=0.0,
zoom_range=0.0,
channel_shift_range=0.0,
fill_mode="nearest",
cval=0.0,
horizontal_flip=False,
vertical_flip=False,
rescale=None,
preprocessing_function=None,
data_format=None,
validation_split=0.0,
dtype=None,
)
preprocessing_function: a function that will be applied to each input. The function will run after the image is resized and augmented. The function should take one argument: one image (Numpy tensor with rank 3) and should output a Numpy tensor with the same shape.
Keras 团队成员说 ImageDataGenerator class 是遗留的。他们建议我使用转换层。它们可以在训练时随时使用。
转换层的用法示例:Keras Transformation layers example page
Github 问题(已关闭):GitHub Issues