Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

waifu2x-ncnn-py

Python Binding for waifu2x-ncnn-vulkan with PyBind11

PyPI version test_pip Release PyPI - Python Version

Image Super-Resolution for Anime-style art using Deep Convolutional Neural Networks. And it supports photo. This wrapper provides an easy-to-use interface for running the pre-trained Waifu2x model.

Current building status matrix

System Status CPU (32bit) CPU (64bit) GPU (32bit) GPU (64bit)
Linux (Clang) CI-Linux-x64-Clang — :white_check_mark: — :white_check_mark:
Linux (GCC) CI-Linux-x64-GCC — :white_check_mark: — :white_check_mark:
Windows CI-Windows-x64-MSVC — :white_check_mark: — :white_check_mark:
MacOS CI-MacOS-Universal-Clang — :white_check_mark: — :white_check_mark:
MacOS (ARM) CI-MacOS-Universal-Clang — :white_check_mark: — :white_check_mark:

Usage

To use this package, simply install it via pip:

pip install waifu2x-ncnn-py

For Linux user:

apt install -y libomp5 libvulkan-dev

Then, import the Waifu2x class from the package:

from src.waifu2x_ncnn_py import Waifu2x

To initialize the model:

waifu2x = Waifu2x(gpuid: int = 0, tta_mode: bool = False, num_threads: int = 1, noise: int = 0, scale: int = 2, tilesize: int = 0, model: str = "models-cunet")
# model can be "models-cunet", "models-upconv_7_anime_style_art_rgb" and "models-upconv_7_photo"
# or an absolute path to the models' directory

Here, gpuid specifies the GPU device to use (-1 means use CPU), tta_mode enables test-time augmentation, num_threads sets the number of threads for processing, noise specifies the level of noise to apply to the image (-1 to 3), scale is the scaling factor for super-resolution (1 to 4), tilesize specifies the tile size for processing (0 or >= 32), and model specifies the name of the pre-trained model to use.

Once the model is initialized, you can use the upscale method to super-resolve your images:

Pillow

from PIL import Image
waifu2x = Waifu2x(gpuid=0, scale=2, noise=3)
with Image.open("input.jpg") as image:
    image = waifu2x.process_pil(image)
    image.save("output.jpg", quality=95)

opencv-python

import cv2
waifu2x = Waifu2x(gpuid=0, scale=2, noise=3)
image = cv2.imdecode(np.fromfile("input.jpg", dtype=np.uint8), cv2.IMREAD_COLOR)
image = waifu2x.process_cv2(image)
cv2.imencode(".jpg", image)[1].tofile("output_cv2.jpg")

ffmpeg

import subprocess as sp
# your ffmpeg parameters
command_out = [FFMPEG_BIN,........]
command_in = [FFMPEG_BIN,........]
pipe_out = sp.Popen(command_out, stdout=sp.PIPE, bufsize=10 ** 8)
pipe_in = sp.Popen(command_in, stdin=sp.PIPE)
waifu2x = Waifu2x(gpuid=0, scale=2, noise=3)
while True:
    raw_image = pipe_out.stdout.read(src_width * src_height * 3)
    if not raw_image:
        break
    raw_image = waifu2x.process_bytes(raw_image, src_width, src_height, 3)
    pipe_in.stdin.write(raw_image)

Build

here

The project just only been tested in Ubuntu 18+ and Debian 9+ environments on Linux, so if the project does not work on your system, please try building it.

References

The following references were used in the development of this project:

nihui/waifu2x-ncnn-vulkan - This project was the main inspiration for our work. It provided the core implementation of the Waifu2x algorithm using the ncnn and Vulkan libraries.

Waifu2x - Waifu2x is an Image Super-Resolution algorithm for Anime-style art using Deep Convolutional Neural Networks. And it supports photo.

media2x/waifu2x-ncnn-vulkan-python - This project was used as a reference for implementing the wrapper. Special thanks to the original author for sharing the code.

ncnn - ncnn is a high-performance neural network inference framework developed by Tencent AI Lab.

License

This project is licensed under the BSD 3-Clause - see the LICENSE file for details.

Metadata

Release files for waifu2x-ncnn-py 2.0.0

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

Built distributions (wheels)

