Skip to main content

Helper library for doing tiled inference with PyTorch.

Project description

fliser

Helper library for doing tiled inference with PyTorch.

Installation

pip install fliser

Examples

Use Fliser.from_sizes to choose the best tile size from a set of candidates. The tile size that requires the least amount of tiles to cover the full image will be chosen.

from fliser import Fliser

device = torch.device("cuda:0")

# Create model
model = MyModel().to(device)

# Read image
image = load_image(...)
image = image.unsqueeze(0).to(device)
_, c, h, w = x.shape

# Create Fliser helper class
fliser = Fliser.from_sizes(
    image_size=(h, w),
    num_channels=c,
    tile_sizes=[(416, 632), (512, 512), (632, 416)]
    min_overlap=32,
)

for tile in fliser.tiles():
    # Do inference for single tile
    with torch.inference_mode():
        pred = model(image[tile.slice()])
    
    # Update Fliser state
    fliser.update(tile, pred)

# Compute combined output
output = fliser.compute()

Use Fliser.from_aspect_ratios to instead choose tile size from a set of aspect ratios.

fliser = Fliser.from_aspect_ratios(
    image_size=(h, w),
    num_channels=c,
    tile_num_pixels=512 ** 2,
    aspect_ratios=(0.5, 1.0, 2.0),
    min_overlap=32,
)

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

fliser-0.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fliser-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file fliser-0.1.0.tar.gz.

File metadata

  • Download URL: fliser-0.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fliser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e3f68cfecdd5096493982a9cc82456aab396b643540786c72e6c93cac2cdf63d
MD5 ffe86829e46bac89f95b0cdf86d23b68
BLAKE2b-256 b49e2a544b6abcbdbf2e9410d7bcd95c25400660a8f6c7319585d28248cdc6d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for fliser-0.1.0.tar.gz:

Publisher: python-publish.yml on SimonLarsen/fliser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fliser-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fliser-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fliser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0218db2991c400bf9e626f5ad82605f8d77ab45d1bc71b7730fe31a43c54cc3
MD5 fcfb08ba0607d9f815aaa1f744968ee2
BLAKE2b-256 a910e17d77d09f50fdd1e71e1c83a2116c258bf030785c8f1f05b0916e07fe0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for fliser-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on SimonLarsen/fliser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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