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
interpfrom 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)
or if you do not want to have any aligment with the input gridpoints, power, channels = 6, 3, 25 interp = interp(points, power, channels, dtype=torch.double,align_corners = True)
-
Choose the enhacement factor you like
factor = 4 points, power, channels = 6, 3, 25 interp = interp(points, power, channels, dtype=torch.double,align_corners = False,factor = factor)
factor = 16 points, power, channels = 6, 3, 25 interp = interp(points, power, channels, dtype=torch.double,align_corners = False,factor = factor)
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.
Metadata
Release files for PyInterpX 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| PyInterpX-0.2.3.tar.gz | 9.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| PyInterpX-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.1 kB
Release files / PyInterpX-0.2.3.tar.gz
| Download URL | PyInterpX-0.2.3.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2667eb94b8cea6e6ffbd57797a31212ea7a096fbd45283732caf058253428438
|
|
BLAKE2b-256 checksum How to use checksums |
dd12e0f3d56fab2c80186fea50b15e7a4b6e9b807a04aedbb5791a8160bfd2c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.8.18
|
Release files / PyInterpX-0.2.3-py3-none-any.whl
| Download URL | PyInterpX-0.2.3-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5241e901825873122a58abfbcea3f9c90b830665b1f7a0eb333934df680b519
|
|
BLAKE2b-256 checksum How to use checksums |
9d762ed3887e9a90afa57d6400d92b2900b2817eeea96649d17070b47f221af5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.8.18
|
Security for PyInterpX 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.