Code Monkey home page Code Monkey logo

Comments (2)

danijar avatar danijar commented on August 22, 2024

You need to start the queue runners for filename_queue to get populated. Here are some examples: https://www.tensorflow.org/programmers_guide/threading_and_queues

from tensorflowbook.

michael-GitHub-0 avatar michael-GitHub-0 commented on August 22, 2024

Thanks for your answer!! I used BGPark's code and got it to work. Sorry, I am new to Python (and GitHub) so I struggle a bit with the coding. I also played around a bit in case anyone is interested for themselves:

# Create H image.
import numpy as np
h=np.array([[[  0,   0,   0],
        [255, 255, 255],
        [254,   0,   0]],

       [[  0, 191,   0],
        [  3, 108, 233],
        [  0, 191,   0]],

       [[254,   0,   0],
        [255, 255, 255],
        [  0,   0,   0]]], dtype='uint8')
h.shape

# Display created H image.
from matplotlib import pyplot as plt
plt.imshow(h, interpolation=None)
plt.show()

# Export H image as a jpg.
import matplotlib
matplotlib.image.imsave('my_dir/H.jpg', h)

# Import H image into TensorFlow.
import tensorflow as tf

image_filename = "my_dir/H.jpg"
filename_queue = tf.train.string_input_producer([image_filename])

image_reader = tf.WholeFileReader()
_, image_file = image_reader.read(filename_queue)
image = tf.image.decode_jpeg(image_file)

sess = tf.Session()

sess.run(tf.global_variables_initializer())
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord, sess=sess)

a = sess.run(image)
a.shape

# Display imported H image.
from matplotlib import pyplot as plt
plt.imshow(a, interpolation=None)
plt.show()

from tensorflowbook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.