Skip to main content

VAE-based image compression using latent space quantization and JPEG XL

Project description

vaepack

VAE-based image compression using latent space quantization and JPEG XL.

vaepack encodes images into the latent space of a Variational Autoencoder (SDXL), quantizes the latents to configurable bit-depth, and compresses the result with JPEG XL inside a compact .zvae container.

Alpha software. This project is experimental and not intended for production use. APIs and behavior may change without notice.

Installation

Recommended

Install the package with VAE support:

pip install "vaepack[diffusers]"

Minimal

Install the core package only:

pip install vaepack

This is enough for container inspection and non-VAE utilities, but encoding and decoding with the SDXL VAE requires the diffusers extra.

Note: if you need GPU acceleration, install the appropriate PyTorch build first. See pytorch.org.

From source

git clone https://github.com/DVA305-VT26-Grupp4/Projektarbete.git
cd Projektarbete
pip install -e ".[diffusers]"

Quick start

Python API

from vaepack import compress, decompress

state = compress("photo.png", "photo.zvae", quant_bits=10, metrics=True)
print(state.metrics)

state = decompress("photo.zvae", "recon.png")

Command line

zipvae compress photo.png -o photo.zvae --quant-bits 10 --metrics
zipvae decompress photo.zvae -o recon.png --reference photo.png --metrics

What the package provides

  • High-level compress() and decompress() helpers for notebooks and scripts
  • A stage-based pipeline API for step-by-step experimentation
  • A .zvae container format for compressed latents
  • JPEG XL latent compression via imagecodecs
  • PSNR and SSIM metrics
  • A zipvae command-line interface

Current limitations

  • The project is still alpha quality.
  • The packaged VAE backend is currently sdxl.
  • The packaged codec backend is currently jxl.
  • The first VAE load downloads weights from Hugging Face.
  • Kodak benchmark assets and notebooks live in the source repository, not in the PyPI package.

Examples and benchmark assets

The repository contains the batch benchmark script and the Colab notebook used for Kodak experiments:

For the full source, module-level docstrings, and issue tracker, use the project links on PyPI or visit the repository directly.

License

MIT

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

vaepack-0.1.1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

vaepack-0.1.1-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vaepack-0.1.1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for vaepack-0.1.1.tar.gz
Algorithm Hash digest
SHA256 91c52228936943b72e7b3385f643755750b7eca22ef6eeeee667e8f9c3b752e9
MD5 7059510710ad5ae3fc4d2181838d9c7f
BLAKE2b-256 ca302b5e8a5ce9edb7e089fc12e62405e5d92ae605d95536ac1523891f3406e5

See more details on using hashes here.

File details

Details for the file vaepack-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: vaepack-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for vaepack-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e0a78690f68b040a8752b1321aae6c65a23ead31caaf492eb4ec704ca430ecd6
MD5 7efa2234b1cbe04f4394494c30e649cb
BLAKE2b-256 98206d21c32b011258190043cc2c22cd04ae68028960fa4f0faf3fa6241b1745

See more details on using hashes here.

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