Skip to content

Add alpha channel input for Qwen Image 2.1 and relative docs - #2021

Merged
leejet merged 8 commits into
leejet:masterfrom
CarlGao4:master
Sep 22, 2026
Merged

leejet merged 8 commits into
leejet:masterfrom
CarlGao4:master

Conversation

@CarlGao4

@CarlGao4 CarlGao4 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Image inputs are no longer force-converted to RGB during decode in the CLI and server; they keep their native channel count. The generation pipeline already normalizes channels per model (get_image_channels() + ensure_image_tensor_channels()), so RGBA-capable models now receive the alpha channel while RGB-only models are unaffected.

Relative docs are also added.

Additional Information

The decoder change affects all image and video input paths. Due to local VRAM limits video generation paths were not exercised locally and should be tested before merging. Theoretically this is not affected.

It seems that sometimes requiring the model to remove background may create some white squares, which I haven't find out the reason yet. Maybe comparing different quantizations (I have no enough VRAM too) or test the results of original diffusers could answer this.

Checklist

@CarlGao4

Copy link
Copy Markdown
Contributor Author

Ohh I accidentally pushed 1014d0f here, but if stop building docker images on branches is acceptable I'll just keep it here

@leejet
leejet merged commit e112ab5 into leejet:master Sep 22, 2026
@leejet

leejet commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Thank you for your contribution.

@stduhpf

stduhpf commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

I'm noticing the same opaque white patches in the areas that are supposed to transparent in assets/qwen/qwen-image-2.1-alpha-out2.png and in my own attempts at generating transparent images. Is this a flaw of the model in general, or a bug in sd.cpp's implementation in particular?

@CarlGao4

Copy link
Copy Markdown
Contributor Author

@stduhpf What quantization are you using?

@stduhpf

stduhpf commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Q8_0

@CarlGao4

Copy link
Copy Markdown
Contributor Author

I tried the demo on huggingface space which use diffusers directly without quantization. The white patches didn't exist.
image
workflow_bc47f08aa5bbc689

I'll try F16 on sd.cpp then

@CarlGao4

Copy link
Copy Markdown
Contributor Author

Interesting. I ran with original weights (transformer, vae, text encoder) without quantization, the results are same:

test-f16dit-f32vae-f16encoder

@CarlGao4

Copy link
Copy Markdown
Contributor Author

Almost there. Some last tests then I'll come to an answer and open another PR

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.

3 participants