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)
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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With