PyInterpX


NamePyInterpX JSON
Version 0.2.3 PyPI version JSON
download
home_page
SummaryA highly performant, GPU compatible package for higher order interpolation in PyTorch
upload_time2024-03-12 20:52:42
maintainer
docs_urlNone
authorThomasHelfer
requires_python>=3.8
licenseMIT
keywords machine learning pytorch interpolation higher order interpolation 3d interpolation gpu compatible
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![Unit Test Status](https://github.com/ThomasHelfer/HigherOrderInterpolation3DTorch/actions/workflows/actions.yml/badge.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-red.svg)](https://opensource.org/licenses/MIT)

# PyInterpX - Higher Order Interpolation in 3D for Torch
<p align="center">
    <img src="https://github.com/ThomasHelfer/PyInterpX/blob/main/img/logo_cropped.png" alt="no alignment" width="25%" height="auto"/>
</p>

## 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:

    ```bash
    pip install pyinterpx
    ```

2. Import `interp` from PyInterpX and PyTorch in your script or notebook:

    ```python
    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:

    ```python
    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](https://github.com/ThomasHelfer/HigherOrderInterpolation3DTorch/blob/main/img/Comparison.png "Performance Comparison")

- **CPU and GPU Compatible**: Functions seamlessly on both CPU and GPU environments.

    ```python
    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.

    ```python
    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.

    ```python
    # 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.
  
    ```python
    points, power, channels = 6, 3, 25
    interp = interp(points, power, channels, dtype=torch.double,align_corners = False)
    ```
    <p align="center">
        <img src="https://github.com/ThomasHelfer/HigherOrderInterpolation3DTorch/blob/main/img/no_align.png" alt="no alignment" width="50%" height="auto"/>
    </p>
    or if you do not want to have any aligment with the input grid
    
    ```python
    points, power, channels = 6, 3, 25
    interp = interp(points, power, channels, dtype=torch.double,align_corners = True)
    ```
    
    <p align="center">
        <img src="https://github.com/ThomasHelfer/HigherOrderInterpolation3DTorch/blob/main/img/align.png" alt="aligned" width="50%" height="auto"/>
    </p>

- Choose the enhacement **factor** you like
    ```python
    factor = 4
    points, power, channels = 6, 3, 25
    interp = interp(points, power, channels, dtype=torch.double,align_corners = False,factor = factor)
    ```
    <p align="center">
        <img src="https://github.com/ThomasHelfer/HigherOrderInterpolation3DTorch/blob/main/img/interpolation_grid_zoomed_factor_4.png" alt="no alignment" width="50%" height="auto"/>
    </p>
    
     ```python
    factor = 16
    points, power, channels = 6, 3, 25
    interp = interp(points, power, channels, dtype=torch.double,align_corners = False,factor = factor)
    ```
    <p align="center">
        <img src="https://github.com/ThomasHelfer/HigherOrderInterpolation3DTorch/blob/main/img/interpolation_grid_zoomed_factor_16.png" alt="no alignment" width="50%" height="auto"/>
    </p>    
    
### 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.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "PyInterpX",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "Machine learning,Pytorch,Interpolation,Higher order interpolation,3D interpolation,GPU compatible",
    "author": "ThomasHelfer",
    "author_email": "thomashelfer@live.de",
    "download_url": "https://files.pythonhosted.org/packages/dd/12/e0f3d56fab2c80186fea50b15e7a4b6e9b807a04aedbb5791a8160bfd2c8/PyInterpX-0.2.3.tar.gz",
    "platform": null,
    "description": "![Unit Test Status](https://github.com/ThomasHelfer/HigherOrderInterpolation3DTorch/actions/workflows/actions.yml/badge.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-red.svg)](https://opensource.org/licenses/MIT)\n\n# PyInterpX - Higher Order Interpolation in 3D for Torch\n<p align=\"center\">\n    <img src=\"https://github.com/ThomasHelfer/PyInterpX/blob/main/img/logo_cropped.png\" alt=\"no alignment\" width=\"25%\" height=\"auto\"/>\n</p>\n\n## Overview\n\nPyInterpX 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.\n\n## Quick Start\n\nTo get started with PyInterpX:\n\n1. Install the library using pip:\n\n    ```bash\n    pip install pyinterpx\n    ```\n\n2. Import `interp` from PyInterpX and PyTorch in your script or notebook:\n\n    ```python\n    from pyinterpx.Interpolation import interp\n    import torch\n    ```\n\n3. Utilize the interpolation function with a 6x6x6 kernel, polynomials up to the third power, and 25 channels:\n\n    ```python\n    points, power, channels = 6, 3, 25\n    Interp = interp(points, power, channels)\n    x = torch.rand(2, 25, 10, 10, 10)\n    Interp(x)\n    ```\n\n## Key Features\n\n- **Fast**: Optimized for high performance across any device.\n\n![Performance Comparison](https://github.com/ThomasHelfer/HigherOrderInterpolation3DTorch/blob/main/img/Comparison.png \"Performance Comparison\")\n\n- **CPU and GPU Compatible**: Functions seamlessly on both CPU and GPU environments.\n\n    ```python\n    points, power, channels = 6, 3, 25\n    # Running on GPU for even faster computations \n    interp = interp(points, power, channels, device=\"cuda:0\")\n    ```\n\n- **Precise**: Supports various data types for precise computation.\n\n    ```python\n    points, power, channels = 6, 3, 25\n    # Using double for more precision \n    interp = interp(points, power, channels, dtype=torch.double)\n    ```\n\n- **Integrated with PyTorch**: Easily integrates within the PyTorch ecosystem.\n\n    ```python\n    # A simple model which uses interpolation at some layer\n    class Model(torch.nn.Module):\n        def __init__(self):\n            super(Model, self).__init__()\n            points, power, channels = 6, 3, 25\n            # Setting up interpolation \n            self.interpolation = interp(points, power, channels)\n\n            self.convs = torch.nn.Sequential(\n                torch.nn.Conv3d(25, 64, kernel_size=3, padding=1),\n                torch.nn.ReLU(inplace=True),\n            )\n\n        def forward(self, x):\n            x = self.convs(x)\n            x = self.interpolation(x)\n            return x\n    ```\n- Choose simply the **grid alignment** you like.\n  \n    ```python\n    points, power, channels = 6, 3, 25\n    interp = interp(points, power, channels, dtype=torch.double,align_corners = False)\n    ```\n    <p align=\"center\">\n        <img src=\"https://github.com/ThomasHelfer/HigherOrderInterpolation3DTorch/blob/main/img/no_align.png\" alt=\"no alignment\" width=\"50%\" height=\"auto\"/>\n    </p>\n    or if you do not want to have any aligment with the input grid\n    \n    ```python\n    points, power, channels = 6, 3, 25\n    interp = interp(points, power, channels, dtype=torch.double,align_corners = True)\n    ```\n    \n    <p align=\"center\">\n        <img src=\"https://github.com/ThomasHelfer/HigherOrderInterpolation3DTorch/blob/main/img/align.png\" alt=\"aligned\" width=\"50%\" height=\"auto\"/>\n    </p>\n\n- Choose the enhacement **factor** you like\n    ```python\n    factor = 4\n    points, power, channels = 6, 3, 25\n    interp = interp(points, power, channels, dtype=torch.double,align_corners = False,factor = factor)\n    ```\n    <p align=\"center\">\n        <img src=\"https://github.com/ThomasHelfer/HigherOrderInterpolation3DTorch/blob/main/img/interpolation_grid_zoomed_factor_4.png\" alt=\"no alignment\" width=\"50%\" height=\"auto\"/>\n    </p>\n    \n     ```python\n    factor = 16\n    points, power, channels = 6, 3, 25\n    interp = interp(points, power, channels, dtype=torch.double,align_corners = False,factor = factor)\n    ```\n    <p align=\"center\">\n        <img src=\"https://github.com/ThomasHelfer/HigherOrderInterpolation3DTorch/blob/main/img/interpolation_grid_zoomed_factor_16.png\" alt=\"no alignment\" width=\"50%\" height=\"auto\"/>\n    </p>    \n    \n### Prerequisites\n\nBefore installing PyInterpX, ensure you meet the following prerequisites:\n- Python 3.8 or higher\n- pip package manager\n\n## License\n\nPyInterpX is open-sourced under the MIT License. For more details, see the LICENSE file.\n\n## Contact\n\nFor inquiries or support, reach out to Thomas Helfer at thomashelfer@live.de.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A highly performant, GPU compatible package for higher order interpolation in PyTorch",
    "version": "0.2.3",
    "project_urls": null,
    "split_keywords": [
        "machine learning",
        "pytorch",
        "interpolation",
        "higher order interpolation",
        "3d interpolation",
        "gpu compatible"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9d762ed3887e9a90afa57d6400d92b2900b2817eeea96649d17070b47f221af5",
                "md5": "307ab3b9841f36068378ad28142b5185",
                "sha256": "e5241e901825873122a58abfbcea3f9c90b830665b1f7a0eb333934df680b519"
            },
            "downloads": -1,
            "filename": "PyInterpX-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "307ab3b9841f36068378ad28142b5185",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8329,
            "upload_time": "2024-03-12T20:52:40",
            "upload_time_iso_8601": "2024-03-12T20:52:40.734195Z",
            "url": "https://files.pythonhosted.org/packages/9d/76/2ed3887e9a90afa57d6400d92b2900b2817eeea96649d17070b47f221af5/PyInterpX-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dd12e0f3d56fab2c80186fea50b15e7a4b6e9b807a04aedbb5791a8160bfd2c8",
                "md5": "39598b4a9c65f347a17b3a8871fccf9a",
                "sha256": "2667eb94b8cea6e6ffbd57797a31212ea7a096fbd45283732caf058253428438"
            },
            "downloads": -1,
            "filename": "PyInterpX-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "39598b4a9c65f347a17b3a8871fccf9a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9737,
            "upload_time": "2024-03-12T20:52:42",
            "upload_time_iso_8601": "2024-03-12T20:52:42.603029Z",
            "url": "https://files.pythonhosted.org/packages/dd/12/e0f3d56fab2c80186fea50b15e7a4b6e9b807a04aedbb5791a8160bfd2c8/PyInterpX-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-12 20:52:42",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pyinterpx"
}
        
Elapsed time: 4.61874s