Skip to main content

A blazingly fast Rust-powered image loader for Python.

Project description

Vantix

A fast image loader for Python, built in Rust.

PyTorch's DataLoader is fine, but it hits a wall pretty fast when you have a lot of images — the Python GIL and slow JPEG decoding eat up a huge chunk of your GPU's potential throughput. Vantix moves all of that work (decoding, resizing, normalizing) into a multi-threaded Rust backend, hands you a ready-to-use float32 tensor, and gets out of the way. On some workloads it's over 9× faster than a standard PyTorch pipeline.

How it works

The Rust core (src/lib.rs) uses:

  • rayon — spawns one thread per CPU core, each decoding and resizing one image in parallel
  • fast_image_resize — SIMD-accelerated resizing (AVX2 on x86, NEON on ARM) so bilinear resize is basically free
  • pyo3 + numpy — the output buffer is handed back to Python as a NumPy array with zero extra copies

On the Python side, VantixLoader (python/vantix/loader.py) wraps everything in a prefetch queue: a background thread keeps up to 3 batches queued so your training loop never waits on I/O. It also supports PyTorch DDP (multi-GPU) out of the box by sharding indices across ranks.

Features

  • True parallelism — bypasses the Python GIL entirely, all decoding happens in Rust threads
  • SIMD resizing — hardware-accelerated, way faster than Pillow
  • Zero-copy tensor handoff — the NumPy array converts to a PyTorch tensor without duplicating memory
  • Fused pipeline — resize + optional random horizontal flip + normalize all in one pass
  • DDP ready — automatically shards the dataset across GPUs when using distributed training
  • Drop-in replacement — same interface as a standard PyTorch IterableDataset

Quick start

Install (from source, for now)

You need Rust and maturin installed first:

pip install maturin
maturin develop --release

Once it's published on PyPI:

pip install vantixloader

Basic usage

from vantixloader import VantixLoader
import glob

paths = glob.glob("data/train/**/*.jpg", recursive=True)

loader = VantixLoader(
    image_paths=paths,
    width=224,
    height=224,
    batch_size=64,
    augment=True,   # random horizontal flip
    shuffle=True,
)

for batch in loader:
    # batch is a float32 torch.Tensor of shape [B, 3, H, W]
    outputs = model(batch.to("cuda"))

Parameters

Parameter Default Description
image_paths List of paths to images on disk
width 224 Target width after resize
height 224 Target height after resize
batch_size 64 Images per batch
augment False Random horizontal flip (50% chance per image)
shuffle True Shuffle order every epoch
transform None Optional Python transform applied after loading
queue_size 3 Number of batches to prefetch in the background

Benchmarks

See BENCHMARK.md for full results. Short version:

Dataset PyTorch (img/s) Vantix (img/s) Speedup
CIFAR-Like (32 px) ~1 750 ~16 400 ~9.4×
ImageNet (224 px) ~420 ~1 020 ~2.4×
4K Medical (2048→224) ~65 ~180 ~2.8×

Running the benchmarks yourself

# 1. Build the Rust extension
maturin develop --release

# 2. Download + prep CIFAR-10 test data
python benchmarks/prepare_data.py

# 3. Raw throughput (images/sec)
python benchmarks/benchmark_throughput.py

# 4. End-to-end training speedup
python benchmarks/benchmark_training.py

Charts are saved to assets/.

Project structure

vantix/
├── src/lib.rs                  # Rust core: parallel decode, resize, normalize
├── python/vantixloader/
│   ├── __init__.py
│   └── loader.py               # VantixLoader — Python wrapper + prefetch queue
├── benchmarks/
│   ├── benchmark_throughput.py # Raw img/s benchmark
│   └── benchmark_training.py  # Full training loop speedup benchmark
├── assets/                     # Benchmark charts
├── Cargo.toml                  # Rust dependencies
└── pyproject.toml              # Python packaging (maturin)

License

MIT — Carl Kemmerich

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

vantixloader-0.1.1.tar.gz (105.5 kB view details)

Uploaded Source

Built Distributions

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

