• Stars
    star
    2,963
  • Rank 15,284 (Top 0.4 %)
  • Language
    C
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

waifu2x converter ncnn version, runs fast on intel / amd / nvidia / apple-silicon GPU with vulkan

waifu2x ncnn Vulkan

CI download

ncnn implementation of waifu2x converter. Runs fast on Intel / AMD / Nvidia / Apple-Silicon with Vulkan API.

waifu2x-ncnn-vulkan uses ncnn project as the universal neural network inference framework.

Download

Download Windows/Linux/MacOS Executable for Intel/AMD/Nvidia GPU

https://github.com/nihui/waifu2x-ncnn-vulkan/releases

This package includes all the binaries and models required. It is portable, so no CUDA or Caffe runtime environment is needed :)

Usages

Example Command

waifu2x-ncnn-vulkan.exe -i input.jpg -o output.png -n 2 -s 2

Full Usages

Usage: waifu2x-ncnn-vulkan -i infile -o outfile [options]...

  -h                   show this help
  -v                   verbose output
  -i input-path        input image path (jpg/png/webp) or directory
  -o output-path       output image path (jpg/png/webp) or directory
  -n noise-level       denoise level (-1/0/1/2/3, default=0)
  -s scale             upscale ratio (1/2/4/8/16/32, default=2)
  -t tile-size         tile size (>=32/0=auto, default=0) can be 0,0,0 for multi-gpu
  -m model-path        waifu2x model path (default=models-cunet)
  -g gpu-id            gpu device to use (-1=cpu, default=auto) can be 0,1,2 for multi-gpu
  -j load:proc:save    thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu
  -x                   enable tta mode
  -f format            output image format (jpg/png/webp, default=ext/png)
  • input-path and output-path accept either file path or directory path
  • noise-level = noise level, large value means strong denoise effect, -1 = no effect
  • scale = scale level, 1 = no scaling, 2 = upscale 2x
  • tile-size = tile size, use smaller value to reduce GPU memory usage, default selects automatically
  • load:proc:save = thread count for the three stages (image decoding + waifu2x upscaling + image encoding), using larger values may increase GPU usage and consume more GPU memory. You can tune this configuration with "4:4:4" for many small-size images, and "2:2:2" for large-size images. The default setting usually works fine for most situations. If you find that your GPU is hungry, try increasing thread count to achieve faster processing.
  • format = the format of the image to be output, png is better supported, however webp generally yields smaller file sizes, both are losslessly encoded

If you encounter a crash or error, try upgrading your GPU driver:

Build from Source

  1. Download and setup the Vulkan SDK from https://vulkan.lunarg.com/
  • For Linux distributions, you can either get the essential build requirements from package manager
dnf install vulkan-headers vulkan-loader-devel
apt-get install libvulkan-dev
pacman -S vulkan-headers vulkan-icd-loader
  1. Clone this project with all submodules
git clone https://github.com/nihui/waifu2x-ncnn-vulkan.git
cd waifu2x-ncnn-vulkan
git submodule update --init --recursive
  1. Build with CMake
  • You can pass -DUSE_STATIC_MOLTENVK=ON option to avoid linking the vulkan loader library on MacOS
mkdir build
cd build
cmake ../src
cmake --build . -j 4

Speed Comparison with waifu2x-caffe-cui

Environment

  • Windows 10 1809
  • AMD R7-1700
  • Nvidia GTX-1070
  • Nvidia driver 419.67
  • CUDA 10.1.105
  • cuDNN 10.1
Measure-Command { waifu2x-ncnn-vulkan.exe -i input.png -o output.png -n 2 -s 2 -t [block size] -m [model dir] }
Measure-Command { waifu2x-caffe-cui.exe -t 0 --gpu 0 -b 1 -c [block size] -p cudnn --model_dir [model dir] -s 2 -n 2 -m noise_scale -i input.png -o output.png }

cunet

