tf.keras.visualization.plot_image_gallery

Displays a gallery of images with optional labels and predictions.

images A 4D tensor or NumPy array of images. Shape should be (batch_size, height, width, channels).
y_true A 1D tensor or NumPy array of true labels (class indices). Defaults to None.
y_pred A 1D tensor or NumPy array of predicted labels (class indices). Defaults to None.
label_map A dictionary mapping class indices to class names. Required if y_true or y_pred are provided. Defaults to None.
value_range A tuple specifying the value range of the images (e.g., (0, 255) or (0, 1)). Defaults to (0, 255).
rows The number of rows in the gallery. If None, it's calculated based on the number of images and cols. Defaults to None.
cols The number of columns in the gallery. If None, it's calculated based on the number of images and rows. Defaults to None.
scale A float controlling the size of the displayed images. The images are scaled by this factor. Defaults to 2.
path The path to save the generated gallery image. If None, the image is displayed using plt.show(). Defaults to None.
show Whether to display the image using plt.show(). If True, the image is displayed. If False, the image is not displayed. Ignored if path is not None. Defaults to True if path is None, False otherwise.
transparent A boolean, whether to save the figure with a transparent background. Defaults to True.
dpi The DPI (dots per inch) for saving the figure. Defaults to 60.
legend_handles A list of matplotlib Patch objects to use as legend handles. Defaults to None.
data_format The image data format "channels_last" or "channels_first". Defaults to the Keras backend data format.

ValueError If both path and show are set to non-None values, if images is not a 4D tensor or array, or if y_true or y_pred are provided without a label_map.
ImportError if matplotlib is not installed.