HighCWu / waifu2x-tfjs

Image super-resolution using Tensorflow.js .

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support transparent images

bragle opened this issue · comments

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? 😸

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.

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.

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

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输入模型当中,再对输出转换回透明通道。