8000 Transparent images lose alpha channel · Issue #1365 · k4yt3x/video2x · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Transparent images lose alpha channel #1365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zhanghai opened this issue Apr 7, 2025 · 6 comments
Open

Transparent images lose alpha channel #1365

zhanghai opened this issue Apr 7, 2025 · 6 comments
Labels
state:Backlog This issue will be worked on in the future type:Bug Something isn't working

Comments

@zhanghai
Copy link
zhanghai commented Apr 7, 2025

Describe the bug

video2x works fine on upscaling plain BMP files, but drops the alpha channel for PNG files with alpha channel.

To Reproduce

Steps to reproduce the behavior:

  1. Use real-esrgan to upscale a PNG file with alpha channel.
  2. Observe that the alpha channel is lost after upscaling.

Expected behavior

The alpha channel is kept and upscaled in the output PNG.

Actual behavior

The alpha channel is lost in the output PNG.

Screenshots

Image Image

Environment:

  • OS: Windows 10 22H2
  • GPU: NVIDIA GeForce RTX 3080
  • Video2X Version: 6.4.0

Full command

.\video2x.exe -i PNG_transparency_demonstration_1.png -o PNG_transparency_demonstration_1.3x.png -p realesrgan -c png --pix-fmt rgba -s 3

Additional context

I tried specifying --pix-fmt rgba as in #457 (which was for waifu2x back in 2021), but it didn't work either, probably because it's for output instead of input.

@zhanghai zhanghai added the type:Bug Something isn't working label Apr 7, 2025
@github-actions github-actions bot added the state:Backlog This issue will be worked on in the future label Apr 7, 2025
@k4yt3x
Copy link
Owner
k4yt3x commented Apr 8, 2025

This is because the current models take and output RGB24 images. This is just not possible AFAIK.

@k4yt3x
Copy link
Owner
k4yt3x commented Apr 8, 2025

Specifically here:

ncnn::Mat ncnn_image = ncnn::Mat(width, height, static_cast<size_t>(3), 3);

I needed BGR24 to create the ncnn::Mat. I don't think it's possible to preserve the alpha channel here.

@zhanghai
Copy link
Author
zhanghai commented Apr 8, 2025

Thanks for the reply!

For other people with this problem, I ended up using xinntao/Real-ESRGAN-ncnn-vulkan directly with the models included in this project and it handled the alpha channel well.

I wanted to check if it's easy to support the same thing in this project, but given that it's not possible I'll just close this issue.

@zhanghai zhanghai closed this as completed Apr 8, 2025
@github-actions github-actions bot added state:Done This issue has been resolved/dismissed and removed state:Backlog This issue will be worked on in the future labels Apr 8, 2025
@k4yt3x
Copy link
Owner
k4yt3x commented Apr 8, 2025

I think it could be possible if I end up using libtorch instead of ncnn. It's something I can look out for down the road.

@zhanghai
Copy link
Author
zhanghai commented Apr 8, 2025

I think it could be possible if I end up using libtorch instead of ncnn.

Is ncnn the problem here though? Asking because I was able to use xinntao/Real-ESRGAN-ncnn-vulkan directly and it did handle alpha channel properly.

@k4yt3x
Copy link
Owner
k4yt3x commented Apr 8, 2025

Hmm maybe I missed something here? Can you please reopen the issue? I'll take a look when I have time.

@zhanghai zhanghai reopened this Apr 9, 2025
@github-actions github-actions bot added state:Backlog This issue will be worked on in the future and removed state:Done This issue has been resolved/dismissed labels Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:Backlog This issue will be worked on in the future type:Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants
0