Skip to main content

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

Project description

SRMD ncnn Vulkan Python

CI

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

This project is a Python wrapper of nihui's project.

srmd-ncnn-vulkan-python wraps srmd-ncnn-vulkan project by SWIG to make it easier to integrate srmd-ncnn-vulkan with existing python projects.

This project only wrapped the original SRMD 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.

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:

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/srmd-ncnn-vulkan-python.git
cd srmd-ncnn-vulkan-python
git submodule update --init --recursive
cmake -B build src
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 to generate the Visual Studio solution file and build it. This will make the lib crash on loading.

The only way is use Visual Studio to open the project as directory, and build it from Visual Studio.

  1. install dependencies: cmake, vulkan sdk, swig and python-dev
  1. cmake the project. Either reference the linux build method or just do it on Visual Studio.

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/srmd-ncnn-vulkan-python.git
cd srmd-ncnn-vulkan-python
git submodule update --init --recursive
cmake -B build src
cd build
make

Usages

Example program

from PIL import Image
from srmd_ncnn_vulkan import Srmd

im = Image.open("0.jpg")
upscaler = Srmd(gpuid=0)
out_im = upscaler.process(im)
out_im.save("1.png")

Original SRMD Project

Other Open-Source Code Used

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

srmd-ncnn-vulkan-python-1.0.0.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file srmd-ncnn-vulkan-python-1.0.0.tar.gz.

File metadata

  • Download URL: srmd-ncnn-vulkan-python-1.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for srmd-ncnn-vulkan-python-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8386c602dc6a298796bf8d14794afa53b6174894c829b401c1da39695f2006ea
MD5 5d1048ab4f78a294eb15cecfbb011d04
BLAKE2b-256 929c715d1d3ef8b165a7b84c4fbce187e2f7e982bdfc7fd3ef5e9d99ae715e7f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page