【发布时间】:2021-08-23 02:05:12
【问题描述】:
我有一个名为 TRAIN 的目录,它有 37 个子目录,其中包含不同大小的图像,我想用 TensorFlow 的 ImageDataGenerator 加载这些图像,但它需要相同大小的图像。我想为这些图像添加填充以调整它们的大小。
tf.image.resize_with_crop_or_pad(
image, target_height, target_width
)
我在网上找到了上面的代码,但我不知道如何使用它。
【问题讨论】:
-
没有。
ImageDataGenerator不希望所有图像的大小相同。您可以在生成器中通过target_size=(width, height)参数指定输出大小。 -
所以,如果我的一张图片是(230, 300),如果我指定 target_size=(400, 400),它会将图片拉伸到 (400,400) 还是将添加填充? @Kaveh
-
它将使用
nearest方法,这是interpolation的默认值。如果您愿意,可以使用其他方法。检查这个:tensorflow.org/api_docs/python/tf/keras/preprocessing/image/…
标签: tensorflow image-processing