【发布时间】:2016-06-12 08:46:33
【问题描述】:
我想使用tf.image.resize_image_with_crop_or_pad 裁剪输入图像的一部分。但是出现了一个错误:ValueError: 'image' must be fully defined。我检查了Why do I get ValueError('\'image\' must be fully defined.') when transforming image in Tensorflow? 我添加了Tensor.set_shape() 但它也无法工作。
我列出我的代码和错误如下:
example = tf.image.decode_png(file_contents, channels=3)
example.set_shape = ([256,256,3])
crop_image = tf.image.resize_image_with_crop_or_pad(example, crop_size, crop_size)
错误:
File "/home/kang/Documents/work_code_PC1/VGG_tensorflow_UCMerced/readUClandUsedImagetxt.py", line 97, in _input_pipeline
crop_image = tf.image.resize_image_with_crop_or_pad(image, crop_size, crop_size)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/image_ops.py", line 534, in resize_image_with_crop_or_pad
_Check3DImage(image, require_static=True)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/image_ops.py", line 221, in _Check3DImage
raise ValueError('\'image\' must be fully defined.')
ValueError: 'image' must be fully defined.
即使我将某些形状设置为图像,我也不知道为什么会出现错误。 但是,我这样测试代码:
example = tf.image.decode_png(file_contents, channels=3)
example = tf.reshape(example, [256,256,3])
crop_image = tf.image.resize_image_with_crop_or_pad(example, crop_size, crop_size)
它有效。我认为重塑为相同的形状不会改变张量中值的顺序,对吗?也许它可以成为解决方案。
【问题讨论】:
标签: python tensorflow deep-learning