Skip to content
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

Support transparent images #6

Open
1 of 4 tasks
bragle opened this issue Jul 11, 2021 · 3 comments
Open
1 of 4 tasks

Support transparent images #6

bragle opened this issue Jul 11, 2021 · 3 comments

Comments

@bragle
Copy link

bragle commented Jul 11, 2021

I'm submitting a ...

  • bug report
  • feature request
  • question about the decisions made in the repository
  • question about how to use this project

Summary
Implementing support for transparent images seem to be possible (like waifu2x), but unfortunately my TF skills are a bit lacking, so when I tried tinkering with it, I just ended up breaking it. Is this something you would consider implementing? 😸

@HighCWu
Copy link
Owner

HighCWu commented Jul 11, 2021

Hey, thank you for your interest in my project.
For this requirement you mentioned, I think it can be achieved without changing the internal codes of waifu2x-tfjs.
In fact, waifu2x does not process the transparency channel when performing image super-resolution.
You only need to pass the RGB channels of the image into waifu2x-tfjs to get a new super-resolution RGB image, and then combine it with the original transparency channel.
Of course, if the image is enlarged, then you need to enlarge the transparency channel to the same size when you combine the new image and the transparency channel.
This should work. You could have a try.

@qinlili23333
Copy link

Hey, thank you for your interest in my project.
For this requirement you mentioned, I think it can be achieved without changing the internal codes of waifu2x-tfjs.
In fact, waifu2x does not process the transparency channel when performing image super-resolution.
You only need to pass the RGB channels of the image into waifu2x-tfjs to get a new super-resolution RGB image, and then combine it with the original transparency channel.
Of course, if the image is enlarged, then you need to enlarge the transparency channel to the same size when you combine the new image and the transparency channel.
This should work. You could have a try.

或许可以增加一个支持透明度的选项,开启后检测到有透明的图片先提取透明通道到灰度图像,然后把灰度图像也分别送入放大,主图和灰度图放大完成后把灰度图还原为透明通道合并回主图,会消耗两倍的时间但应该可以实现保证质量的透明放大

@HighCWu
Copy link
Owner

HighCWu commented Aug 16, 2021

Hey, thank you for your interest in my project.
For this requirement you mentioned, I think it can be achieved without changing the internal codes of waifu2x-tfjs.
In fact, waifu2x does not process the transparency channel when performing image super-resolution.
You only need to pass the RGB channels of the image into waifu2x-tfjs to get a new super-resolution RGB image, and then combine it with the original transparency channel.
Of course, if the image is enlarged, then you need to enlarge the transparency channel to the same size when you combine the new image and the transparency channel.
This should work. You could have a try.

或许可以增加一个支持透明度的选项,开启后检测到有透明的图片先提取透明通道到灰度图像,然后把灰度图像也分别送入放大,主图和灰度图放大完成后把灰度图还原为透明通道合并回主图,会消耗两倍的时间但应该可以实现保证质量的透明放大

想法可行,不过我暂时没有时间做此类拓展。
本仓库基本上就是实现waifu2x模型原本能实现的功能,关于透明通道放大之类的,相当于是模型之外的额外操作,我的建议是可以自己把透明通道转换为灰度图再转换为imagebitmap输入模型当中,再对输出转换回透明通道。

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

No branches or pull requests

3 participants