Resizing Images for Training in Tensorflow
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...
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)
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])