Skip to main content

Variopinta

Variopinta is an experimental CPU image-augmentation compiler with a Python configuration API and a Rust execution core. It compiles complete pipelines to reduce Python/native crossings, reuse buffers, select optimized kernels, and report the resulting execution plan.

Variopinta is the feminine form of the Spanish variopinto: “varied in color or appearance,” from Italian variopinto, “varied” and “painted.” — RAE

Variopinta is image-only and experimental. The public Python API may change between 0.y.0 releases; patch releases preserve documented signatures and data contracts unless a correctness or security fix requires otherwise.

Installation

Variopinta supports CPython 3.10–3.13 on 64-bit x86 Linux with glibc 2.34 or newer and on macOS 11 or newer running natively on Apple Silicon. AVX2 is detected at runtime on x86-64 and is not required. Other Python implementations, operating systems, architectures, and 32-bit environments are not supported.

Install Variopinta from PyPI:

python -m pip install variopinta

To build from a source checkout, install Rust 1.87 or newer and CMake. Linux x86-64 additionally needs a C/C++ toolchain and NASM:

sudo apt-get update
sudo apt-get install build-essential cmake nasm
python -m pip install .

On Apple Silicon, install Xcode command-line tools and CMake; NASM is not required. Source and wheel builds compile the locked vendored libjpeg-turbo statically and do not use Homebrew or MacPorts codec libraries.

The build uses Maturin through Python build isolation. NumPy is installed as the only required runtime dependency.

The default branch documents its source checkout. Each package release embeds the README that applies to that release; see the changelog when comparing them.

ToTorch is optional and requires a PyTorch build compatible with the selected Python and platform:

python -m pip install torch

Quick start

import numpy as np
import variopinta as vp

pipeline = vp.Compose(
    [
        vp.RandomCrop(256, 256),
        vp.Resize(224, 224),
        vp.HorizontalFlip(p=0.5),
        vp.Normalize(),
    ],
    seed=42,
).compile()

image = np.zeros((320, 320, 3), dtype=np.uint8)
output = pipeline(image, key=0)

print(output.shape, output.dtype)  # (224, 224, 3) float32
print(pipeline.explain())

Compose provides the semantic reference path; .compile() selects the optimized execution plan. explain() reports operations, pixel passes, buffers, copies, dtype and layout changes, fusion, and portable fallbacks. Each step has an always, conditional, or never status, and exact p=0 routes report only work that can execute.

Use an explicit unsigned 64-bit key when a result must be independent of call order or worker assignment. Omitting it advances the sequence associated with the pipeline seed.

Documentation

Data contract

Stage Type Shape and layout
Pipeline input NumPy uint8 HWC RGB with positive dimensions
Default output NumPy uint8 owned, contiguous HWC RGB
After Normalize NumPy float32 owned, contiguous HWC RGB
After terminal ToTorch CPU tensor contiguous CHW; preserves the current dtype

Non-contiguous NumPy input is made contiguous at the Python boundary. Normalize must be terminal or immediately precede ToTorch; ToTorch must always be last. Public floating-point configuration is stored at its effective finite float32 value. Values that overflow float32 or leave a documented open or closed domain after conversion raise ValueError.

Transforms

  • Geometry: Resize, RandomCrop, RandomResizedCrop, CenterCrop, PadIfNeeded, Affine, RandomRotation, Perspective, and GridDistortion.
  • Flips: HorizontalFlip and VerticalFlip.
  • Color and filtering: ColorJitter, GaussianBlur, GaussianNoise, Sharpen, Grayscale, Invert, Solarize, and Posterize.
  • Dropout: CoarseDropout.
  • Terminal conversion: Normalize and ToTorch.

Transforms are immutable configuration objects and accept an application probability p where applicable. Geometric operations support the documented nearest or bilinear interpolation policies and constant or reflect-101 borders. Variopinta defines its own rounding, sampling, and border semantics; it does not promise pixel or random-stream identity with another library. Affine and RandomRotation reject an input axis above 16,777,216 before rasterization.

Constructor parameters, defaults, and transform-specific behavior are in the transform reference.

Image I/O

read_image and decode_image accept JPEG or static PNG and return owned, contiguous NumPy arrays. Decode modes are unchanged, gray, rgb, and rgba.

encode_image and write_image support:

  • JPEG: uint8 grayscale or RGB, quality 1–100;
  • PNG: one to four uint8 or uint16 channels, compression 0–9.
import variopinta as vp

image = vp.read_image("input.jpg")
encoded = vp.encode_image(image, format="jpeg", quality=90)
decoded = vp.decode_image(encoded)
vp.write_image("output.png", decoded, compression=6)

