I tried to read my own images for training in TensorFlow. However, there seems to be an error:

ValueError: 'size' must be a 1-D Tensor of 2 elements: new_height, new_width. 

What is wrong with the following code sample?

filenames=['images/000001.jpg','images/000002.jpg','images/000003.jpg','images/000004.jpg'] labels=[1,0,1,0] filename_queue=tf.train.string_input_producer(filenames) reader=tf.WholeFileReader() filename, content = reader.read(filename_queue) images=tf.image.decode_jpeg(content, channels=3) images=tf.cast(images, tf.float32) resized_images=tf.image.resize_images(images, 224, 224) image_batch, label_batch=tf.train.batch([resized_images, labels], batch_size=2) 
1

2 Answers

The error says, size must be a 1-D Tensor. What tensorflow actually means with this is just to make the second argument of tf.image.resize_images a tuple:

resized_images = tf.image.resize_images(images, (224, 224)) 

I got the same error and simply make the tuple a tensorflow constant

resized_images= tf.image.resize(images, tf.constant([224, 224]) 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy