Skip to main content

A highly performant, GPU compatible package for higher order interpolation in PyTorch

Project description

Unit Test Status License: MIT

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:

  1. Install the library using pip:

    pip install pyinterpx
    
  2. Import interp from PyInterpX and PyTorch in your script or notebook:

    from pyinterpx.Interpolation import interp
    import torch
    
  3. 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.

Performance Comparison

  • 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)
    

    no alignment

    or if you do not want to have any aligment with the input grid
    points, power, channels = 6, 3, 25
    interp = interp(points, power, channels, dtype=torch.double,align_corners = True)
    

    aligned

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyInterpX-0.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

PyInterpX-0.2-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file PyInterpX-0.2.tar.gz.

File metadata

  • Download URL: PyInterpX-0.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for PyInterpX-0.2.tar.gz
Algorithm Hash digest
SHA256 4a5b430b6b6b36b70066872ded2c48a04226233f20e0f83f2845cb15e120c5ff
MD5 a41f361e56243dc18e7f630500145b0d
BLAKE2b-256 18bb0312f9224d8cae302acbd6b78f5df0ac22fa71974b8664b6e48c6e0f00e4

See more details on using hashes here.

File details

Details for the file PyInterpX-0.2-py3-none-any.whl.

File metadata

  • Download URL: PyInterpX-0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for PyInterpX-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 65509ed4614970529605297ceeda28ae8a0eb69c3f38ba7b316a103b3bebbe7a
MD5 1c95aca4a3c19fe36e30cad0878f6a74
BLAKE2b-256 9dc65c33627cb554cec6816a70b437c79e2491b0bf308ba131f6876bde686aee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page