【问题标题】:Keras: How does reprocessing scale images?Keras:再处理如何缩放图像?
【发布时间】:2021-01-28 19:38:43
【问题描述】:

为了从磁盘加载图像数据,Keras 提供了tf.keras.preprocessing.image_dataset_from_directory() 方法,该方法记录在https://keras.io/api/preprocessing/image/ 上。 我想使用这种方法来加载数据以生成图像分类器。 https://machinelearningmastery.com/how-to-load-large-datasets-from-directories-for-deep-learning-with-keras/ 包含一些关于如何最好地组织数据的信息。

image_dataset_from_directory() 采用强制参数 image_size=(..., ...) 以将所有图像的大小设置为相同(后续步骤需要此参数)。
在哪里可以找到有关如何缩放图片的详细信息?
具有极端比例的图片是否会失真并对分类器产生负面影响?

【问题讨论】:

    标签: python tensorflow keras deep-learning


    【解决方案1】:

    它使用任何tf.image.ResizeMethod。你可以在Tensorflowdocumentation找到源代码。

    【讨论】:

      【解决方案2】:

      我无法找到有关如何调整大小的细节。但是它可能使用下面列出的 cv2 中可用的一种方法,但我不知道是哪一种。

      [optional] flag that takes one of the following methods. INTER_NEAREST – a nearest-neighbor interpolation INTER_LINEAR – a bilinear interpolation (used by default) INTER_AREA – resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method. INTER_CUBIC – a bicubic interpolation over 4×4 pixel neighborhood INTER_LANCZOS4 – a Lanczos interpolation over 8×8 pixel neighborhood
      

      当然,在调整大小时,您的图像会变形。我做了很多图像分类,并没有发现这是一个问题。除此之外,似乎别无选择,只能让所有图像大小相同。

      【讨论】:

      • 嗨,格里,感谢您的回答。知道 Keras 使用 cv2 已经很有帮助。
      • 我不认为 Keras 使用 cv2。我刚才提到它是因为它说明了调整大小方法的类型。
      猜你喜欢
      • 2018-04-25
      • 1970-01-01
      • 2019-02-26
      • 1970-01-01
      • 1970-01-01
      • 2017-09-21
      • 1970-01-01
      • 2019-01-20
      • 1970-01-01
      相关资源
      最近更新 更多