Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: TensorFlow:ValueError: 'images' contains no shape

mxl:

I used TensorFlow function tf.image.resize_images to resize my image, but I got this Error in Code: ValueError: 'images' contains no shape. The full code is below:


# -*- coding: utf-8 -*-
import tensorflow as tf
file = ["./1.jpg"]
f = tf.train.string_input_producer(file)
reader = tf.WholeFileReader()
key, img = reader.read(f)

img = tf.image.decode_image(img)
# img.set_shape([218,178,3])
img = tf.image.resize_images(img, [64,64])

coord = tf.train.Coordinator()
with tf.Session() as sess:
tf.train.start_queue_runners(coord=coord)
image = sess.run(img)

The full Error information is


Traceback (most recent call last):
File "image_read_test.py", line 10, in
img = tf.image.resize_images(img, [64,64])
File "C:\Python35\lib\site-packages\tensorflow\python\ops\image_ops_impl.py", line 724, in resize_images
raise ValueError('\'images\' contains no shape.')
ValueError: 'images' contains no shape.

Then I try to fix this, but only find a way like that


# -*- coding: utf-8 -*-
import tensorflow as tf
file = ["./1.jpg"]
f = tf.train.string_input_producer(file)
reader = tf.WholeFileReader()
key, img = reader.read(f)

img = tf.image.decode_image(img)
# img.set_shape([218,178])
# img = tf.image.resize_images(img, [64,64])

coord = tf.train.Coordinator()
with tf.Session() as sess:
tf.train.start_queue_runners(coord=coord)
image = sess.run(img)
image = tf.image.resize_images(image, [64,64])

Only in this way the function can work well, But I don't know why? Is the function tf.image.resize_images only take the numpy array as parameter? Or I can find another way to solve this problem? NB: img.set_shape([218,78,3]) does not work for me



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: TensorFlow:ValueError: 'images' contains no shape

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×