Now let's look at how TensorFlow loads images. Let's define a constant with a small array of three images and load them into a session:
sess = tf.InteractiveSession()image_batch = tf.constant([ [ # First Image [[255, 0, 0], [255, 0, 0], [0, 255, 0]], [[255, 0, 0], [255, 0, 0], [0, 255, 0]] ], [ # Second Image [[0, 0, 0], [0, 255, 0], [0, 255, 0]], [[0, 0, 0], [0, 255, 0], [0, 255, 0]] ], [ # Third Image [[0, 0, 255], [0, 0, 255], [0, 0, 255]], [[0, 0, 255], [0, 0, 255], [0, 0, 255]] ] ]) print(image_batch.get_shape()) print(sess.run(image_batch)[1][0][0])
The output of the preceding listing shows the shape of the tensor and the first pixel of the first image. In this example code, an array of images is created ...