Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chapter 5 working with images page 161 #22

Open
zmc1021 opened this issue Feb 25, 2017 · 0 comments
Open

chapter 5 working with images page 161 #22

zmc1021 opened this issue Feb 25, 2017 · 0 comments

Comments

@zmc1021
Copy link

zmc1021 commented Feb 25, 2017

I downloaded the code of ch5's test-input-image.jpg and tried to replicate the results shown at the bottom of the page, array([[[..., but I couldn't get it run.
import tensorflow as tf
import numpy as np
import Image
sess = tf.Session()
image_filename = "test-input-image.jpg"

loaded the image directly in the folder of the script

display images in python

img = Image.open(image_filename)

img.show()

display images in python

print image_filename
filename_queue = tf.train.string_input_producer(tf.train.match_filenames_once(image_filename))
print filename_queue
image_reader = tf.WholeFileReader()
key,image_file = image_reader.read(filename_queue)
print key
print image_file
image = tf.image.decode_jpeg(image_file)
print image
sess.run(tf.global_variables_initializer())
sess.run(image)
print(sess.run(image))
and the results are
<tensorflow.python.ops.data_flow_ops.FIFOQueue object at 0x7f555b882110>
Tensor("ReaderRead:0", shape=(), dtype=string)
Tensor("ReaderRead:1", shape=(), dtype=string)
Tensor("DecodeJpeg:0", shape=(?, ?, ?), dtype=uint8)

Clearly, the image was not read in properly, otherwise why shape=(?,?,?) after decode_jpeg. I also used the python code to display the input at the beginening to make sure the jpeg image was correctly read in, which is true.
I would appreciate it if someone could provide some insights what the problem could be.
Thanks in advance for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant