waifu2x-ncnn-vulkan

授权协议 MIT License
开发语言 C/C++
所属分类 程序开发、 图形/图像处理
软件类型 开源软件
地区 不详
投 递 者 东明德
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

waifu2x ncnn Vulkan

CIdownload

ncnn implementation of waifu2x converter. Runs fast on Intel / AMD / Nvidia 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

Upscale 2x with ImageMagick

convert origin.jpg -resize 200% output.png

Upscale 2x with ImageMagick Lanczo4 Filter

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

Upscale 2x with waifu2x noise=2 scale=2

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

Original waifu2x Project

Other Open-Source Code Used

  • 1.NCNN编译 NCNN就不描述了,这里采用NCNN最新的发布版ncnn-20200727,buildroot中的mk文件如下 NCNN_VERSION = 20200727 NCNN_SITE = $(call github,Tencent,ncnn,$(NCNN_VERSION)) NCNN_INSTALL_STAGING = YES NCNN_LICENSE = BSD-2-Clause

  • 目录 1. 编译ncnn 2. 配置ncnn 3. 调用Vulkan 4. 总结 1. 编译ncnn 1. 编译opencv和portobuf,也可以直接下载windows版本的opencv 2. 安装vulkan,直接取官网下载 3. 下载ncnn源码: git clone https://github.com/Tencent/ncnn.git 4. 下载补充包: cd ncnn

 相关资料
  • ncnn 是腾讯优图实验室首个开源项目,是一个为手机端极致优化的高性能神经网络前向计算框架。 ncnn 从设计之初深刻考虑手机端的部属和使用。无第三方依赖,跨平台,手机端 cpu 的速度快于目前所有已知的开源框架。 基于 ncnn,开发者能够将深度学习算法轻松移植到手机端高效执行,开发出人工智能 APP,将 AI 带到你的指尖。 ncnn 目前已在腾讯多款应用中使用,如 QQ,Qzone,微信,天

  • waifu2x 通过使用卷积神经网络对动漫风格的图片进行放大操作(支持照片)。 一般图片在放大后可能会出现边界锯齿、线条模糊等问题,而 waifu2x 的算法对这种情况提供了非常好的图片拉伸、降噪、填补机制,使得放大前后的图片给人观感基本一致。 示例 依赖 硬件 NVIDIA GPU 平台 Torch7 NVIDIA CUDA LuaRocks 软件包 (excludes torch7's def

  • Waifu2x-Extension-GUI 是一个使用机器学习的多媒体处理应用,借助深度卷积神经网络对图片 & GIF & 视频进行超分辨率放大(即放大与降噪)。 特性 自动化处理多种媒体: 支持处理 图片 的同时,实现了自动化处理 GIF 和 视频 全图像风格支持: 内置多种算法, 无论是二次元动漫还是您日常拍摄的照片&录像 ,都可以进行清晰化处理 强大的兼容性: 内置多个引擎, 几乎与所有现代

  • 我正在使用Ubuntu18:04和lxc/lxd蒸汽容器。它工作得很好,我遵循了本教程,并对网络内容做了一些更改。 https://blog.simos.info/running-steam-in-a-lxd-system-container/ 蒸汽适用于opengl游戏,但不适用于沃肯游戏。卢特里斯也一样。 主办方: 集装箱侧: ubuntu@steam:~$vulkaninfo OpenGL工

  • 我试图用计算着色器对图像进行后期处理,并在当前计算中使用前一帧的颜色。我需要sampler2D来访问插值操作,尽管在下面的简单示例中似乎不是这样。我使用以下着色器更新当前输入输出“颜色”: 调度后: 我使用管道屏障转换图像布局 使用vkCmdCopyImage将“颜色”图像复制到“上一个颜色” 转换回布局,以便在下一帧中使用 所有这些(包括计算着色器调度)都在一个命令缓冲区中完成。然而,在使用Re

  • 我有一个计算着色器,可以使用读取带符号的标准化整数图像。 图像本身(包含正值和负值)被创建为,并由先前gpass中的片段着色器写入。绑定到计算着色器中descriptorsetlayout绑定的imageview也使用相同的格式创建。 一切正常。 昨天我意识到在计算着色器中我使用了错误的图像格式限定符。有点困惑(我不明白它如何正确读取无符号规范化值)我更正为,并且...什么都没变。 我做了几次测试