edflow.iterators.tf_batches module

Summary

Functions:

image_grid

Arrange a minibatch of images into a grid to form a single image.

tf_batch_to_canvas

reshape a batch of images into a grid canvas to form a single image.

Reference

edflow.iterators.tf_batches.tf_batch_to_canvas(X, cols: int = None)[source]

reshape a batch of images into a grid canvas to form a single image.

Parameters
  • X (Tensor) – Batch of images to format. [N, H, W, C]-shaped

  • cols (int :) –

  • cols – (Default value = None)

Returns

image_grid – Tensor representing the image grid. [1, HH, WW, C]-shaped

Return type

Tensor

Examples

x = np.ones((9, 100, 100, 3)) x = tf.convert_to_tensor(x) canvas = batches.tf_batch_to_canvas(x) assert canvas.shape == (1, 300, 300, 3)

canvas = batches.tf_batch_to_canvas(x, cols=5) assert canvas.shape == (1, 200, 500, 3)

edflow.iterators.tf_batches.image_grid(input_tensor, grid_shape, image_shape=(32, 32), num_channels=3)[source]

Arrange a minibatch of images into a grid to form a single image.

Parameters
  • input_tensor – Tensor. Minibatch of images to format, either 4D ([batch size, height, width, num_channels]) or flattened ([batch size, height * width * num_channels]).

  • grid_shape – Sequence of int. The shape of the image grid, formatted as [grid_height, grid_width].

  • image_shape – Sequence of int. The shape of a single image, formatted as [image_height, image_width]. (Default value = (32)

  • 32)

  • num_channels – (Default value = 3)

Returns

Return type

Tensor representing a single image in which the input images have been

Raises

ValueError – The grid shape and minibatch size don’t match, or the image shape and number of channels are incompatible with the input tensor.