Skip to content

Fix: ensure RGBA images are converted to RGB before resizing#2

Open
hahminlew wants to merge 2 commits intoQualcomm-AI-research:mainfrom
hahminlew:fix/rgba-to-rgb
Open

Fix: ensure RGBA images are converted to RGB before resizing#2
hahminlew wants to merge 2 commits intoQualcomm-AI-research:mainfrom
hahminlew:fix/rgba-to-rgb

Conversation

@hahminlew
Copy link
Copy Markdown

This PR fixes a runtime error caused when loading images with an alpha channel (RGBA).
Previously, RGBA images led to a channel mismatch error in the model:

RuntimeError: Given groups=1, weight of size [128, 3, 3, 3], 
expected input[1, 4, 512, 512] to have 3 channels, but got 4 channels instead

Changes
Added .convert("RGB") before resizing input images:
pil_img_cond = Image.open(img_path).convert("RGB").resize((512, 512))

Reason
Ensures all input images have 3 channels (RGB), preventing channel mismatch during convolution.

Test
Verified with RGBA images: model now runs without error.
Confirmed RGB images remain unaffected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant