I have a realtime application where I'm trying to classify images that come from a feed as they arrive. The classify_images example has:
image_data = tf.gfile.FastGFile(image, 'rb').read()
#...
with tf.Session() as sess:
predictions = sess.run(softmax_tensor,
{'DecodeJpeg/contents:0': image_data})
Where image is the path to the image file. However, I'm not reading images from a file, I'm receiving them as numpy arrays. What's the best way to run a Tensorflow session on a previously-acquired image? Also, is the best practice to create one session and one graph beforehand, and whenever a new frame is acquired, run the existing session on the new image, instead of creating a new graph and a new session?
Edit:
I tried:
images_placeholder = tensorflow.placeholder(tensorflow.int32)
predictions = sess.run(softmax_tensor,
{images_placeholder: image})
and it worked! Thanks sygi!
Edit 2:
This crashes after a while with no error message, and also every frame has the same labels predicted. I even create a new images_place object at each frame, yet I still get the same label.
image? You should feed different (batch of) images each time.imagesoftmax_tensor = sess.graph.get_tensor_by_name('softmax:0')every iteration in the loop, should that change per iteration?