Skip to main content

realcugan ncnn Vulkan Python

CI

Introduction

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

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

This project only wrapped the original RealCUGAN 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 implements, 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.

Update: it has been uploaded to PyPI, and you can install it with pip now.

Installation

pip install realcugan-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 https://github.com/ArchieMeng/realcugan-ncnn-vulkan-python.git
cd realcugan-ncnn-vulkan-python
git submodule update --init --recursive
cd src
cmake -B build .
cd build
make

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.

The only problem on Windows is that, you cannot use CMake for Windows GUI to generate the Visual Studio solution file and build it. This will make the lib crash on loading.

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
git clone https://github.com/ArchieMeng/realcugan-ncnn-vulkan-python.git
cd realcugan-ncnn-vulkan-python
git submodule update --init --recursive
cd src
cmake -B build .
cd build
make

Usages

Example program

from PIL import Image
from realcugan_ncnn_vulkan import RealCUGAN

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

Docs

Known issues

Original realcugan Project

Other Open-Source Code Used

Metadata

Release files for realcugan-ncnn-vulkan-python 1.0.2

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

Source distribution (sdist)

Source distribution for realcugan-ncnn-vulkan-python 1.0.2
File Size Uploaded Provenance
realcugan-ncnn-vulkan-python-1.0.2.tar.gz 49.4 MB Without provenance Details

Release files / realcugan-ncnn-vulkan-python-1.0.2.tar.gz

Download URL realcugan-ncnn-vulkan-python-1.0.2.tar.gz
Size 49.4 MB
Tags Source
SHA-256 checksum
How to use checksums
12699646d7e42bede9a1a4b081bb23b7beafba6b784f68bd76aa8ae62e891b4d
BLAKE2b-256 checksum
How to use checksums
648fa97b3fac5e2123e4652a122f1df50846e4721056964003890edc20f24fbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.63.2 CPython/3.10.4

Security for realcugan-ncnn-vulkan-python 1.0.2

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