Package: realcugan-ncnn-vulkan-python
realcugan ncnn Vulkan PythonIntroductionA Python FFI of nihui/realcugan-ncnn-vulkan achieved with SWIG.realcugan-ncnn-vulkanis 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.Downloadlinux 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.Update: it has been uploaded to PyPI, and you can install it with pip now.Installationpipinstallrealcugan-ncnn-vulkan-pythonBuildFirst, 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 setuptoolspythonsetup.pyinstallUse CMakeLinuxinstall dependencies: cmake, vulkan sdk, swig and python-devDebian, Ubuntu and other Debian-like Distrosapt-getinstallcmakelibvulkan-devswigpython3-devArch Distrospacman-Sbase-develcmakevulkan-headersvulkan-icd-loaderswigpythonBuild with CMakegitclonehttps://github.com/ArchieMeng/realcugan-ncnn-vulkan-python.gitcdrealcugan-ncnn-vulkan-python
gitsubmoduleupdate--init--recursivecdsrc
cmake-Bbuild.cdbuild
makeWindowsI 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 useCMake for WindowsGUI to generate the Visual Studio solution file and build it. This will make the lib crash on loading.One way isusing 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 therelease.ymlMac OS Xinstall dependencies: cmake, vulkan sdk, swig and python-devdownload vulkan sdk fromhttps://vulkan.lunarg.com/sdk/homeIf you have homebrew installed, run the command below to get SWIGbrewinstallswigI guess python dev is out-of-box in Mac. If not, google it.Build with CMakeYou can pass -DUSE_STATIC_MOLTENVK=ON option to avoid linking the vulkan loader library on MacOSgitclonehttps://github.com/ArchieMeng/realcugan-ncnn-vulkan-python.gitcdrealcugan-ncnn-vulkan-python
gitsubmoduleupdate--init--recursivecdsrc
cmake-Bbuild.cdbuild
makeUsagesExample programfromPILimportImagefromrealcugan_ncnn_vulkanimportRealCUGANwithImage.open("input.png")asimage:realcugan=RealCUGAN(gpuid=0,scale=2,noise=3)image=realcugan.process(image)image.save("output.png")DocsKnown issuesModule finalization will crash for nvidia dedicated graphics card(s) on Linux. (The image processing still works.)Not yet tested for Mac OS. I guess it should work.Original realcugan Projecthttps://github.com/bilibili/ailab/tree/main/Real-CUGANhttps://github.com/nihui/realcugan-ncnn-vulkanOther Open-Source Code Usedhttps://github.com/Tencent/ncnnfor fast neural network inference on ALL PLATFORMShttps://github.com/webmproject/libwebpfor encoding and decoding Webp images on ALL PLATFORMShttps://github.com/nothings/stbfor decoding and encoding image on Linux / MacOShttps://github.com/tronkko/direntfor listing files in directory on Windows