LinuxCommandLibrary

waifu2x-ncnn-vulkan

Upscale images using waifu2x algorithm with Vulkan

TLDR

Upscale an image

$ waifu2x-ncnn-vulkan -i [path/to/input_file] -o [path/to/output_file]
copy

Upscale an image by a custom scale factor and denoise it
$ waifu2x-ncnn-vulkan -i [path/to/input_file] -o [path/to/output_file] -s [1|2|4|8|16|32] -n [-1|0|1|2|3]
copy

Save the upscaled image in a specific format
$ waifu2x-ncnn-vulkan -i [path/to/input_file] -o [path/to/output_file] -f [jpg|png|webp]
copy

SYNOPSIS

waifu2x-ncnn-vulkan -i input_path -o output_path [options]

PARAMETERS

-i
    Specifies the path to the input image file or directory.

-o
    Specifies the path for the output image file or directory.

-n
    Sets the noise reduction level (0=none, 1=low, 2=medium, 3=high).

-s
    Sets the upscale factor (1=no upscaling, 2, 3, or 4).

-t
    Defines the tile size for GPU processing in pixels (e.g., 200, 400). Smaller values reduce VRAM usage but may increase processing time.

-g
    Specifies the GPU device ID to use. Default is 0.

-j
    Sets the number of parallel jobs (threads) for each GPU.

-m
    Specifies the directory containing the AI models.

-f
    Sets the output image format (e.g., png, webp, jpg).

-x
    Enables Test-Time Augmentation (TTA) mode for potentially higher quality but slower processing.

-h
    Displays the help message.

DESCRIPTION

waifu2x-ncnn-vulkan is a high-performance command-line tool for intelligently upscaling images and reducing noise, particularly effective for anime-style art but also suitable for photographs. It leverages the waifu2x deep convolutional neural network algorithm, optimized with the ncnn inference framework, and accelerated by the Vulkan graphics API. This combination allows for significant speed improvements on compatible GPUs, making it a powerful choice for batch processing and high-resolution outputs. It intelligently fills in missing pixel data, resulting in sharper, more detailed images without the typical pixelation or blur associated with traditional scaling methods.

CAVEATS

VRAM Usage: High tile_size values or large input images can consume significant GPU VRAM, potentially leading to out-of-memory errors on GPUs with limited memory. Adjust tile_size downwards if this occurs.

Performance: While highly optimized, performance can vary greatly depending on GPU capabilities, driver versions, and image size/complexity. Using a dedicated GPU is highly recommended for practical speeds.

Model Specificity: The underlying waifu2x models are primarily trained on anime and cartoon images. While they perform well on photos, the results may not always be as optimal compared to models specifically trained for photographic realism.

BATCH PROCESSING

waifu2x-ncnn-vulkan natively supports processing entire directories. Simply specify an input directory with -i and an output directory with -o, and it will process all supported image files within the input directory, mirroring the structure in the output.

SUPPORTED FORMATS

The command typically supports common image formats like PNG, JPG, and WebP for both input and output. For outputs, specific formats can be forced using the -f option.

HISTORY

The waifu2x algorithm was initially developed in 2015 by nagadomi. waifu2x-ncnn-vulkan is a highly optimized port that came into existence around 2018-2019, specifically designed to leverage Tencent's ncnn framework for efficient neural network inference and the Vulkan API for cross-platform GPU acceleration. This combination significantly improved the speed and accessibility of waifu2x on various hardware, moving it from a CPU-bound or CUDA-exclusive solution to a more generalized and faster GPU-accelerated tool for Linux, Windows, and macOS.

SEE ALSO

imagemagick(1), ffmpeg(1)

Copied to clipboard