{"id":20996281,"url":"https://github.com/tohrusky/srmd-ncnn-py","last_synced_at":"2025-08-10T16:06:41.120Z","repository":{"id":153848617,"uuid":"630744616","full_name":"Tohrusky/srmd-ncnn-py","owner":"Tohrusky","description":"Python Binding for srmd-ncnn-vulkan with PyBind11","archived":false,"fork":false,"pushed_at":"2023-12-30T10:59:40.000Z","size":17611,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-10T10:54:21.461Z","etag":null,"topics":["cpp","ncnn","pybind11","python3","srmd","super-resolution"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tohrusky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-04-21T03:56:16.000Z","updated_at":"2024-11-07T03:06:26.000Z","dependencies_parsed_at":"2023-12-29T01:02:34.492Z","dependency_job_id":null,"html_url":"https://github.com/Tohrusky/srmd-ncnn-py","commit_stats":null,"previous_names":["final2x/srmd-ncnn-py","tohrusky/srmd-ncnn-py"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/Tohrusky/srmd-ncnn-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tohrusky%2Fsrmd-ncnn-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tohrusky%2Fsrmd-ncnn-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tohrusky%2Fsrmd-ncnn-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tohrusky%2Fsrmd-ncnn-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tohrusky","download_url":"https://codeload.github.com/Tohrusky/srmd-ncnn-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tohrusky%2Fsrmd-ncnn-py/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269747842,"owners_count":24469099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","ncnn","pybind11","python3","srmd","super-resolution"],"created_at":"2024-11-19T07:29:04.521Z","updated_at":"2025-08-10T16:06:41.085Z","avatar_url":"https://github.com/Tohrusky.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# srmd-ncnn-py\n\nPython Binding for srmd-ncnn-py with PyBind11\n\n[![PyPI version](https://badge.fury.io/py/srmd-ncnn-py.svg?123456)](https://badge.fury.io/py/srmd-ncnn-py?123456)\n[![Release](https://github.com/Tohrusky/srmd-ncnn-py/actions/workflows/Release.yml/badge.svg)](https://github.com/Tohrusky/srmd-ncnn-py/actions/workflows/Release.yml)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/srmd-ncnn-py)\n\nSRMD - Learning a Single Convolutional Super-Resolution Network for Multiple Degradations (CVPR, 2018).\nThis wrapper provides an easy-to-use interface for running the pre-trained SRMD model.\n\n### Current building status matrix\n\n|    System     |                                                                                                          Status                                                                                                           | CPU (32bit) | CPU (64bit) | GPU (32bit) |    GPU (64bit)     |\n| :-----------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------: | :---------: | :---------: | :----------------: |\n| Linux (Clang) |          [![CI-Linux-x64-Clang](https://github.com/Tohrusky/srmd-ncnn-py/actions/workflows/CI-Linux-x64-Clang.yml/badge.svg)](https://github.com/Tohrusky/srmd-ncnn-py/actions/workflows/CI-Linux-x64-Clang.yml)          |      —      |      —      |      —      | :white_check_mark: |\n|  Linux (GCC)  |             [![CI-Linux-x64-GCC](https://github.com/Tohrusky/srmd-ncnn-py/actions/workflows/CI-Linux-x64-GCC.yml/badge.svg)](https://github.com/Tohrusky/srmd-ncnn-py/actions/workflows/CI-Linux-x64-GCC.yml)             |      —      |      —      |      —      | :white_check_mark: |\n|    Windows    |        [![CI-Windows-x64-MSVC](https://github.com/Tohrusky/srmd-ncnn-py/actions/workflows/CI-Windows-x64-MSVC.yml/badge.svg)](https://github.com/Tohrusky/srmd-ncnn-py/actions/workflows/CI-Windows-x64-MSVC.yml)         |      —      |      —      |      —      | :white_check_mark: |\n|     MacOS     | [![CI-MacOS-Universal-Clang](https://github.com/Tohrusky/srmd-ncnn-py/actions/workflows/CI-MacOS-Universal-Clang.yml/badge.svg)](https://github.com/Tohrusky/srmd-ncnn-py/actions/workflows/CI-MacOS-Universal-Clang.yml) |      —      |      —      |      —      | :white_check_mark: |\n|  MacOS (ARM)  | [![CI-MacOS-Universal-Clang](https://github.com/Tohrusky/srmd-ncnn-py/actions/workflows/CI-MacOS-Universal-Clang.yml/badge.svg)](https://github.com/Tohrusky/srmd-ncnn-py/actions/workflows/CI-MacOS-Universal-Clang.yml) |      —      |      —      |      —      | :white_check_mark: |\n\n# Usage\n\n`Python \u003e= 3.6 (\u003e= 3.9 in MacOS arm)`\n\nTo use this package, simply install it via pip:\n\n```sh\npip install srmd-ncnn-py\n```\n\nFor Linux user:\n\n```sh\napt install -y libomp5 libvulkan-dev\n```\n\nThen, import the SRMD class from the package:\n\n```python\nfrom srmd_ncnn_py import SRMD\n```\n\nTo initialize the model:\n\n```python\nsrmd = SRMD(gpuid: int = 0, tta_mode: bool = False, noise: int = 3, scale: int = 2, tilesize: int = 0, model: int = 0)\n# model can be \"models-srmd\" or an absolute path to a model folder\n```\n\nHere, 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 \u003e= 32), and model specifies the pre-trained model to use.\n\nOnce the model is initialized, you can use the upscale method to super-resolve your images:\n\n### Pillow\n\n```python\nfrom PIL import Image\nsrmd = SRMD(gpuid=0)\nwith Image.open(\"input.jpg\") as image:\n    image = srmd.process_pil(image)\n    image.save(\"output.jpg\", quality=95)\n```\n\n### opencv-python\n\n```python\nimport cv2\nsrmd = SRMD(gpuid=0)\nimage = cv2.imdecode(np.fromfile(\"input.jpg\", dtype=np.uint8), cv2.IMREAD_COLOR)\nimage = srmd.process_cv2(image)\ncv2.imencode(\".jpg\", image)[1].tofile(\"output_cv2.jpg\")\n```\n\n### ffmpeg\n\n```python\nimport subprocess as sp\n# your ffmpeg parameters\ncommand_out = [FFMPEG_BIN,........]\ncommand_in = [FFMPEG_BIN,........]\npipe_out = sp.Popen(command_out, stdout=sp.PIPE, bufsize=10 ** 8)\npipe_in = sp.Popen(command_in, stdin=sp.PIPE)\nsrmd = SRMD(gpuid=0)\nwhile True:\n    raw_image = pipe_out.stdout.read(src_width * src_height * 3)\n    if not raw_image:\n        break\n    raw_image = srmd.process_bytes(raw_image, src_width, src_height, 3)\n    pipe_in.stdin.write(raw_image)\n```\n\n# Build\n\n[here](https://github.com/Tohrusky/srmd-ncnn-py/blob/main/.github/workflows/Release.yml)\n\n_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._\n\n# References\n\nThe following references were used in the development of this project:\n\n[nihui/srmd-ncnn-vulkan](https://github.com/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.\n\n[cszn/SRMD](https://github.com/cszn/SRMD) - Learning a Single Convolutional Super-Resolution Network for Multiple Degradations (CVPR, 2018) (Matlab)\n\n[media2x/srmd-ncnn-vulkan-python](https://github.com/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.\n\n[ncnn](https://github.com/Tencent/ncnn) - ncnn is a high-performance neural network inference framework developed by Tencent AI Lab.\n\n# License\n\nThis project is licensed under the BSD 3-Clause - see the [LICENSE file](https://github.com/Tohrusky/srmd-ncnn-py/blob/main/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftohrusky%2Fsrmd-ncnn-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftohrusky%2Fsrmd-ncnn-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftohrusky%2Fsrmd-ncnn-py/lists"}