我尝试用tensorflow的random_transform
方法为图像生成6个随机变换。下面是我的代码:
train_image_generator = ImageDataGenerator(rescale=1./255)
train_data_gen = train_image_generator.flow_from_directory(
train_dir,
target_size=(IMG_HEIGHT, IMG_WIDTH),
color_mode='rgb',
classes=None,
class_mode='categorical',
batch_size=128,
shuffle='True',
seed=None,
save_to_dir=None,
save_prefix='',
save_format='png',
follow_links=False,
subset=None,
interpolation="nearest")
train_image_generator = train_image_generator.random_transform(
train_data_gen[0][0][0],
seed=None)
我得到以下错误:
random_transform() missing 1 required positional argument: 'x'
我的train_data_gen[0][0][0]
是一个3D数组-我不知道我的错误在哪里。
random_transform
是ImageDataGenerator
对象的一个方法。所以,你需要像这样:
train_image_generator = ImageDataGenerator()
train_image_generator.random_transform(train_data_gen[0][0][0], seed=None)