A highly performant, GPU compatible package for higher order interpolation in PyTorch
Project description
PyInterpX - Higher Order Interpolation in 3D for Torch
Overview
PyInterpX is a compact library designed for advanced 3D interpolation using higher order polynomial bases, which is not currently supported by PyTorch's torch.nn.functional.interpolate()
method. This enhancement allows for more precise and customized interpolation processes in 3D spaces, catering to specialized applications requiring beyond-linear data manipulation.
Quick Start
To get started with PyInterpX:
-
Install the library using pip:
pip install pyinterpx
-
Import
interp
from PyInterpX and PyTorch in your script or notebook:from pyinterpx.Interpolation import interp import torch
-
Utilize the interpolation function with a 6x6x6 kernel, polynomials up to the third power, and 25 channels:
points, power, channels = 6, 3, 25 Interp = interp(points, power, channels) x = torch.rand(2, 25, 10, 10, 10) Interp(x)
Key Features
- Fast: Optimized for high performance across any device.
-
CPU and GPU Compatible: Functions seamlessly on both CPU and GPU environments.
points, power, channels = 6, 3, 25 # Running on GPU for even faster computations interp = interp(points, power, channels, device="cuda:0")
-
Precise: Supports various data types for precise computation.
points, power, channels = 6, 3, 25 # Using double for more precision interp = interp(points, power, channels, dtype=torch.double)
-
Integrated with PyTorch: Easily integrates within the PyTorch ecosystem.
# A simple model which uses interpolation at some layer class Model(torch.nn.Module): def __init__(self): super(Model, self).__init__() points, power, channels = 6, 3, 25 # Setting up interpolation self.interpolation = interp(points, power, channels) self.convs = torch.nn.Sequential( torch.nn.Conv3d(25, 64, kernel_size=3, padding=1), torch.nn.ReLU(inplace=True), ) def forward(self, x): x = self.convs(x) x = self.interpolation(x) return x
-
**Choose simply the grid alignment you like.
points, power, channels = 6, 3, 25 interp = interp(points, power, channels, dtype=torch.double,align_corners = False)
points, power, channels = 6, 3, 25 interp = interp(points, power, channels, dtype=torch.double,align_corners = True)
Prerequisites
Before installing PyInterpX, ensure you meet the following prerequisites:
- Python 3.8 or higher
- pip package manager
License
PyInterpX is open-sourced under the MIT License. For more details, see the LICENSE file.
Contact
For inquiries or support, reach out to Thomas Helfer at thomashelfer@live.de.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file PyInterpX-0.2.2.tar.gz
.
File metadata
- Download URL: PyInterpX-0.2.2.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8d1bcd03c2adca24745ab3badc853ffbbb083c029535bf3cb25e4d09943b00a |
|
MD5 | 8b6f382f15238198ca1a1dbbcd069c3b |
|
BLAKE2b-256 | f8176da2f041c4fdb4ddd8801d02c8a406974dd1be38a508cf20cdcb5605e92d |
File details
Details for the file PyInterpX-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: PyInterpX-0.2.2-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b54026d9bfac22ea4c7d9e966df8ae1f38af19608bafec986b92bf97a1e957b0 |
|
MD5 | 33d888739773210af062859ffe6eaac6 |
|
BLAKE2b-256 | d715715dbaed74c62eab353f50efb1c3f58f9759ea222449a2cc137f119ef2f9 |