Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
yoterel committed Jan 9, 2025
2 parents 4a4e362 + ac6cc12 commit b80373d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/gsoup/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,9 @@ def image_grid(images, rows, cols, pad=0, pad_color=None):
if len(images) != rows * cols:
raise ValueError("number of images must be equal to rows * cols")
if pad > 0:
images = pad_to_res(images, images.shape[1]+pad*2, images.shape[2]+pad*2, pad_color)
images = pad_to_res(
images, images.shape[1] + pad * 2, images.shape[2] + pad * 2, pad_color
)
tmp = images.reshape(rows, cols, images.shape[1], images.shape[2], -1)
if type(tmp) == torch.Tensor:
result = tmp.permute(0, 2, 1, 3, 4).reshape(
Expand Down
6 changes: 4 additions & 2 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,10 @@ def test_image():
assert grid.shape == (512, 512, 3)
white_images = gsoup.to_8b(np.ones((4, 256, 256, 3), dtype=np.float32))
pad = 5
grid2 = gsoup.image_grid(white_images, 2, 2, pad=5, pad_color=np.array([255, 255, 0]))
assert grid2.shape == (512+pad*4, 512+pad*4, 3)
grid2 = gsoup.image_grid(
white_images, 2, 2, pad=5, pad_color=np.array([255, 255, 0])
)
assert grid2.shape == (512 + pad * 4, 512 + pad * 4, 3)
img = gsoup.load_images([dst, dst, dst, dst], as_grayscale=True)
assert img.shape == (4, 512, 512, 1)
img = gsoup.load_images(
Expand Down

0 comments on commit b80373d

Please sign in to comment.