2016-11-04 100 views
0

我下面https://www.kaggle.com/freeman89/dogs-vs-cats-redux-kernels-edition/create-dataset-with-tensorflow图像resize_func错误

的问题是关于tf.image.resize_image_with_crop_or_pad

resize_func = lambda image: tf.image.resize_image_with_crop_or_pad(image, HEIGHT, WIDTH) 

--------------------------------------------------------------------------- 
ValueError        Traceback (most recent call last) 
<ipython-input-12-907e45393ea9> in <module>() 
----> 1 processed_train_images = decode_image(train_image_file_names, resize_func=resize_func) 
     2 processed_test_images = decode_image(test_image_file_names, resize_func=resize_func) 

<ipython-input-4-bd49dae09433> in decode_image(image_file_names, resize_func) 
    12   image = tf.image.decode_jpeg(file) 
    13   if resize_func != None: 
---> 14    image = resize_func(image) 
    15 
    16  with tf.Session(graph=graph) as session: 

<ipython-input-11-a8bf1ee259c1> in <lambda>(image) 
     1 WIDTH=500 
     2 HEIGHT=500 
----> 3 resize_func = lambda image: tf.image.resize_image_with_crop_or_pad(image, HEIGHT, WIDTH) 

//anaconda/lib/python2.7/site-packages/tensorflow/python/ops/image_ops.pyc in resize_image_with_crop_or_pad(image, target_height, target_width) 
    532 """ 
    533 image = ops.convert_to_tensor(image, name='image') 
--> 534 _Check3DImage(image, require_static=True) 
    535 original_height, original_width, _ = _ImageDimensions(image) 
    536 

//anaconda/lib/python2.7/site-packages/tensorflow/python/ops/image_ops.pyc in _Check3DImage(image, require_static) 
    219  raise ValueError('\'image\' must be three-dimensional.') 
    220 if require_static and not image_shape.is_fully_defined(): 
--> 221  raise ValueError('\'image\' must be fully defined.') 
    222 if any(x == 0 for x in image_shape): 
    223  raise ValueError('all dims of \'image.shape\' must be > 0: %s' % 

ValueError: 'image' must be fully defined. 

参考:Why do I get ValueError('\'image\' must be fully defined.') when transforming image in Tensorflow?

+0

你知道图像的形状应该是什么吗?你有没有尝试用set_shape设置它? –

+0

你在使用队列吗? – Steven

回答

-1

u可以使用tf.map_fn()来解决这个问题