我正在尝试训练一个分类图像的模型。问题在于,这些图像的大小不同。我应该如何格式化我的图像或模型架构?
我正在尝试训练一个分类图像的模型。问题在于,这些图像的大小不同。我应该如何格式化我的图像或模型架构?
N
个不同的图像。填充选项可能会向网络的预测引入额外的错误源,因为网络可能(即:很可能)会偏向包含这样的填充边框的图像。
如果您需要一些想法,请查看TensorFlow文档中的Images部分,其中有一些像resize_image_with_crop_or_pad
这样的代码片段可以减轻工作负担。
关于不关心压缩的问题,这里是著名的Inception网络预处理管道的一部分:
# This resizing operation may distort the images because the aspect
# ratio is not respected. We select a resize method in a round robin
# fashion based on the thread number.
# Note that ResizeMethod contains 4 enumerated resizing methods.
# We select only 1 case for fast_mode bilinear.
num_resize_cases = 1 if fast_mode else 4
distorted_image = apply_with_random_selector(
distorted_image,
lambda x, method: tf.image.resize_images(x, [height, width], method=method),
num_cases=num_resize_cases)