Table of built distributions (wheels) for waifu2x-ncnn-py 2.0.0
File
waifu2x_ncnn_py-2.0.0-cp312-none-win_amd64.whl CPython 3.12 none Windows x86-64 Details
waifu2x_ncnn_py-2.0.0-cp312-none-manylinux1_x86_64.whl CPython 3.12 none Linux glibc 2.5+ x86-64 Details
waifu2x_ncnn_py-2.0.0-cp312-none-macosx_11_0_universal2.whl CPython 3.12 none macOS 11.0+ universal2 (ARM64, x86-64) Details
waifu2x_ncnn_py-2.0.0-cp311-none-win_amd64.whl CPython 3.11 none Windows x86-64 Details
waifu2x_ncnn_py-2.0.0-cp311-none-manylinux1_x86_64.whl CPython 3.11 none Linux glibc 2.5+ x86-64 Details
waifu2x_ncnn_py-2.0.0-cp311-none-macosx_11_0_universal2.whl CPython 3.11 none macOS 11.0+ universal2 (ARM64, x86-64) Details
waifu2x_ncnn_py-2.0.0-cp310-none-win_amd64.whl CPython 3.10 none Windows x86-64 Details
waifu2x_ncnn_py-2.0.0-cp310-none-manylinux1_x86_64.whl CPython 3.10 none Linux glibc 2.5+ x86-64 Details
waifu2x_ncnn_py-2.0.0-cp310-none-macosx_11_0_universal2.whl CPython 3.10 none macOS 11.0+ universal2 (ARM64, x86-64) Details
waifu2x_ncnn_py-2.0.0-cp39-none-win_amd64.whl CPython 3.9 none Windows x86-64 Details
waifu2x_ncnn_py-2.0.0-cp39-none-manylinux1_x86_64.whl CPython 3.9 none Linux glibc 2.5+ x86-64 Details
waifu2x_ncnn_py-2.0.0-cp39-none-macosx_11_0_universal2.whl CPython 3.9 none macOS 11.0+ universal2 (ARM64, x86-64) Details
waifu2x_ncnn_py-2.0.0-cp38-none-win_amd64.whl CPython 3.8 none Windows x86-64 Details
waifu2x_ncnn_py-2.0.0-cp38-none-manylinux1_x86_64.whl CPython 3.8 none Linux glibc 2.5+ x86-64 Details
waifu2x_ncnn_py-2.0.0-cp38-none-macosx_10_15_x86_64.whl CPython 3.8 none macOS 10.15+ x86-64 Details

Total release size: 557.4 MB

Release files / waifu2x_ncnn_py-2.0.0-cp312-none-win_amd64.whl

Download URL waifu2x_ncnn_py-2.0.0-cp312-none-win_amd64.whl
Size 34.6 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
5b480bcf34e8ed82bea0fe1b9650f63735351c5ada60a09b64bde1914dc79233
BLAKE2b-256 checksum
How to use checksums
86a53acbd64f42abb5f46c438d2a61560c01bb22ac7f8cd80cc1ca0ff4cc187b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp312-none-manylinux1_x86_64.whl

Download URL waifu2x_ncnn_py-2.0.0-cp312-none-manylinux1_x86_64.whl
Size 36.0 MB
Tags CPython 3.12 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
70db561fb00c2dd9b184c3a52dfb2a69f4a0eebf0cc9e21aa6ab7fc4978995f2
BLAKE2b-256 checksum
How to use checksums
7fadce2dff93a14f46d9d18d725b288d8284572bdbc498d30fbab4b55cf5a861
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp312-none-macosx_11_0_universal2.whl

Download URL waifu2x_ncnn_py-2.0.0-cp312-none-macosx_11_0_universal2.whl
Size 40.9 MB
Tags CPython 3.12 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
b2fcf0887fb489779aa24cc6124f34b92633108356d86e699b797b96bd530b1b
BLAKE2b-256 checksum
How to use checksums
c58b474088dfeb3051a7bc865746c76c12e7ab2629cd191703990bda71574ddc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp311-none-win_amd64.whl

Download URL waifu2x_ncnn_py-2.0.0-cp311-none-win_amd64.whl
Size 34.6 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
0a00d709ed1f666dd5d0be4eae8a66589ebe991513a8409e6fa7d93efe83b4ec
BLAKE2b-256 checksum
How to use checksums
51b63e99bd679d05152c4aceda57e374796b69511fffd2ba79ee754bb76aa09a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp311-none-manylinux1_x86_64.whl

Download URL waifu2x_ncnn_py-2.0.0-cp311-none-manylinux1_x86_64.whl
Size 36.0 MB
Tags CPython 3.11 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
1f991d6c066bf3f5f038fc9ece448ad23f0d91cf75b62e10870e645c29a05d7c
BLAKE2b-256 checksum
How to use checksums
a2c79202b1223c4a0dd651c9b7aacd774954cd50bd6ec8e786ec3e92769910b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp311-none-macosx_11_0_universal2.whl

