Batch preparation
Group compatible outputs without padding
Owned inputs can request full, region, reduced or region-plus-reduced decoding. The codec groups compatible dimensions, layouts and native sample types while retaining source order metadata.
AI ingestion / Rust / CUDA + Metal
Decode JPEG 2000 and HTJ2K batches into integer tensors or resident device buffers. Keep codec work separate from dataset policy, augmentation and model preprocessing.
01 / Decode boundary
Frames prepares and groups encoded images, executes supported codec routes, and returns the decoded rectangles and source indices. Sampling, labels and model policy remain with the application.
Batch preparation
Owned inputs can request full, region, reduced or region-plus-reduced decoding. The codec groups compatible dimensions, layouts and native sample types while retaining source order metadata.
Tensor outputs
j2k-ml returns rank-four Burn tensors as U8, U16 or I16. Float conversion and normalization remain ordinary tensor operations.
Device routes
CUDA can decode into Burn-owned device storage. Staged CUDA and Metal routes read completed output through host memory before ordinary framework upload. The route is explicit.
02 / Integrations
j2k-ml batch adapterCPU, direct CUDA, staged CUDA and staged Metal routes create ordinary Burn tensors while preserving codec group and failure information.
j2k-mpsgraph resident batchesSupported decoded batches can be handed to Apple MPSGraph without leaving the GPU. This integration adds no codec formats beyond J2K’s support boundary.
j2k-python PyTorch and NumPyThe optional Rust-written extension exposes native pixel tensors, reusable batches, region and reduced decode, selected wavelet bands, and a supported direct CUDA-to-PyTorch route.
03 / Start
The examples make the dataset, batching and device-transfer ownership visible. Explicit accelerator routes return errors for unsupported inputs rather than falling back silently.
$ cargo add j2k-ml --features cpu $ cargo run -p j2k-ml --example training_batcher --features cpu
Dataset → DataLoader → Batcher with source-index realignment and tensor normalization.
$ cargo run -p j2k-ml --example cuda_direct --features cudaDecode into the final Burn CUDA allocation without decoded-pixel host readback.