Skip to main content

No project description provided

Project description

srmd-ncnn-py

Python Binding for srmd-ncnn-py with PyBind11

PyPI version Release PyPI - Python Version

SRMD - Learning a Single Convolutional Super-Resolution Network for Multiple Degradations (CVPR, 2018). This wrapper provides an easy-to-use interface for running the pre-trained SRMD model.

Current building status matrix

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

Usage

Python >= 3.6 (>= 3.9 in MacOS arm)

To use this package, simply install it via pip:

pip install srmd-ncnn-py

For Linux user:

apt install -y libomp5 libvulkan-dev

Then, import the SRMD class from the package:

from srmd_ncnn_py import SRMD

To initialize the model:

srmd = SRMD(gpuid: int = 0, tta_mode: bool = False, noise: int = 3, scale: int = 2, tilesize: int = 0, model: int = 0)
# model can be "models-srmd" or an absolute path to a model folder

Here, gpuid specifies the GPU device to use, tta_mode enables test-time augmentation, noise specifies the level of noise to apply to the image (-1 to 10), scale is the scaling factor for super-resolution (2 to 4), tilesize specifies the tile size for processing (0 or >= 32), and model specifies 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
srmd = SRMD(gpuid=0)
with Image.open("input.jpg") as image:
    image = srmd.process_pil(image)
    image.save("output.jpg", quality=95)

opencv-python

import cv2
srmd = SRMD(gpuid=0)
image = cv2.imdecode(np.fromfile("input.jpg", dtype=np.uint8), cv2.IMREAD_COLOR)
image = srmd.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)
srmd = SRMD(gpuid=0)
while True:
    raw_image = pipe_out.stdout.read(src_width * src_height * 3)
    if not raw_image:
        break
    raw_image = srmd.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/srmd-ncnn-vulkan - This project was the main inspiration for our work. It provided the core implementation of the SRMD algorithm using the ncnn and Vulkan libraries.

cszn/SRMD - Learning a Single Convolutional Super-Resolution Network for Multiple Degradations (CVPR, 2018) (Matlab)

media2x/srmd-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.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

srmd_ncnn_py-2.0.0-cp312-none-win_amd64.whl (18.3 MB view details)

Uploaded CPython 3.12 Windows x86-64

srmd_ncnn_py-2.0.0-cp312-none-manylinux1_x86_64.whl (19.6 MB view details)

Uploaded CPython 3.12

srmd_ncnn_py-2.0.0-cp312-none-macosx_11_0_universal2.whl (24.2 MB view details)

Uploaded CPython 3.12 macOS 11.0+ universal2 (ARM64, x86-64)

srmd_ncnn_py-2.0.0-cp311-none-win_amd64.whl (18.3 MB view details)

Uploaded CPython 3.11 Windows x86-64

srmd_ncnn_py-2.0.0-cp311-none-manylinux1_x86_64.whl (19.6 MB view details)

Uploaded CPython 3.11

srmd_ncnn_py-2.0.0-cp311-none-macosx_11_0_universal2.whl (24.3 MB view details)

Uploaded CPython 3.11 macOS 11.0+ universal2 (ARM64, x86-64)

srmd_ncnn_py-2.0.0-cp310-none-win_amd64.whl (18.3 MB view details)

Uploaded CPython 3.10 Windows x86-64

srmd_ncnn_py-2.0.0-cp310-none-manylinux1_x86_64.whl (19.6 MB view details)

Uploaded CPython 3.10

srmd_ncnn_py-2.0.0-cp310-none-macosx_11_0_universal2.whl (24.2 MB view details)

Uploaded CPython 3.10 macOS 11.0+ universal2 (ARM64, x86-64)

srmd_ncnn_py-2.0.0-cp39-none-win_amd64.whl (18.3 MB view details)

Uploaded CPython 3.9 Windows x86-64

srmd_ncnn_py-2.0.0-cp39-none-manylinux1_x86_64.whl (19.6 MB view details)

Uploaded CPython 3.9

srmd_ncnn_py-2.0.0-cp39-none-macosx_11_0_universal2.whl (24.2 MB view details)

Uploaded CPython 3.9 macOS 11.0+ universal2 (ARM64, x86-64)

srmd_ncnn_py-2.0.0-cp38-none-win_amd64.whl (18.3 MB view details)

Uploaded CPython 3.8 Windows x86-64

srmd_ncnn_py-2.0.0-cp38-none-manylinux1_x86_64.whl (19.6 MB view details)

Uploaded CPython 3.8

