Skip to main content

No project description provided

Project description

srmd-ncnn-py

Python Binding for srmd-ncnn-py with PyBind11 PyPI version Release

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, **_kwargs)
# 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

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11

srmd_ncnn_py-1.0.0.0-cp311-cp311-macosx_12_0_universal2.whl (24.5 MB view details)

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

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10

srmd_ncnn_py-1.0.0.0-cp310-cp310-macosx_12_0_universal2.whl (24.5 MB view details)

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

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

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9

srmd_ncnn_py-1.0.0.0-cp39-cp39-macosx_12_0_universal2.whl (24.5 MB view details)

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

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

Uploaded CPython 3.8Windows x86-64

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

Uploaded CPython 3.8

srmd_ncnn_py-1.0.0.0-cp38-cp38-macosx_10_15_x86_64.whl (24.5 MB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

srmd_ncnn_py-1.0.0.0-cp37-cp37m-win_amd64.whl (18.3 MB view details)

Uploaded CPython 3.7mWindows x86-64

srmd_ncnn_py-1.0.0.0-cp37-cp37m-manylinux1_x86_64.whl (19.6 MB view details)

Uploaded CPython 3.7m

srmd_ncnn_py-1.0.0.0-cp37-cp37m-macosx_10_15_x86_64.whl (24.5 MB view details)

Uploaded CPython 3.7mmacOS 10.15+ x86-64

srmd_ncnn_py-1.0.0.0-cp36-cp36m-win_amd64.whl (18.3 MB view details)

Uploaded CPython 3.6mWindows x86-64

srmd_ncnn_py-1.0.0.0-cp36-cp36m-manylinux1_x86_64.whl (19.6 MB view details)

Uploaded CPython 3.6m

srmd_ncnn_py-1.0.0.0-cp36-cp36m-macosx_10_15_x86_64.whl (24.5 MB view details)

Uploaded CPython 3.6mmacOS 10.15+ x86-64

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 763e30857086dba0148a5532de51ae1f170079357bc26b3dc018398ecbea3409
MD5 6c6bb876974647d486a93bde73c3d186
BLAKE2b-256 06cf6fdfa0e6570cad5a43e9b352d8e5abcb33930998b4b8d247f46dfc25f490

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp311-cp311-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp311-cp311-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2af1bf70e69701d8b2f1a31ee4d9b51abeb0cad8d4174e8b1373461c85c2cabf
MD5 43b52a5d13e0711e4bb4ee2a93b4dfdc
BLAKE2b-256 30a7428f202310f8979eb87a55a866fba4908e42fc0791d2a9a7e5d423e7a876

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp311-cp311-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp311-cp311-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 b00c122d5480767e56246ddbe39a7c13b96edc38753f209584507dc96f35bc0b
MD5 fb843b596e025f363287167f6b390d33
BLAKE2b-256 95fe6329aa39e988b70ce67838e104b5b96db9808fbdadd80a49d5711e510941

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 dfdaad5da3dcbe145512a1ffea8dfe3a36d42003bf18727bbe48d91a29549b3b
MD5 93d41aac3586c3ef289c0128815c1cf0
BLAKE2b-256 57fbfaca650ca11f3be05fbe29d86fa0d6ddd4fadc1856c0b0f175bfeec192a1

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp310-cp310-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp310-cp310-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6353f85ed069b2f3b119c3b32fe45c97df44e193fbac27611e9e88d1c44ffbee
MD5 854a881d4ceb303f01551d68bd242fb4
BLAKE2b-256 05f24ccfc48ddf7cedb8705d63d3a003aaf29f53c8065897402d2676da9c26ae

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp310-cp310-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp310-cp310-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 420151f5b4c59d18258e6d73f518b9c922954ace4eb69b3dd1d08cbcd2010bd2
MD5 54b4ec4b2e1a8a7f6c2d15e3da46b73f
BLAKE2b-256 4cf5cc1760f7fd8ee9e9b59c9ce3d0bcaff6b65537389d4e638350fe14b26444

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 aa2878ba77eb81c88d9cc278a79744119eaddecbb999fa4ce5daaca7db1b4379
MD5 eb59f120eca03c27f9e3a7bda5765bbd
BLAKE2b-256 1e399b15ae4c3353f54bf43bd09e0d1d675fb8f1b4bd40483057f4aa917b4965

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp39-cp39-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 71c72240c0aee1042ef87cd3b9478356013e999f149acb943a47f439b8fa2ae4
MD5 99b36cb9ca0db51aae1657983a6364cf
BLAKE2b-256 b13e7f224433b18ee6bae7c5c1abd39b382616c54d0127f0cecd342cbb0a86de

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp39-cp39-macosx_12_0_universal2.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp39-cp39-macosx_12_0_universal2.whl
Algorithm Hash digest
SHA256 04a82e344320bc8b8fb57f91b17a75ea4c7eb753cca0ec99ca29404ed1b1e458
MD5 8bc1aa95ddb012903dfd9d0c11279136
BLAKE2b-256 f1e0342830492c1c4a448c7283786ac7b96dbe55d384df9c36656d1ccc1ddc48

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 fa4870f3e52e93caa8d6c41b9fca650a19a49b0d19859b3dee0f57b22e5e7281
MD5 26cdf70e786d31f3241247fe8ec3da49
BLAKE2b-256 f27f8938955ac3eb1f309b5f8525834f170c0ce34e078137fa243c0b04dbb38c

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp38-cp38-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3268cedca1ef9a4045e97f895f2831cd137d6cfcc68a9b2e7be6f617d18b0ed8
MD5 46b8e099a46477467753a44f8221df3a
BLAKE2b-256 33564fef5bd1230a5cacba8b9bfefb35d25cc5986b8441acc0c26569287663bf

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d6761de4be7239dc139ecb9c38ac752596949136282c86773eeb4188396a0f64
MD5 ead43c392eb51c694d4864fd0898ce52
BLAKE2b-256 7abcb9e8859d17ae2264c26ac354844eed6cc989acccdc4931b19c2be0be66d7

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 4f4f867a80e3039a0f1b346c804eb005e409818f6943ff48dcf9f53661d47d48
MD5 b043ad2c1eea2a9db9f9a67c75dcf96e
BLAKE2b-256 0cf31c7afbd75cbb05bab056cc42b828fc104554719fe50fe4b80174d568e40e

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8e1e88652075bb151570d52605da5c198707426bbb09f92ce313ccf147e19429
MD5 07f97b2f714f93bb6c2ad92b857438a5
BLAKE2b-256 ee122e2a992f5ba2eba0dd32a1735f815322482ef365639e8326e0869e8f95b5

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 2d59ceaae3372718cfdb9df12c3e6c1b27685d33c1eba79f526b221f97e28eb4
MD5 182c6d2bbe7b848235d7fc4638346cea
BLAKE2b-256 d5fb1b80f184c0b445cbae1b845b0a7907e82ae57d9bfb664d2ce3f466eceae5

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 36cbfca2da60b74e360ef5a70b24457e5cb45405bb7dd4e13d683eb6e308b443
MD5 d705a059b79294db8aeeb55aa4a126b8
BLAKE2b-256 8501ea4f0effda2151a792cadd11f9f6485ec58f6eb0e3eeea8676adfde6285c

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b0400e7614410315bfadb861d0416d2d4607c2627441819d1b0448be57c4f8c8
MD5 ddeb6bb60266765201226c9935ec5c32
BLAKE2b-256 be097a4c1df3d14e1ad11311604c80f034ccff0382cd564e4558331aa0072240

See more details on using hashes here.

File details

Details for the file srmd_ncnn_py-1.0.0.0-cp36-cp36m-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for srmd_ncnn_py-1.0.0.0-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 cca4dc729a32e4e4cd9ec7d46b492e772819b59626903fde47cfb53dae4bac2f
MD5 9b0399dd80bb917e2d80a727d88a12de
BLAKE2b-256 83b436784245fde9a6fff1f61cf4f334043f88b23a5066954deb7e0aadf0e46b

See more details on using hashes here.

Supported by

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