为什么 `tf.image.resize_images` 不设置图像形状?
Why doesn't `tf.image.resize_images` set the image shape?
我的 objective 是为了数据扩充目的引入随机缩放和平移。
distorted_image = tf.image.resize_images(distorted_image, random_scale, random_scale)
distorted_image = tf.image.crop_to_bounding_box(distorted_image, random_y, random_x, 299, 299)
这失败了 'image' must be fully defined.
换行有效,但没有做我真正需要的。
distorted_image = tf.image.crop_to_bounding_box(distorted_image, random_y, random_x, 299, 299)
distorted_image = tf.image.resize_images(distorted_image, random_scale, random_scale)
所以看起来 resize_images 失去了图像张量的形状然后 crop_to_bouding_box
失败了。这是故意的,我错过了什么吗?为什么 random_crop
在调整大小后工作但 crop_to_bounding_box
不工作?
tf.image.resize_images()
操作做设置图像形状,在this line的实现。 (这是在 TensorFlow 0.7 中添加的。)
但是,如果 new_height
或 new_width
参数中的任何一个是动态值,则 TensorFlow 无法推断出该维度的单一形状,因此对该维度使用 None
.我在您的代码中注意到新的高度和宽度值称为 random_scale
:如果在每个步骤上绘制一个新的随机值,则形状的高度和宽度尺寸将具有 None
。
请注意,在这种情况下,tf.image.crop_to_bounding_box()
操作将不起作用,因为正如错误消息所指出的那样,当前的实现要求完全定义输入的形状。正如我在 , the best workaround might be to use the lower level ops from which tf.image.crop_to_bounding_box()
is implemented (in particular tf.slice()
中使用计算索引指出的那样)。
我的 objective 是为了数据扩充目的引入随机缩放和平移。
distorted_image = tf.image.resize_images(distorted_image, random_scale, random_scale)
distorted_image = tf.image.crop_to_bounding_box(distorted_image, random_y, random_x, 299, 299)
这失败了 'image' must be fully defined.
换行有效,但没有做我真正需要的。
distorted_image = tf.image.crop_to_bounding_box(distorted_image, random_y, random_x, 299, 299)
distorted_image = tf.image.resize_images(distorted_image, random_scale, random_scale)
所以看起来 resize_images 失去了图像张量的形状然后 crop_to_bouding_box
失败了。这是故意的,我错过了什么吗?为什么 random_crop
在调整大小后工作但 crop_to_bounding_box
不工作?
tf.image.resize_images()
操作做设置图像形状,在this line的实现。 (这是在 TensorFlow 0.7 中添加的。)
但是,如果 new_height
或 new_width
参数中的任何一个是动态值,则 TensorFlow 无法推断出该维度的单一形状,因此对该维度使用 None
.我在您的代码中注意到新的高度和宽度值称为 random_scale
:如果在每个步骤上绘制一个新的随机值,则形状的高度和宽度尺寸将具有 None
。
请注意,在这种情况下,tf.image.crop_to_bounding_box()
操作将不起作用,因为正如错误消息所指出的那样,当前的实现要求完全定义输入的形状。正如我在 tf.image.crop_to_bounding_box()
is implemented (in particular tf.slice()
中使用计算索引指出的那样)。