We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2c1a1a8 commit 16a2d97Copy full SHA for 16a2d97
āsahi/utils/cv.pyā
@@ -204,8 +204,11 @@ def read_image_as_pil(image: Image.Image | str | np.ndarray, exif_fix: bool = Tr
204
else:
205
raise TypeError(f"image with shape: {image_sk.shape[3]} is not supported.")
206
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
209
if image.ndim == 3 and image.shape[0] < 5: # image in CHW
210
if image.shape[2] > 4:
211
+ # convert CHW to HWC (Height, Width, Channels)
212
image = np.transpose(image, (1, 2, 0))
213
image_pil = Image.fromarray(image)
214
0 commit comments