Skip to main content

waifu2x ncnn Vulkan Python

CI

Introduction

A Python FFI of nihui/waifu2x-ncnn-vulkan achieved with SWIG.

waifu2x-ncnn-vulkan is nihui's ncnn implementation of waifu2x converter. Runs fast on Intel / AMD / Nvidia with Vulkan API.

This project only wrapped the original Waifu2x class. As a result, functions other than the core upscaling and denoising such as multi-thread loading and saving are not available. Of course, the auto tilesize and prepadding settings are implemented, so don't worry about them.

Download

linux x64, Windows x64 and MacOS x64 releases are available now. For other platforms, you may compile it on your own. The reason why MacOS ARM64 build is not available is that it needs ARM Python Dev Libs which I have no ideas on how to get it on Github's MacOS x64 VM. Moreover, I don't have a Mac.

  • However, for Linux (Like Ubuntu 18.04) with an older GLIBC (version < 2.29), you may try to use the ubuntu-1804 release or just compile it on your own.
  • Windows release is not working for all python version. The version of Windows build is for python 3.9. This is a known issue: ImportError: DLL load failed while importing _rife_ncnn_vulkan_wrapper: The specified module could not be found.
  • Updates:
    • The binary wheel releases on Github are now linked with specific python version. Please download the right one according to your python version.
    • it has been uploaded to PyPI, and you can install it with pip now. But you need to have all the build dependencies (SWIG and Vulkan Dev) installed. Because the PYPI package of this lib is a source distribution.

Installation

pip install waifu2x-ncnn-vulkan-python

Build

First, you have to install python, python development package (Python native development libs in Visual Studio), vulkan SDK and SWIG on your platform. And then, there are two ways to build it:

  • Use setuptools to build and install into python package directly. (Currently in developing)
  • Use CMake directly (The old way)

Use setuptools

python setup.py install

Use CMake

Linux

  1. install dependencies: cmake, vulkan sdk, swig and python-dev
Debian, Ubuntu and other Debian-like Distros
apt-get install cmake libvulkan-dev swig python3-dev
Arch Distros
pacman -S base-devel cmake vulkan-headers vulkan-icd-loader swig python
  1. Build with CMake
git clone --recursive https://github.com/media2x/waifu2x-ncnn-vulkan-python.git
cd waifu2x-ncnn-vulkan-python
cmake -B build -S waifu2x_ncnn_vulkan_python
cmake --build build

Windows

I used Visual Studio 2019 and msvc v142 to build this project for Windows.

Install visual studio and open the project directory, and build. Job done.

One way is using Visual Studio to open the project as directory, and build it from Visual Studio. And another way is build it from powershell just like what is written in the release.yml

Mac OS X

  1. install dependencies: cmake, vulkan sdk, swig and python-dev
brew install swig
  • I guess python dev is out-of-box in Mac. If not, google it.
  1. Build with CMake
  • You can pass -DUSE_STATIC_MOLTENVK=ON option to avoid linking the vulkan loader library on MacOS
  • The remaining steps are similar to Linux.

Usages

Example program

from PIL import Image
from waifu2x_ncnn_vulkan import Waifu2x

with Image.open("input.png") as image:
  waifu2x = Waifu2x(gpuid=0, scale=2, noise=3)
  image = waifu2x.process(image)
  image.save("output.png")

Docs

Known issues

Software that uses this package

Original waifu2x Project

Other Open-Source Code Used

Metadata

Release files for waifu2x-ncnn-vulkan-python 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for waifu2x-ncnn-vulkan-python 1.0.4
File Size Uploaded Provenance
waifu2x-ncnn-vulkan-python-1.0.4.tar.gz 53.6 MB Without provenance Details

Release files / waifu2x-ncnn-vulkan-python-1.0.4.tar.gz

Download URL waifu2x-ncnn-vulkan-python-1.0.4.tar.gz
Size 53.6 MB
Tags Source
SHA-256 checksum
How to use checksums
bc7023cd4f2daf7ce3954086ef314f92236ca6529ad7715d1324291a1dfeda00
BLAKE2b-256 checksum
How to use checksums
4228a5ed9e1e843732709d07a0e1c8d50a71a1933a923883905aa4d11191b297
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.4.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.10.5

Security for waifu2x-ncnn-vulkan-python 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page