Image Size Target Size Block Size Total Time(s) GPU Memory(MB)
waifu2x-ncnn-vulkan 200x200 400x400 400/200/100 0.86/0.86/0.82 638/638/197
waifu2x-caffe-cui 200x200 400x400 400/200/100 2.54/2.39/2.36 3017/936/843
waifu2x-ncnn-vulkan 400x400 800x800 400/200/100 1.17/1.04/1.02 2430/638/197
waifu2x-caffe-cui 400x400 800x800 400/200/100 2.91/2.43/2.7 3202/1389/1178
waifu2x-ncnn-vulkan 1000x1000 2000x2000 400/200/100 2.35/2.26/2.46 2430/638/197
waifu2x-caffe-cui 1000x1000 2000x2000 400/200/100 4.04/3.79/4.35 3258/1582/1175
waifu2x-ncnn-vulkan 2000x2000 4000x4000 400/200/100 6.46/6.59/7.49 2430/686/213
waifu2x-caffe-cui 2000x2000 4000x4000 400/200/100 7.01/7.54/10.11 3258/1499/1200
waifu2x-ncnn-vulkan 4000x4000 8000x8000 400/200/100 22.78/23.78/27.61 2448/654/213
waifu2x-caffe-cui 4000x4000 8000x8000 400/200/100 18.45/21.85/31.82 3325/1652/1236

upconv_7_anime_style_art_rgb

Image Size Target Size Block Size Total Time(s) GPU Memory(MB)
waifu2x-ncnn-vulkan 200x200 400x400 400/200/100 0.74/0.75/0.72 482/482/142
waifu2x-caffe-cui 200x200 400x400 400/200/100 2.04/1.99/1.99 995/546/459
waifu2x-ncnn-vulkan 400x400 800x800 400/200/100 0.95/0.83/0.81 1762/482/142
waifu2x-caffe-cui 400x400 800x800 400/200/100 2.08/2.12/2.11 995/546/459
waifu2x-ncnn-vulkan 1000x1000 2000x2000 400/200/100 1.52/1.41/1.44 1778/482/142
waifu2x-caffe-cui 1000x1000 2000x2000 400/200/100 2.72/2.60/2.68 1015/570/459
waifu2x-ncnn-vulkan 2000x2000 4000x4000 400/200/100 3.45/3.42/3.63 1778/482/142
waifu2x-caffe-cui 2000x2000 4000x4000 400/200/100 3.90/4.01/4.35 1015/521/462
waifu2x-ncnn-vulkan 4000x4000 8000x8000 400/200/100 11.16/11.29/12.07 1796/498/158
waifu2x-caffe-cui 4000x4000 8000x8000 400/200/100 9.24/9.81/11.16 995/546/436

Sample Images

Original Image

origin

Upscale 2x with ImageMagick

convert origin.jpg -resize 200% output.png

browser

Upscale 2x with ImageMagick Lanczo4 Filter

convert origin.jpg -filter Lanczos -resize 200% output.png

browser

Upscale 2x with waifu2x noise=2 scale=2

waifu2x-ncnn-vulkan.exe -i origin.jpg -o output.png -n 2 -s 2

waifu2x

Original waifu2x Project

Other Open-Source Code Used

More Repositories

1

opencv-mobile

The minimal opencv for Android, iOS, ARM Linux, Windows, Linux, MacOS, WebAssembly
C++
2,325
star
2

realsr-ncnn-vulkan

RealSR super resolution implemented with ncnn library
C
1,077
star
3

rife-ncnn-vulkan

RIFE, Real-Time Intermediate Flow Estimation for Video Frame Interpolation implemented with ncnn library
C
775
star
4

realcugan-ncnn-vulkan

real-cugan converter ncnn version, runs fast on intel / amd / nvidia / apple-silicon GPU with vulkan
C
751
star
5

ncnn-android-yolov5

The YOLOv5 object detection android example
C++
621
star
6