vantixloader-0.1.1-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10Windows x86-64

vantixloader-0.1.1-cp310-cp310-win32.whl (1.3 MB view details)

Uploaded CPython 3.10Windows x86

vantixloader-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

vantixloader-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64

vantixloader-0.1.1-cp310-cp310-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

vantixloader-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for vantixloader-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d59f43b3fb8caf1f152af08a1f41d93f44314c90fb1f54397c3d94934606bcde
MD5 7fd364b92e3f47c2fc74e4c501a3bc10
BLAKE2b-256 e7d0a7f584b5b500a43efeda184665bce5406227590c8e7c7468a9c48fe6071e

See more details on using hashes here.

Provenance

The following attestation bundles were made for vantixloader-0.1.1.tar.gz:

Publisher: CI.yml on carlk13/vantix

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

File details

Details for the file vantixloader-0.1.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for vantixloader-0.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6ee9f28c4c7f1e2771dba7af9bd13ed58ed374cdaef5dd62812c576e0001f08a
MD5 4424264ff9f4b0a6420a78238d53e805
BLAKE2b-256 b9a8168d170df82f720ab1b01341a56843bbf903064acf5c50eee938acd156b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for vantixloader-0.1.1-cp310-cp310-win_amd64.whl:

Publisher: CI.yml on carlk13/vantix

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

File details

Details for the file vantixloader-0.1.1-cp310-cp310-win32.whl.

File metadata

  • Download URL: vantixloader-0.1.1-cp310-cp310-win32.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.10, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vantixloader-0.1.1-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 21ef875d03f094e289dc318859fc3f7e9b04a412eea17100355dceed0e87cac9
MD5 e181492e046244c7af652e76b5b9051d
BLAKE2b-256 1136a7d0802a03cef4daf4b3afb1f1f17cc87cdeaddb9c3d3beef8a892eff66d

See more details on using hashes here.

Provenance

The following attestation bundles were made for vantixloader-0.1.1-cp310-cp310-win32.whl:

Publisher: CI.yml on carlk13/vantix

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

File details

Details for the file vantixloader-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for vantixloader-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1f293c7c09ab8541dc22bb7889e93f62af9e37ab2a1ceb875cab2de679d0b355
MD5 6d5b83144a1d39917fc94b58375d7f00
BLAKE2b-256 6475cbab25dc2aa40a6de48e7a3dfa3671e4d0ee99a2c000f7a0109319f24ed8

See more details on using hashes here.

Provenance

The following attestation bundles were made for vantixloader-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: CI.yml on carlk13/vantix

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

File details

Details for the file vantixloader-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for vantixloader-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 21bebf9866143d529c894c0f1a153d6bff42c76eb27083018cdc4c020c611f24
MD5 4682e48b61785e55ba56228cb4f309dd
BLAKE2b-256 855f5f37de5001931b79e2f8f9c02e8dae70df14cb4af6c498a2c55c30f34417

See more details on using hashes here.

Provenance

The following attestation bundles were made for vantixloader-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: CI.yml on carlk13/vantix

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

File details

Details for the file vantixloader-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for vantixloader-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 add80a98d747bdfc3f995ac1ed762c7ae8478bd37081a743e8064e56b7e96bbb
MD5 da64e9165fc72e345f8be97a0f0c231c
BLAKE2b-256 0dcbfca7bd3d6a0586ccfc757c87b73a2d7bca567776708f2552e178161a6c2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for vantixloader-0.1.1-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: CI.yml on carlk13/vantix

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

File details

Details for the file vantixloader-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for vantixloader-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 08d4a6006887efed8ff39791b80f8af23933372467df4c88d1a6aff9655da0c6
MD5 07cd78c6d8367481f224c2ce10dee937
BLAKE2b-256 05e87ba0764865d950e3e42f3a4eef1322bf3d242786da8c6920c66df47d059c

See more details on using hashes here.

Provenance

The following attestation bundles were made for vantixloader-0.1.1-cp310-cp310-macosx_10_12_x86_64.whl:

Publisher: CI.yml on carlk13/vantix

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