• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H21-May-2021-387369

images/H03-May-2022-

models/H21-May-2021-668649

src/H03-May-2022-1,115,256962,241

.gitmodulesH A D21-May-2021179 76

LICENSEH A D21-May-20211 KiB2217

README.mdH A D21-May-20216.7 KiB180132

README.md

1# waifu2x ncnn Vulkan
2
3![CI](https://github.com/nihui/waifu2x-ncnn-vulkan/workflows/CI/badge.svg)
4![download](https://img.shields.io/github/downloads/nihui/waifu2x-ncnn-vulkan/total.svg)
5
6ncnn implementation of waifu2x converter. Runs fast on Intel / AMD / Nvidia with Vulkan API.
7
8waifu2x-ncnn-vulkan uses [ncnn project](https://github.com/Tencent/ncnn) as the universal neural network inference framework.
9
10## [Download](https://github.com/nihui/waifu2x-ncnn-vulkan/releases)
11
12Download Windows/Linux/MacOS Executable for Intel/AMD/Nvidia GPU
13
14**https://github.com/nihui/waifu2x-ncnn-vulkan/releases**
15
16This package includes all the binaries and models required. It is portable, so no CUDA or Caffe runtime environment is needed :)
17
18## Usages
19
20### Example Command
21
22```shell
23waifu2x-ncnn-vulkan.exe -i input.jpg -o output.png -n 2 -s 2
24```
25
26### Full Usages
27
28```console
29Usage: waifu2x-ncnn-vulkan -i infile -o outfile [options]...
30
31  -h                   show this help
32  -v                   verbose output
33  -i input-path        input image path (jpg/png/webp) or directory
34  -o output-path       output image path (jpg/png/webp) or directory
35  -n noise-level       denoise level (-1/0/1/2/3, default=0)
36  -s scale             upscale ratio (1/2/4/8/16/32, default=2)
37  -t tile-size         tile size (>=32/0=auto, default=0) can be 0,0,0 for multi-gpu
38  -m model-path        waifu2x model path (default=models-cunet)
39  -g gpu-id            gpu device to use (-1=cpu, default=auto) can be 0,1,2 for multi-gpu
40  -j load:proc:save    thread count for load/proc/save (default=1:2:2) can be 1:2,2,2:2 for multi-gpu
41  -x                   enable tta mode
42  -f format            output image format (jpg/png/webp, default=ext/png)
43```
44
45- `input-path` and `output-path` accept either file path or directory path
46- `noise-level` = noise level, large value means strong denoise effect, -1 = no effect
47- `scale` = scale level, 1 = no scaling, 2 = upscale 2x
48- `tile-size` = tile size, use smaller value to reduce GPU memory usage, default selects automatically
49- `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.
50- `format` = the format of the image to be output, png is better supported, however webp generally yields smaller file sizes, both are losslessly encoded
51
52If you encounter a crash or error, try upgrading your GPU driver:
53
54- Intel: https://downloadcenter.intel.com/product/80939/Graphics-Drivers
55- AMD: https://www.amd.com/en/support
56- NVIDIA: https://www.nvidia.com/Download/index.aspx
57
58## Build from Source
59
601. Download and setup the Vulkan SDK from https://vulkan.lunarg.com/
61  - For Linux distributions, you can either get the essential build requirements from package manager
62```shell
63dnf install vulkan-headers vulkan-loader-devel
64```
65```shell
66apt-get install libvulkan-dev
67```
68```shell
69pacman -S vulkan-headers vulkan-icd-loader
70```
71
722. Clone this project with all submodules
73
74```shell
75git clone https://github.com/nihui/waifu2x-ncnn-vulkan.git
76cd waifu2x-ncnn-vulkan
77git submodule update --init --recursive
78```
79
803. Build with CMake
81  - You can pass -DUSE_STATIC_MOLTENVK=ON option to avoid linking the vulkan loader library on MacOS
82
83```shell
84mkdir build
85cd build
86cmake ../src
87cmake --build . -j 4
88```
89
90## Speed Comparison with waifu2x-caffe-cui
91
92### Environment
93
94- Windows 10 1809
95- AMD R7-1700
96- Nvidia GTX-1070
97- Nvidia driver 419.67
98- CUDA 10.1.105
99- cuDNN 10.1
100
101```powershell
102Measure-Command { waifu2x-ncnn-vulkan.exe -i input.png -o output.png -n 2 -s 2 -t [block size] -m [model dir] }
103```
104
105```powershell
106Measure-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 }
107```
108
109### cunet
110
111||Image Size|Target Size|Block Size|Total Time(s)|GPU Memory(MB)|
112|---|---|---|---|---|---|
113|waifu2x-ncnn-vulkan|200x200|400x400|400/200/100|0.86/0.86/0.82|638/638/197|
114|waifu2x-caffe-cui|200x200|400x400|400/200/100|2.54/2.39/2.36|3017/936/843|
115|waifu2x-ncnn-vulkan|400x400|800x800|400/200/100|1.17/1.04/1.02|2430/638/197|
116|waifu2x-caffe-cui|400x400|800x800|400/200/100|2.91/2.43/2.7|3202/1389/1178|
117|waifu2x-ncnn-vulkan|1000x1000|2000x2000|400/200/100|2.35/2.26/2.46|2430/638/197|
118|waifu2x-caffe-cui|1000x1000|2000x2000|400/200/100|4.04/3.79/4.35|3258/1582/1175|
119|waifu2x-ncnn-vulkan|2000x2000|4000x4000|400/200/100|6.46/6.59/7.49|2430/686/213|
120|waifu2x-caffe-cui|2000x2000|4000x4000|400/200/100|7.01/7.54/10.11|3258/1499/1200|
121|waifu2x-ncnn-vulkan|4000x4000|8000x8000|400/200/100|22.78/23.78/27.61|2448/654/213|
122|waifu2x-caffe-cui|4000x4000|8000x8000|400/200/100|18.45/21.85/31.82|3325/1652/1236|
123
124### upconv_7_anime_style_art_rgb
125
126||Image Size|Target Size|Block Size|Total Time(s)|GPU Memory(MB)|
127|---|---|---|---|---|---|
128|waifu2x-ncnn-vulkan|200x200|400x400|400/200/100|0.74/0.75/0.72|482/482/142|
129|waifu2x-caffe-cui|200x200|400x400|400/200/100|2.04/1.99/1.99|995/546/459|
130|waifu2x-ncnn-vulkan|400x400|800x800|400/200/100|0.95/0.83/0.81|1762/482/142|
131|waifu2x-caffe-cui|400x400|800x800|400/200/100|2.08/2.12/2.11|995/546/459|
132|waifu2x-ncnn-vulkan|1000x1000|2000x2000|400/200/100|1.52/1.41/1.44|1778/482/142|
133|waifu2x-caffe-cui|1000x1000|2000x2000|400/200/100|2.72/2.60/2.68|1015/570/459|
134|waifu2x-ncnn-vulkan|2000x2000|4000x4000|400/200/100|3.45/3.42/3.63|1778/482/142|
135|waifu2x-caffe-cui|2000x2000|4000x4000|400/200/100|3.90/4.01/4.35|1015/521/462|
136|waifu2x-ncnn-vulkan|4000x4000|8000x8000|400/200/100|11.16/11.29/12.07|1796/498/158|
137|waifu2x-caffe-cui|4000x4000|8000x8000|400/200/100|9.24/9.81/11.16|995/546/436|
138
139## Sample Images
140
141### Original Image
142
143![origin](images/0.jpg)
144
145### Upscale 2x with ImageMagick
146
147```shell
148convert origin.jpg -resize 200% output.png
149```
150
151![browser](images/1.png)
152
153### Upscale 2x with ImageMagick Lanczo4 Filter
154
155```shell
156convert origin.jpg -filter Lanczos -resize 200% output.png
157```
158
159![browser](images/4.png)
160
161### Upscale 2x with waifu2x noise=2 scale=2
162
163```shell
164waifu2x-ncnn-vulkan.exe -i origin.jpg -o output.png -n 2 -s 2
165```
166
167![waifu2x](images/2.png)
168
169## Original waifu2x Project
170
171- https://github.com/nagadomi/waifu2x
172- https://github.com/lltcggie/waifu2x-caffe
173
174## Other Open-Source Code Used
175
176- https://github.com/Tencent/ncnn for fast neural network inference on ALL PLATFORMS
177- https://github.com/webmproject/libwebp for encoding and decoding Webp images on ALL PLATFORMS
178- https://github.com/nothings/stb for decoding and encoding image on Linux / MacOS
179- https://github.com/tronkko/dirent for listing files in directory on Windows
180