dain-ncnn-vulkan

DAIN, Depth-Aware Video Frame Interpolation implemented with ncnn library
C
506
star
7

ncnn-android-nanodet

C++
355
star
8

srmd-ncnn-vulkan

SRMD super resolution implemented with ncnn library
C
324
star
9

ruapu

Detect CPU features with single-file
C
268
star
10

ncnn-android-scrfd

C++
208
star
11

ncnn-assets

Python
186
star
12

ncnn-small-board

ncnn benchmark on various single board computers
157
star
13

ncnn-android-squeezenet

The squeezenet image classification android example
C++
141
star
14

ncnn-webassembly-yolov5

Deploy YOLOv5 in your web browser with ncnn and webassembly
C++
138
star
15

cain-ncnn-vulkan

CAIN, Channel Attention Is All You Need for Video Frame Interpolation implemented with ncnn library
C
130
star
16

ncnn-webassembly-nanodet

Deploy nanodet, the super fast and lightweight object detection, in your web browser with ncnn and webassembly
C++
118
star
17

vkpeak

A tool which profiles Vulkan devices to find their peak capacities
C++
96
star
18

ifrnet-ncnn-vulkan

IFRNet: Intermediate Feature Refine Network for Efficient Frame Interpolation implemented with ncnn library
C
92
star
19

ncnn-android-mobilenetssd

The mobilenetssd object detection android example
Java
89
star
20

ncnn-android-styletransfer

The style transfer android example
C
84
star
21

ncnn-android-benchmark

ncnn android benchmark app
C++
83
star
22

ncnn_on_esp32

C
65
star
23

stable-diffusion-ncnn-vulkan

60
star
24

nihui

57
star
25

valgrind-android

55
star
26

ncnn-webassembly-scrfd

Deploy SCRFD, an efficient high accuracy face detection approach, in your web browser with ncnn and webassembly
C++
52
star
27

ncnn-webassembly-portrait-segmentation

Portrait segmentation in your web browser with ncnn and webassembly
C++
33
star
28

riscv-v-toolchain

prebuild package for cross compiling riscv
18
star
29

ncnn-android-vkpeak

C++
17
star
30

styletransfer-ncnn-vulkan

C
17
star
31

ncnn_on_xr806

C++
14
star
32

ncnn-vulkan-compute-sample

CMake
13
star
33

fxxk-tensorflow-lite-note

add custom op in both tensorflow and tensorflow-lite
Jupyter Notebook
7
star
34

zzzz

C++
6
star
35

milkv-duo-test

C
5
star
36

kuaide

A fast desktop environment based on KDE technology
C++
5
star
37

InferXLite

C++
4
star
38

eva-qq-protocol

qq protocol document for eva
3
star
39

action-protobuf

CMake
3
star
40

libnofetion

next generation of ofetion library
C
3
star
41

oxygenspread

C
3
star
42

xf86-video-siska

xf86 Driver for SIS Chipset
C
3
star
43

playground

C++
2
star
44

ksaolaji

C++
2
star
45

VulkanOnMetal

Vulkan On Metal
C
2
star
46

kio-kuaipan

C++
2
star
47

kfuseiso

C++
1
star
48

eva-qt4

C++
1
star
49

action-xmwk

1
star
50

kopete-qq

C++
1
star
51

kiconedit

C++
1
star
52

kde-thumbnailer

C++
1
star
53

kcm-fontadjust

C++
1
star
54

choqok-sina

C++
1
star
55

qsopcast

C++
1
star
56

choqok-tencent

C++
1
star
57

nihui-patch

nihui's patch collection
1
star
58

dozen

1
star
59

estelle

C++
1
star
60

kamule

C++
1
star
61

kdoubanfm

C++
1
star
62

kopete-fetion

C++
1
star
63

vendor-rockchip-common

common
C
1
star
64

plasma-webqq

C++
1
star
65

choqok-netease

C++
1
star