MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / save_image_grid

Function save_image_grid

eval_code/recons/utils/vis_utils.py:9–22  ·  view source on GitHub ↗

images: numpy array of shape (N, H, W, 3) grid_shape: (rows, cols)

(images: np.ndarray, grid_shape: tuple, save_path: str)

Source from the content-addressed store, hash-verified

7
8
9def save_image_grid(images: np.ndarray, grid_shape: tuple, save_path: str):
10 """
11 images: numpy array of shape (N, H, W, 3)
12 grid_shape: (rows, cols)
13 """
14 H, W = images.shape[1], images.shape[2]
15 grid = np.zeros((grid_shape[0]*H, grid_shape[1]*W, 3), dtype=np.uint8)
16
17 for i in range(min(len(images), grid_shape[0]*grid_shape[1])):
18 row = i // grid_shape[1]
19 col = i % grid_shape[1]
20 grid[row*H:(row+1)*H, col*W:(col+1)*W] = images[i]
21
22 Image.fromarray(grid).save(save_path)
23
24
25def save_image_grid_auto(images: Union[np.ndarray, torch.Tensor], save_path: str):

Callers 1

save_image_grid_autoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected