MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / make_image_grid

Function make_image_grid

diffusers/src/diffusers/utils/pil_utils.py:53–67  ·  view source on GitHub ↗

Prepares a single grid of images. Useful for visualization purposes.

(images: List[PIL.Image.Image], rows: int, cols: int, resize: int = None)

Source from the content-addressed store, hash-verified

51
52
53def make_image_grid(images: List[PIL.Image.Image], rows: int, cols: int, resize: int = None) -> PIL.Image.Image:
54 """
55 Prepares a single grid of images. Useful for visualization purposes.
56 """
57 assert len(images) == rows * cols
58
59 if resize is not None:
60 images = [img.resize((resize, resize)) for img in images]
61
62 w, h = images[0].size
63 grid = Image.new("RGB", size=(cols * w, rows * h))
64
65 for i, img in enumerate(images):
66 grid.paste(img, box=(i % cols * w, i // cols * h))
67 return grid

Callers 11

save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90
generate_imagesFunction · 0.90
log_validationFunction · 0.90
save_model_cardFunction · 0.90
save_model_cardFunction · 0.90

Calls 1

resizeMethod · 0.45

Tested by

no test coverage detected