Skip to content

Commit 16a2d97

Browse files
committed
docs: šŸ“ add bug fixes and improvements report detailing issues and resolutions
Signed-off-by: Onuralp SEZER <[email protected]>
1 parent 2c1a1a8 commit 16a2d97

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ā€Žsahi/utils/cv.pyā€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,11 @@ def read_image_as_pil(image: Image.Image | str | np.ndarray, exif_fix: bool = Tr
204204
else:
205205
raise TypeError(f"image with shape: {image_sk.shape[3]} is not supported.")
206206
elif isinstance(image, np.ndarray):
207+
# check if image is in CHW format (Channels, Height, Width)
208+
# heuristic: 3 dimensions, first dim (channels) < 5, last dim (width) > 4
207209
if image.ndim == 3 and image.shape[0] < 5: # image in CHW
208210
if image.shape[2] > 4:
211+
# convert CHW to HWC (Height, Width, Channels)
209212
image = np.transpose(image, (1, 2, 0))
210213
image_pil = Image.fromarray(image)
211214
else:

0 commit comments

Comments
Ā (0)