【问题标题】:Data augmentation with Keras produces almost white images使用 Keras 进行数据增强会产生几乎是白色的图像
【发布时间】:2019-04-08 08:15:48
【问题描述】:

我正在尝试使用 keras ImageDataGenerator 进行数据扩充。 我正在从包含一列中图像路径和另一列中标签的数据框中提取图像。现在,我只是想水平翻转图像。但是当我绘制图像时,图像看起来像是亮度被推到了最大值。我想知道这里发生了什么...有什么想法吗?

datagen = ImageDataGenerator(horizontal_flip=True)


# Configure batch size and retrieve one batch of images
for X_batch, y_batch in datagen.flow_from_dataframe(dataframe=data,
    x_col="File name",
    y_col="Driving direction",
    directory = "Self-Driving-Car/Training Data/",
    target_size = (480, 640),
    class_mode = "other"):
    # Show 9 images
    for i in range(0, 9):
        plt.subplot(330 + 1 + i)
        plt.imshow(X_batch[i])
    plt.show()
    break

【问题讨论】:

    标签: python keras data-augmentation


    【解决方案1】:

    好的,这只是一个绘图问题,这解决了它:

        plt.imshow(X_batch[i]/255)
    

    【讨论】:

      【解决方案2】:

      更一般地,请注意,如果您没有 0-255 范围内的 int 图像,ImageDataGenerator 可以根据某些增强选项的某些默认值将数据重新缩放到 0-255,而不是其他选项。亮度范围是一个重新调整为 0-255 的示例。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-11-20
        • 1970-01-01
        • 1970-01-01
        • 2018-09-17
        • 2016-11-04
        • 2018-02-24
        • 2015-04-24
        • 2023-03-28
        相关资源
        最近更新 更多