Keras:ImageDataGenerator产生的图像中出现奇怪的伪像

时间:2019-03-26 10:12:27

标签: keras

我已指示数据生成器输出生成的图像。

train_datagen = ImageDataGenerator(
        rescale=1. / 255,
        rotation_range=180,  # randomly rotate images in the range (degrees, 0 to 180)
        width_shift_range=0.1,  # randomly shift images horizontally (fraction of total width)
        height_shift_range=0.1,  # randomly shift images vertically (fraction of total height)
        zoom_range=0.2,
        horizontal_flip=True,  # randomly flip images
        vertical_flip=True
    ) 

train_generator = train_datagen.flow_from_directory(
        os.path.join(train_base, train_dir),
        target_size=(img_width, img_height),
        batch_size=batch_size,
        class_mode='binary',
        color_mode='grayscale',
        save_to_dir=gen_train_dir,
    )

运行后,我在输出目录中发现一些带有奇怪伪像的图像。在belof图片上,我只用黄色电路标记了一个,但是我认为这很明显,其他单元格中包含不自然的线条伪像。

enter image description here

它们为什么出现?

我怀疑它们会影响准确性。

1 个答案:

答案 0 :(得分:2)

您看到的工件是由生成器引起的。缩放/旋转/移动时,新图像将需要“填充”原始图像中不存在的一些像素。默认情况下,如果使用fill_mode="nearest的方式,那么它只需要最近的像素来填充它。

如果其他模式更适合您的问题,则可能需要测试它们。 All options can be found here