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

CNNx2UL quality measurement #14

Open
arianaa30 opened this issue Mar 5, 2024 · 3 comments
Open

CNNx2UL quality measurement #14

arianaa30 opened this issue Mar 5, 2024 · 3 comments
Assignees

Comments

@arianaa30
Copy link

Interesting repo. I measured the SSIM of your CNNx2UL (downloaded the Canvas on web demo), and realized it is much lower (0.77) than that of the PyTorch-converted model (0.97) in bloc97/Anime4K#220 . I assume they should be very equivalent.
I actually measured the upscale-VL on PyTorch but I assume UL should even be higher quality score.

What could be the discrepency here? The SSIM difference is too large.

@plasmas
Copy link
Member

plasmas commented Mar 13, 2024

Thanks for opening the issue! I was busy last week. I'm not sure how we should compare the pytorch model with the webgpu shaders, since they are both derived from the glsl shaders. I might recommend rendering a anime image in MPV with the stock glsl shaders and treat it as the baseline. I will look into how.

Also, since there are more than one scripts method in the issue mentioned, which one did you use to generate the pytorch model? Would you mind sharing the notebook w/ model? We might be able to compare the weights, etc.

@arianaa30
Copy link
Author

I used these pytorch models folks contributed here: bloc97/Anime4K#220

@plasmas
Copy link
Member

plasmas commented Mar 22, 2024

To make sure the webGPU version reproduces the original glsl shaders, I first compared the upscaled results of MPV and webGPU, using this image and the upscale CNN 2x UL shader. The steps are:

  • For webGPU implementation, upload the image here and click "Download Canvas" on the right panel to download the image. Note the output image has outstanding alpha channels.
  • For MPV, install the original Anime4K as instructed, and register CTRL+s screenshot-to-file mpv_2x.png window in input.conf to dump windows as image. Then view the image with mpv --image-display-duration=inf --no-hidpi-window-scale --glsl-shaders="~~/shaders/Anime4K_Upscale_CNN_x2_UL.glsl" --geometry=1280x720 Magia_360p.png. Use CTRL + s keys to dump the output.

These two images are compared using this script. They are visually indistinguishable, with SSIM > 0.9995 and MSE < 0.05. Considering the precision issues, the webGPU implementation should be largely aligned with the original GLSL shader.

I also took a look at the PyTorch models here and they incorporates more processing stages like AutoDownscalePre and ClampHighlight. They have significant impact on the output, if you tried the pre-defined shader combos defined in anime4k's MPV release. You may try to run inference on anime4k module instead of the whole Anime4KPipeline to see if the result differs.

@plasmas plasmas self-assigned this Mar 22, 2024
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

2 participants