Search code examples
pythonimage-processingtensorflowtensorboard

Tensorboard tf.summary.image strange image colors


I am loading a series of 128x128 uint8 color images to Tensorflow using:

x = tf.placeholder(tf.float32, shape=[None, img_size,img_size,num_channels], name='x-input')

I first check that the image I am loading is fine so I check it using Matplotlib (notice Matplotlib uses BGR colors so I fix it before displaying):

plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.show()

and I get the following image:

enter image description here

which is what I expect. I then load to Tensorboard with:

tf.summary.image('input', x, 1)

but the image show is:

enter image description here

Image is ok but the colors are all messed up. Any ideas what could be happening?


Solution

  • Never mind, it was CV2.imread that was causing the problem. CV2 reads BGR instead of RGB, so the images where loaded incorrectly and Tensorflow was showing them as it should.