Skip to content

Conversation

@onuralpszr
Copy link
Collaborator

@onuralpszr onuralpszr commented Nov 25, 2025

# check if image is in CHW format (Channels, Height, Width)
        # heuristic: 3 dimensions, first dim (channels) < 5, last dim (width) > 4
        if image.ndim == 3 and image.shape[0] < 5:  # image in CHW
            if image.shape[2] > 4:
                # convert CHW to HWC (Height, Width, Channels)
                image = np.transpose(image, (1, 2, 0))
        image_pil = Image.fromarray(image)

@onuralpszr onuralpszr self-assigned this Nov 25, 2025
@onuralpszr onuralpszr added the bug Something isn't working label Nov 25, 2025
@onuralpszr onuralpszr merged commit 04410e5 into main Nov 25, 2025
17 checks passed
@onuralpszr onuralpszr deleted the fix/read_image_as_pil_chw_format branch November 25, 2025 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants