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

Add support for AVIF format #191

Open
rail01 opened this issue Oct 24, 2022 · 5 comments
Open

Add support for AVIF format #191

rail01 opened this issue Oct 24, 2022 · 5 comments

Comments

@rail01
Copy link

rail01 commented Oct 24, 2022

Currently, attempt to upscale image from AVIF fails with error message:

decode image <imagename>.avif failed

While I do have libavif installed in my system.

Upscaling into AVIF also doesn't work with a different error:

invalid outputpath extension type

AVIF uses AV1 codec for compression and achieves excellent results at it.
It is open-source and royalty-free. It would be great if waifu2x supported it natively.

@regs01
Copy link

regs01 commented Jan 20, 2023

AVIF has a very low resolution limit - 8193x4320, as it's made for video. It can be rendered in tiles, but not perfect in that. JPEG-XL, on the other hand, is better in every way. It support resolution up to 1x1 Gp. It's still a little less than 2x2 Gp of PNG and 4x4 Gp of JPEG2000, but still quite a lot. So would make possible to use scale by 16 and 32. It also does lossless encoding better than PNG and WebP. Google is trying to sabotage it though, but hopefully it will make its way.

@Disonantemus
Copy link

You don't need AVIF support, you can do it now! I did a mini (simple) shell script that uses imagemagick to convert from any supported format (100+) to AVIF, and you can use it or customizing to your liking (change output format, fine tune parameters), or make it better.

#!/bin/bash
# needs installed: waifu2x-ncnn-vulkan, imagemagick

file1="${1%.*}"
mkdir -p "/tmp/waifu/"
png_in="/tmp/waifu/in.png"
png_out="/tmp/waifu/out.png"
convert "$1" "$png_in"
waifu2x-ncnn-vulkan -i "$png_in" -o "$png_out" -s 2
convert "$png_out" "$file1".avif
rm -rf "/tmp/waifu/"
  • Tested here (I did name my script waifu2x_to_avif for this):
$ ./waifu2x_to_avif image2upscale.jpg
[0 AMD Radeon RX 580 Series]  queueC=1[4]  queueG=0[1]  queueT=2[2]
[0 AMD Radeon RX 580 Series]  bugsbn1=0  bugbilz=0  bugcopc=0  bugihfa=0
[0 AMD Radeon RX 580 Series]  fp16-p/s/a=1/1/0  int8-p/s/a=1/1/1
[0 AMD Radeon RX 580 Series]  subgroup=64  basic/vote/ballot/shuffle=1/1/1/1
[0 AMD Radeon RX 580 Series]  fp16-matrix-16_8_8/16_8_16/16_16_16=0/0/0

@shirooo39
Copy link

shirooo39 commented Nov 30, 2024

image
I'm currently in the process of learning how to write a simple GUI using Python Eel and I tried to "implement" AVIF support by processing the image into PNG first using waifu2x and then just do a second processing using avifenc

@regs01
Copy link

regs01 commented Nov 30, 2024

PNG is too large and too slow to read and write

@Disonantemus
Copy link

PNG is too large and too slow to read and write

PNG can be smaller when optimized by pngquant or similar. PNG it's a lot better than older formats like: BMP, TIFF, PPM. Of course it is larger, because it's a 25 years older software:

Format Initial Release
PNG 1996
AVIF 2019

WebP it's a lot smaller, newer, can be lossy/lossless, supported by browsers and waifu2x-ncnn-vulkan.

You can change (easy) my shell script to use a WebP temporal file if you want, and it's almost instantaneous in my old i7-4790 (from 2014), marginal to upscale time.

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

4 participants