INNER CODE UNIT · Python
view_images
google/break-a-scene · ptp_utils.py:42
def view_images(
images: Union[np.ndarray, List],
num_rows: int = 1,
offset_ratio: float = 0.02,
display_image: bool = True,
) -> Image.Image:
"""Displays a list of images in a grid."""
if type(images) is list:
num_empty = len(images) % num_rows
elif images.ndim == 4:
num_empty = images.shape[0] % num_rows
else:
images = [images]
num_empty = 0
empty_images = np.ones(images[0].shape, dtype=np.uint8) * 255
images = [image.astype(np.uint8) for image in images] + [empty_images] * num_empty
num_items = len(images)