Write an image summary.

Used in the notebooks

Used in the tutorials

See also tf.summary.scalar, tf.summary.SummaryWriter.

Writes a collection of images to the current default summary writer. Data appears in TensorBoard's 'Images' dashboard. Like tf.summary.scalar points, each collection of images is associated with a step and a name. All the image collections with the same name constitute a time series of image collections.

This example writes 2 random grayscale images:

w = tf.summary.create_file_writer('test/logs')
with w.as_default():
  image1 = tf.random.uniform(shape=[8, 8, 1])
  image2 = tf.random.uniform(shape=[8, 8, 1])
  tf.summary.image("grayscale_noise", [image1, image2], step=0)

To avoid clipping, data should be converted to one of the following:

  • floating point values in the range [0,1], or
  • uint8 values in the range [0,255]
# Convert the original dtype=int32 `Tensor` into `dtype=float64`.
rgb_image_float = tf.constant([
  [[1000, 0, 0], [0, 500, 1000]],
]) / 1000
tf.summary.image("picture", [rgb_image_float], step=0)

# Convert original dtype=ui