Skip to main content

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

Release files for albumentationsxl 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for albumentationsxl 0.1.2
File Size Uploaded
albumentationsxl-0.1.2.tar.gz 50.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for albumentationsxl 0.1.2
File Interpreter ABI Platform
albumentationsxl-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 116.5 kB

Release files / albumentationsxl-0.1.2.tar.gz

Download URL albumentationsxl-0.1.2.tar.gz
Size 50.6 kB
Tags Source
SHA-256 checksum
How to use checksums
461f9006adf1e8e11c8e8c7440e18412aa3e15064ced19f83a543a903993c643
BLAKE2b-256 checksum
How to use checksums
b96b261bd729114c276ef4a5c8b1b22b2ab05aa76246f9fd87b75ccc566c7fa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / albumentationsxl-0.1.2-py3-none-any.whl

Download URL albumentationsxl-0.1.2-py3-none-any.whl
Size 65.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6de543abcc3a92ea8cdf321d33379868ac57fd58a96ad4dfc1eb829fa12bebd6
BLAKE2b-256 checksum
How to use checksums
4a51a4f2ad65da851d5d4d296dd18457412228048bf2be868332e028b06c28ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page