Skip to content

Commit

Permalink
write_image: fix a silent bug when passing in batched images
Browse files Browse the repository at this point in the history
  • Loading branch information
ashawkey committed Mar 28, 2024
1 parent eec26ab commit d79606a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions kiui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,14 @@ def write_image(

if img.dtype == np.float32 or img.dtype == np.float64:
img = (img * 255).astype(np.uint8)

# cvtColor

if len(img.shape) == 4:
if img.shape[0] > 1:
raise ValueError(f'only support saving a single image! current image: {img.shape}')
img = img[0]

if len(img.shape) == 3:
# cvtColor
if order == "RGB":
if img.shape[-1] == 4:
img = cv2.cvtColor(img, cv2.COLOR_RGBA2BGRA)
Expand Down

0 comments on commit d79606a

Please sign in to comment.