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.1.tar.gz (6.7 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.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fliser-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5cd909870588f3bc5a97f3612527e9c4449c0d0cc62dbb151a451aa1e6a099c3
MD5 9373d01f037ca43dcdfc230e8af2f66e
BLAKE2b-256 2e4aab33d7edd1fd6ba727439fa6f5f8f39b0b368b20ea65a2d7b7e1ae66ace3

See more details on using hashes here.

Provenance

The following attestation bundles were made for fliser-0.1.1.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.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for fliser-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3008261e22a48b9a13a20a4cea6ad8c01fe1ee17830ca27492f9b6bcced6a6e4
MD5 dd9d3fe22736d5c61d088136b0b136e8
BLAKE2b-256 132f75c744988052b8a4fb01c855e1d166d6680fc6d27107aa2764ff6bc9b4bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for fliser-0.1.1-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