PyOIDN: Intel Open Image Denoise Python binding
Yet another unofficial Intel Open Image Denoise (OIDN) Python binding -- but more Pythonic. Checkout docs for more details.
Features
- Directly use NumPy arrays as input/output images.
- Support all OIDN filter types.
- Simple and clean API design.
- Lightweight: only depends on NumPy and the OIDN shared library.
- CUDA device support (via PyTorch).
Install
To install the latest release from PyPI:
pip install pyoidn
The default installation only includes lightweight CPU support with NumPy. Additionally, pyoidn provides support via PyTorch which enables CUDA device support:
pip install pyoidn[torch]
Note: this variant doesn't support Intel Macs, use the default installation instead.
Quickstart
Given a noisy image, plus its normal map and albedo map, denoise and save the result.
import numpy as np
from PIL import Image
import pyoidn
def load_image(path: str) -> np.ndarray:
return np.array(Image.open(path), dtype=np.float32) / 255.0
color = load_image(color_path)
normal = load_image(normal_path)
albedo = load_image(albedo_path)
result = np.zeros_like(color, dtype=np.float32)
device = pyoidn.Device()
device.commit()
flt = pyoidn.Filter(device, "RT")
flt.set_image(pyoidn.OIDN_IMAGE_COLOR, color, pyoidn.OIDN_FORMAT_FLOAT3)
flt.set_image(pyoidn.OIDN_IMAGE_NORMAL, normal, pyoidn.OIDN_FORMAT_FLOAT3)
flt.set_image(pyoidn.OIDN_IMAGE_ALBEDO, albedo, pyoidn.OIDN_FORMAT_FLOAT3)
flt.set_image(pyoidn.OIDN_IMAGE_OUTPUT, result, pyoidn.OIDN_FORMAT_FLOAT3)
flt.commit()
flt.execute()
# Always check errors if something looks off
assert device.get_error() is None
result_u8 = np.array(np.clip(result * 255, 0, 255), dtype=np.uint8)
Image.fromarray(result_u8).save(output_path)
flt.release()
device.release()
The result:
pyoidn also supports RAII-style resource management using context managers:
with pyoidn.Device() as device:
device.commit()
with pyoidn.Filter(device, "RT") as flt:
flt.set_bool("hdr", True)
# set images and other parameters
flt.commit()
flt.execute()
If you have installed the PyTorch support, you can also use CUDA devices:
torch_device = torch.device("cuda:0")
color_t = torch.from_numpy(color).to(device=torch_device, dtype=torch.float32).contiguous()
normal_t = torch.from_numpy(normal).to(device=torch_device, dtype=torch.float32).contiguous()
albedo_t = torch.from_numpy(albedo).to(device=torch_device, dtype=torch.float32).contiguous()
result_t = torch.zeros_like(color_t, dtype=torch.float32, device=torch_device)
with pyoidn.Device(torch_device) as device:
device.commit()
with pyoidn.Filter(device, "RT") as flt:
# set images and other parameters
flt.set_image(pyoidn.OIDN_IMAGE_COLOR, color_t, pyoidn.OIDN_FORMAT_FLOAT3)
flt.set_image(pyoidn.OIDN_IMAGE_NORMAL, normal_t, pyoidn.OIDN_FORMAT_FLOAT3)
flt.set_image(pyoidn.OIDN_IMAGE_ALBEDO, albedo_t, pyoidn.OIDN_FORMAT_FLOAT3)
flt.set_image(pyoidn.OIDN_IMAGE_OUTPUT, result_t, pyoidn.OIDN_FORMAT_FLOAT3)
flt.commit()
flt.execute()
Notes
- Error handling: use
device.get_error()after creating/committing/executing. - Async example: see
tests/test.py.
Documentation
Build locally:
pip install -r requirements-docs.txt
mkdocs serve
Roadmap
- CPU device support
- NumPy array support
- All filter types support
- OIDN buffer support
- RAII-style resource management
- More device types
- CUDA (torch)
- SYCL
- Metal
- Documents
- Examples
License
This project is licensed under the MIT License. See LICENSE.
This project includes:
- Intel Open Image Denoise (Apache License 2.0)
Release files for pyoidn 2.5.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pyoidn-2.5.0.1-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| pyoidn-2.5.0.1-py3-none-manylinux2014_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| pyoidn-2.5.0.1-py3-none-macosx_12_0_arm64.whl | Python 3 | none | macOS 12.0+ ARM64 | Details |
| pyoidn-2.5.0.1-py3-none-macosx_10_15_x86_64.whl | Python 3 | none | macOS 10.15+ x86-64 | Details |
Total release size: 233.8 MB
Release files / pyoidn-2.5.0.1-py3-none-win_amd64.whl
| Download URL | pyoidn-2.5.0.1-py3-none-win_amd64.whl |
|---|---|
| Size | 52.7 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
1616850bb24eb1ca44f9481538eb0a1fd690c91533d23c4614a38a6adf4393f2
|
|
BLAKE2b-256 checksum How to use checksums |
7aab630351a02550f387323297790aaa22a7e71a6f589881aa3fe97be4e1da14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Release files / pyoidn-2.5.0.1-py3-none-manylinux2014_x86_64.whl
| Download URL | pyoidn-2.5.0.1-py3-none-manylinux2014_x86_64.whl |
|---|---|
| Size | 83.9 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
0b9a8cc1e954fae9fbbcd8aef70008a5ca837fbe19bd56769f03dd9b2b514756
|
|
BLAKE2b-256 checksum How to use checksums |
52cbc731ea910aa01750288428c2412da2672f180374b35f83d50fc151f57416
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Release files / pyoidn-2.5.0.1-py3-none-macosx_12_0_arm64.whl
| Download URL | pyoidn-2.5.0.1-py3-none-macosx_12_0_arm64.whl |
|---|---|
| Size | 48.4 MB |
| Tags | Python 3 macOS 12.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
4580b041212511f81de5728c811fea5438521a59ce741fbf237110cc4d980649
|
|
BLAKE2b-256 checksum How to use checksums |
653f102d5f004b25c0c6259f36b2c38e1ea84a855c6fd8c8cb291e1fadeda464
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Release files / pyoidn-2.5.0.1-py3-none-macosx_10_15_x86_64.whl
| Download URL | pyoidn-2.5.0.1-py3-none-macosx_10_15_x86_64.whl |
|---|---|
| Size | 48.9 MB |
| Tags | Python 3 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
d7ae9ce478cc678604ffd1ba5615a1b2b60b2b1ec77ae0f9de5ea807b37a3070
|
|
BLAKE2b-256 checksum How to use checksums |
d266e39c8a29aceee6d404ee15d2fa7002074586d338298f8ebd6dcc83858d2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|