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.
Decode JPEG 2000 and HTJ2K batches into PyTorch tensors or NumPy arrays. Apple Metal and NVIDIA CUDA acceleration are available for supported inputs, alongside Rust integrations for Burn and MPSGraph.
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.
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.
j2k-ml returns rank-four Burn tensors as U8, U16 or I16. Float conversion and normalization remain ordinary tensor operations.
PyTorch supports direct MPS and CUDA output for supported inputs. Burn supports direct CUDA output; its staged Metal and CUDA routes copy through host memory.
j2k-ml batch adapterStaged Metal, direct CUDA, staged CUDA and CPU routes create 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 NumPyUse the Rust codecs from Python with NumPy and PyTorch output. Supported builds decode directly into PyTorch MPS tensors on Apple GPUs or CUDA tensors on NVIDIA GPUs. Region and reduced-resolution decoding, reusable batches and selected wavelet bands are also available.
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.