Download URL waifu2x_ncnn_py-2.0.0-cp311-none-macosx_11_0_universal2.whl
Size 40.9 MB
Tags CPython 3.11 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
2e76989552a70e62dba24f017e4ec15701dfd22e5865afbdf6b9aa355b00ffe2
BLAKE2b-256 checksum
How to use checksums
e20ca519f08fef390bb5e3843e21e7cf3ffc283e6267f217b01520b56b20dcb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp310-none-win_amd64.whl

Download URL waifu2x_ncnn_py-2.0.0-cp310-none-win_amd64.whl
Size 34.6 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
56380d72bf51604f57dd695d9632fed0eff1d6e97339390b6ba2fdab5a32f7b7
BLAKE2b-256 checksum
How to use checksums
cc630b4ffe36152ee2826f204eb787bbf490f7aab918beb101a4d89b562c6a45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp310-none-manylinux1_x86_64.whl

Download URL waifu2x_ncnn_py-2.0.0-cp310-none-manylinux1_x86_64.whl
Size 36.0 MB
Tags CPython 3.10 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
89514098703361aff0e787f2d62c2786f5c637c98ff530e68079253422baef62
BLAKE2b-256 checksum
How to use checksums
9c1e2d3143d0823dff2644c07e7eeca0414cc9112b37a1a8723393b1127516a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp310-none-macosx_11_0_universal2.whl

Download URL waifu2x_ncnn_py-2.0.0-cp310-none-macosx_11_0_universal2.whl
Size 40.9 MB
Tags CPython 3.10 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
18584cde42ce417df70001c0dc8c8763401b0e20ae57a2b2fef5edbb4f4a8ca9
BLAKE2b-256 checksum
How to use checksums
1999a6f8cc4fd62f4deabc357d6aded681af94278e3063a8477f213bdec5055c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp39-none-win_amd64.whl

Download URL waifu2x_ncnn_py-2.0.0-cp39-none-win_amd64.whl
Size 34.6 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
b546242b14b6e2132097a431aa902df634e44efad8101c46d034f0f8779cfa5e
BLAKE2b-256 checksum
How to use checksums
82e57f501a23ef2b54564ca6b320ff6440719ee0694b0a619b2acf28b8f09cbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp39-none-manylinux1_x86_64.whl

Download URL waifu2x_ncnn_py-2.0.0-cp39-none-manylinux1_x86_64.whl
Size 36.0 MB
Tags CPython 3.9 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
3b08ff93ac1382386977d95f07ab099892e45e1ee734d7b462e70cd47ade28e6
BLAKE2b-256 checksum
How to use checksums
a81b0c7c43a79b3c04ea2c07121ac6efafe19e705340862aeb147937ceeae025
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp39-none-macosx_11_0_universal2.whl

Download URL waifu2x_ncnn_py-2.0.0-cp39-none-macosx_11_0_universal2.whl
Size 40.9 MB
Tags CPython 3.9 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
7ac6f2bdb6709c7459e72b657c151d2943b95d3af5257c915089a33db8cc6cb3
BLAKE2b-256 checksum
How to use checksums
cf6b40009d21e47935982f2015908a4481ee11939cafa639eb24f6dc137165a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp38-none-win_amd64.whl

Download URL waifu2x_ncnn_py-2.0.0-cp38-none-win_amd64.whl
Size 34.6 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
7bfc21c6c09629d1cca3148b66e79384fedcfc28294fddab1eb042af471f591f
BLAKE2b-256 checksum
How to use checksums
0386bfa61e21b38208a44da506597fb4ce33704f5fd9aba589630b2c5f1fc0c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp38-none-manylinux1_x86_64.whl

Download URL waifu2x_ncnn_py-2.0.0-cp38-none-manylinux1_x86_64.whl
Size 36.0 MB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
2c6f5e2a9f0cee02d938f83da2f6e4730ce3cd2d2d9553044cd3963c009ce956
BLAKE2b-256 checksum
How to use checksums
6fd4144f3615441279b202408c953af30e669123925c548bf2fc0e41f0ef6c86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / waifu2x_ncnn_py-2.0.0-cp38-none-macosx_10_15_x86_64.whl

Download URL waifu2x_ncnn_py-2.0.0-cp38-none-macosx_10_15_x86_64.whl
Size 40.9 MB
Tags CPython 3.8 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
1e377ec0734c3fa9ae1a21fa26fc33e1408ee1a1e34863060ee7d3dfb55677d6
BLAKE2b-256 checksum
How to use checksums
1b77184a325ea68aa81a0b4069c6ea13ddebb0da5c25907d4bf488e450ecee73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Security for waifu2x-ncnn-py 2.0.0

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