Skip to main content
Archived

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

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 — — — ✅
Linux (GCC) CI-Linux-x64-GCC — — — ✅
Windows CI-Windows-x64-MSVC — — — ✅
MacOS CI-MacOS-Universal-Clang — — — ✅
MacOS (ARM) CI-MacOS-Universal-Clang — — — ✅

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.

Metadata

Release files for srmd-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 srmd-ncnn-py 2.0.0
File
srmd_ncnn_py-2.0.0-cp312-none-win_amd64.whl CPython 3.12 none Windows x86-64 Details
srmd_ncnn_py-2.0.0-cp312-none-manylinux1_x86_64.whl CPython 3.12 none Linux glibc 2.5+ x86-64 Details
srmd_ncnn_py-2.0.0-cp312-none-macosx_11_0_universal2.whl CPython 3.12 none macOS 11.0+ universal2 (ARM64, x86-64) Details
srmd_ncnn_py-2.0.0-cp311-none-win_amd64.whl CPython 3.11 none Windows x86-64 Details
srmd_ncnn_py-2.0.0-cp311-none-manylinux1_x86_64.whl CPython 3.11 none Linux glibc 2.5+ x86-64 Details
srmd_ncnn_py-2.0.0-cp311-none-macosx_11_0_universal2.whl CPython 3.11 none macOS 11.0+ universal2 (ARM64, x86-64) Details
srmd_ncnn_py-2.0.0-cp310-none-win_amd64.whl CPython 3.10 none Windows x86-64 Details
srmd_ncnn_py-2.0.0-cp310-none-manylinux1_x86_64.whl CPython 3.10 none Linux glibc 2.5+ x86-64 Details
srmd_ncnn_py-2.0.0-cp310-none-macosx_11_0_universal2.whl CPython 3.10 none macOS 11.0+ universal2 (ARM64, x86-64) Details
srmd_ncnn_py-2.0.0-cp39-none-win_amd64.whl CPython 3.9 none Windows x86-64 Details
srmd_ncnn_py-2.0.0-cp39-none-manylinux1_x86_64.whl CPython 3.9 none Linux glibc 2.5+ x86-64 Details
srmd_ncnn_py-2.0.0-cp39-none-macosx_11_0_universal2.whl CPython 3.9 none macOS 11.0+ universal2 (ARM64, x86-64) Details
srmd_ncnn_py-2.0.0-cp38-none-win_amd64.whl CPython 3.8 none Windows x86-64 Details
srmd_ncnn_py-2.0.0-cp38-none-manylinux1_x86_64.whl CPython 3.8 none Linux glibc 2.5+ x86-64 Details
srmd_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: 310.4 MB

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

Download URL srmd_ncnn_py-2.0.0-cp312-none-win_amd64.whl
Size 18.3 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
a6df83169fe076ba237ad0a9901296dc784962609bd8d0ad44d473cebb5d361a
BLAKE2b-256 checksum
How to use checksums
8922288651d64d3239b3f11b4d819ab3b98f9fb6c218792f79d18eaa012f0169
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

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

Download URL srmd_ncnn_py-2.0.0-cp312-none-manylinux1_x86_64.whl
Size 19.6 MB
Tags CPython 3.12 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
6472ba1fa2ab67bb34284cf9ec8ea264fc77a30e8dd23f12efe48f9b34609f29
BLAKE2b-256 checksum
How to use checksums
6b802c78d42fafbcad52c15a55c19f291cffb35806f3473bedec1b0042a81d37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

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

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

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

Download URL srmd_ncnn_py-2.0.0-cp311-none-win_amd64.whl
Size 18.3 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
477d8011a8c11d1c45e0dde51d482fed194dda453072621ccd876fa41b6cf946
BLAKE2b-256 checksum
How to use checksums
f93e68e424f4ff13ac06272cda6081f52e6a0852f64cea94fe4fcf2d0c7ca9c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

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

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

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

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

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

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

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

Download URL srmd_ncnn_py-2.0.0-cp310-none-manylinux1_x86_64.whl
Size 19.6 MB
Tags CPython 3.10 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
736621d87ab9a42d86653b4f2a1ddcb238c549cfbcc2fbd7426a4de4ea46c5a8
BLAKE2b-256 checksum
How to use checksums
2d8755cf33a29e7546545ce83ca22ed775ebdcef18a49ef3e84b70fc15e5e342
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

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

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

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

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

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

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

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

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

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

Download URL srmd_ncnn_py-2.0.0-cp38-none-win_amd64.whl
Size 18.3 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
c2410bc1fb714ece86dbfe221cb47e584326c36c419ef9e2e78fca302fdd617f
BLAKE2b-256 checksum
How to use checksums
1af7eb1250dfb46c8caf1f853f7dde16d90c48ec0f7b2ad8d4620dc035113e29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

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

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

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

Download URL srmd_ncnn_py-2.0.0-cp38-none-macosx_10_15_x86_64.whl
Size 24.2 MB
Tags CPython 3.8 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
005c04d5a36112b6cd434b8c0a33b21232c40f23f6f89480d606100f0a711812
BLAKE2b-256 checksum
How to use checksums
543bba880a1af940429ed58fe7b7fe097f0214336b7c6e93817edc4e756e487d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7
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