Format detection uses file contents when decoding. EXIF orientation, metadata preservation, and animated PNG are not supported.

Native pipeline I/O

Pipeline source and sink policy can be fixed when Compose is built. The default remains array input plus a returned NumPy array or optional Torch tensor. Encoded-buffer and local-path routes can keep decode, augmentation, encode, and file I/O inside one native call.

from pathlib import Path

import variopinta as vp

pipeline = vp.Compose(
    [vp.RandomCrop(256, 256), vp.Resize(224, 224)],
    seed=42,
    input=vp.PathInput(max_encoded_bytes=32 * 1024 * 1024),
    output=vp.PathOutput(format="jpeg", quality=90),
).compile()

pipeline(Path("input.png"), destination=Path("output.jpg"), key=7)

The complete route matrix, service examples, resource limits, file semantics, ownership, and GIL behavior are documented in pipelines and image I/O.

Reproducibility and limits

Repeated keyed calls are deterministic for the same installed release, execution environment, pipeline, input, seed, and key. Exact pixels or random streams are not guaranteed across releases, builds, or platforms. Pin the full package build and record those inputs when bit-exact replay matters.

Current scope excludes structured targets such as masks and bounding boxes, GPU execution, native batches, and Python callbacks inside a pipeline. The augmentation path retains the GIL while it borrows NumPy input; native codec and file I/O work releases it.

Performance evidence

The controlled benchmark compares Variopinta with Torchvision v2 and AlbumentationsX on one reference machine. It measures equivalent materialized work and records correctness, copies, buffers, kernel paths, hardware, and statistical limits. The results support the compiled pipeline design; they do not establish a universal Rust speed advantage. The published x86-64 results do not claim performance parity on Apple Silicon; Variopinta-owned kernels use their portable scalar paths there, while resize and JPEG dependencies may independently select upstream ARM64 SIMD.

The reproducible harness and canonical evidence layout live under benchmarks/.

Project information

License

Variopinta is licensed under the Apache License 2.0. Native wheels contain permissively licensed third-party components; their required attributions are in THIRD_PARTY_NOTICES.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

variopinta-0.3.1.tar.gz (99.9 kB view details)

Uploaded Source

Built Distributions

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

variopinta-0.3.1-cp310-abi3-manylinux_2_34_x86_64.whl (987.1 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ x86-64

variopinta-0.3.1-cp310-abi3-macosx_11_0_arm64.whl (814.1 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file variopinta-0.3.1.tar.gz.

File metadata

  • Download URL: variopinta-0.3.1.tar.gz
  • Upload date:
  • Size: 99.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for variopinta-0.3.1.tar.gz
Algorithm Hash digest
SHA256 29f9be003aaa8667b67bdf22a6788222abaf011f05f41c7d221475b5268df8ee
MD5 a432f2b489b4c769847e98e6fde409d0
BLAKE2b-256 bd16838f36912aab699ecf82329ca67c5e99ecca43d0d48d841c40d154136fa9

See more details on using hashes here.

Provenance

The following attestation bundles were made for variopinta-0.3.1.tar.gz:

Publisher: release.yml on claverru/variopinta

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

File details

Details for the file variopinta-0.3.1-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for variopinta-0.3.1-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ce636154782f96876735ce2a6b5de486fb9dec2a3b5fa5ad215144c7a88fc892
MD5 b731ed877ce591268d3a77fa41e98afc
BLAKE2b-256 9631f3e59795f8ebcbb6211153f48b80aa2aa589ea4d05dda62ee4e143f4668e

See more details on using hashes here.

Provenance

The following attestation bundles were made for variopinta-0.3.1-cp310-abi3-manylinux_2_34_x86_64.whl:

Publisher: release.yml on claverru/variopinta

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

File details

Details for the file variopinta-0.3.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for variopinta-0.3.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8cc9020701da114914daa51f03e42514a9c5b20ec4f4c728e3c46862e994e496
MD5 a8c1f5a56426573d9b242cbb09c68717
BLAKE2b-256 a7995d1b51d7839b08afd7f5d5d357c10caa120c589f55f1e69345553a1cda5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for variopinta-0.3.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on claverru/variopinta

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

Release history Release notifications | RSS feed

0.5.0

3 files

0.4.4

3 files

0.4.3

3 files

0.4.2

3 files

0.4.1

3 files

0.4.0

3 files

This release

0.3.1 This release

3 files

0.3.0

3 files

0.2.0

3 files

0.1.0

2 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