Skip to main content

A pytohn library for large image augmentations

Project description

AlbumentationsXL

AlbumentationsXL is a Python package for image augmentations fork of the Albumentations package, altered to accomodate large images using the libvips and pyvips libraries.

Why AlbumentationsXL

Although albumentations covers a wide range of augmentations in a user-friendly format, it is not well-suited for large image inputs. Since image operations are performed using Numpy, OpenCV and/or Pillow, images are loaded directly into memory, and this can cause out of memory errors on large inputs and transformations.

To solve this, libvips and its Python wrapper Pyvips can be used as the image handler, which is designed to process large images with low memory footprint, while remaining fast in execution. In doing so, the AlbumentationsXL package has the ease-of-use of Albumentations, while being capable to handle inputs of any size. Several fields that often deal with large images are:

  • Digital pathology:
  • Remote sensing (satelite imagery)

images in this domain are often .tif,.mrxs,.svs, etc. Pyvips can deal with most of these extensions (reading) without any problem, as long as the proper libvips dependencies are used.

Table of contents

Installation

Albumentations requires Python 3.10 or higher. To install the latest version from PyPI:

pip install -U albumentationsxl

Additionally, libvips 8.14.5 or higher, along with its Python bindings, pyvips 2.2.1 or higher, are needed as it is the core image handler. More information on how to build and install libvips/pyvips can be found on their respective documentation.

Documentation

The full documentation is available at https://albumentations.ai/docs/.

A simple example

import albumentationsxl as A
import pyvips

# Declare an augmentation pipeline
transform = A.Compose([
    A.RandomCrop(width=256, height=256),
    A.HorizontalFlip(p=0.5),
    A.RandomBrightnessContrast(p=0.2),
])

# Read an image with OpenCV and convert it to the RGB colorspace
image = pyvips.Image.new_from_file("image.jpg")

# Augment an image
transformed = transform(image=image)
transformed_image = transformed["image"].numpy() # pyvips pipelines are not executed until they reach a target pipeline

List of augmentations

Pixel-level transforms

Pixel-level transforms will change just an input image and will leave any additional targets such as masks, bounding boxes, and keypoints unchanged. The list of pixel-level transforms:

Spatial-level transforms

Spatial-level transforms will simultaneously change both an input image as well as additional targets such as masks, bounding boxes, and keypoints. The following table shows which additional targets are supported by each transform.

Transform Image Masks BBoxes Keypoints
Affine
CenterCrop
CoarseDropout
Crop
ElasticTransform
Flip
GridDropout
HorizontalFlip
Lambda
LongestMaxSize
NoOp
PadIfNeeded
RandomCrop
RandomRotate90
RandomScale
Resize
Rotate
SmallestMaxSize
Transpose
VerticalFlip

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

albumentationsxl-0.1.0.tar.gz (53.8 kB view details)

Uploaded Source

Built Distribution

albumentationsxl-0.1.0-py3-none-any.whl (65.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: albumentationsxl-0.1.0.tar.gz
  • Upload date:
  • Size: 53.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.3

File hashes

Hashes for albumentationsxl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b613ea800803c0c433b84ad0505441fa0fc3b0234290591c082ca3a8f3e285ef
MD5 955fa28d87ecf1f612125d2e0d2125f3
BLAKE2b-256 a71cf9dd67dbf812ae6389e56879c60abe4389ae30e6fdb5a711f971ba7882a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for albumentationsxl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e4bf88c11b1d8427888ecd664c7814b9319e8b8f76d6d56748f56ea9527f9b9
MD5 31bbdd03cc348f31458979596710117d
BLAKE2b-256 8d76976d94cd459486da9c0e722d0fa97ffe0acfe87871f358b26202dd7b70bc

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