srmd_ncnn_py-2.0.0-cp38-none-macosx_10_15_x86_64.whl (24.2 MB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

File details

Details for the file srmd_ncnn_py-2.0.0-cp312-none-win_amd64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 a6df83169fe076ba237ad0a9901296dc784962609bd8d0ad44d473cebb5d361a
MD5 cfe3bcdbca3201b5eb1988db9f0a7257
BLAKE2b-256 8922288651d64d3239b3f11b4d819ab3b98f9fb6c218792f79d18eaa012f0169

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp312-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp312-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6472ba1fa2ab67bb34284cf9ec8ea264fc77a30e8dd23f12efe48f9b34609f29
MD5 fd7cfab758ce3625c24a8e63abe388cf
BLAKE2b-256 6b802c78d42fafbcad52c15a55c19f291cffb35806f3473bedec1b0042a81d37

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp312-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp312-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 165c25b7cda8766fe47f24ba662f2e6879d5a0f9075e5e2899544520d754b041
MD5 e6e7d52e35058b9dd2de4c087c285c1b
BLAKE2b-256 e782b5960ec36938e1fcc1ed8fd2bece40b2b78aacc5db43ab77cd98d4799c6b

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 477d8011a8c11d1c45e0dde51d482fed194dda453072621ccd876fa41b6cf946
MD5 bea8eafe2169bc645a381997b0560ccb
BLAKE2b-256 f93e68e424f4ff13ac06272cda6081f52e6a0852f64cea94fe4fcf2d0c7ca9c6

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp311-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp311-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5d973fa8111cbb1888964ba823f6fa95c53670b9ca1aeac9f1583d0120722643
MD5 e306d2a3f667b87f1bb6348496ba2a92
BLAKE2b-256 5225b74d376953e2bf679fced2befb5cdceecf9d7b46ac3226d25242dcdce9a0

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp311-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp311-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 18d2e6d826742fae7dc2d961c33797c6aba081d062eb27d15adc143a036d80b5
MD5 b441096086d23c602041b33c3a040c56
BLAKE2b-256 31d1356f86ddc69eb44643a7a42b778a1f70ff7ae15a841403cc946cef1935b8

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 5a07ceb4637b5d09f8c471b0b2029b4fa369bf889b2205fe1eb428666e12b9db
MD5 e6cb7799fea6f789efb820c2c7a6f368
BLAKE2b-256 cee0003d50927bd6d2cc0cd8a374fd7725d3c8c0e8aab0a6bc53b18678e53248

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp310-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp310-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 736621d87ab9a42d86653b4f2a1ddcb238c549cfbcc2fbd7426a4de4ea46c5a8
MD5 0649cc6516c315e96f22e252384c7f6c
BLAKE2b-256 2d8755cf33a29e7546545ce83ca22ed775ebdcef18a49ef3e84b70fc15e5e342

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp310-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp310-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 6a70eb3ae2223d2bbac3c6d8a77469406f1de656abf7e2b9b28d4a188735da52
MD5 dcb1a9b5dcf715a4de38ed3611dd4996
BLAKE2b-256 825901dfc16d7368f550d247903d271b2de76662deab8174e517d2d26a0e8fea

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp39-none-win_amd64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 f8bb7876a28eaae8474637088a25e91b411957e8cde2481c0113acdcf73af5b7
MD5 01f67b537d3ceea2e69c7fe7965d3a98
BLAKE2b-256 7142b0fa45af120996741592d79f9d1bb998c9dd27f1338c685f27464ccc9184

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp39-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp39-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 da39b2520a58a65a6b1e4c9b5a6415f975dd15070249d13e0995605f0d6522bd
MD5 07d55895029ad37c3dcaf4705e686b52
BLAKE2b-256 bf4d7f40b8e24e57171486f46c70c695c75a636c138e6e54eb0d5e834ec3ca56

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp39-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp39-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 969f081dc38b6df08ca418d1db0b40d72255481e433da5b9ea89216d75455d6e
MD5 10b4b0bcbb15bddd220b70aff5577ffe
BLAKE2b-256 b3e4da820452543a9066532936ed98d6fac4c46f8ebb342c1e9f39cfa5051c1c

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp38-none-win_amd64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 c2410bc1fb714ece86dbfe221cb47e584326c36c419ef9e2e78fca302fdd617f
MD5 4f26f3e1c5cd2d9018622689b4db20d7
BLAKE2b-256 1af7eb1250dfb46c8caf1f853f7dde16d90c48ec0f7b2ad8d4620dc035113e29

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp38-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp38-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 aa19df1621a482f66724139d79a90700faf637b0b328dc12094c35fe16d974aa
MD5 7aa39f6bd9db32735466a8fe197cc1e9
BLAKE2b-256 6cfb3f0a30e7032d377ffd2f1be542ff57b78e57f32ab025e38cab6701176ff4

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-2.0.0-cp38-none-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-2.0.0-cp38-none-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 005c04d5a36112b6cd434b8c0a33b21232c40f23f6f89480d606100f0a711812
MD5 dc4ec43ef3e797ef338069065cbb070c
BLAKE2b-256 543bba880a1af940429ed58fe7b7fe097f0214336b7c6e93817edc4e756e487d

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