Skip to main content

License PyPI Downloads

CompressAI (compress-ay) is a PyTorch library and evaluation platform for end-to-end compression research.

CompressAI currently provides:

  • custom operations, layers and models for deep learning based data compression
  • a partial port of the official TensorFlow compression library
  • pre-trained end-to-end compression models for learned image compression
  • evaluation scripts to compare learned models against classical image/video compression codecs

PSNR performances plot on Kodak

Note: Multi-GPU support is now experimental.

Installation

CompressAI supports python 3.8+ and PyTorch 1.7+.

pip:

pip install compressai

Note: wheels are available for Linux and MacOS.

From source:

A C++17 compiler, a recent version of pip (19.0+), and common python packages are also required (see setup.py for the full list).

To get started locally and install the development version of CompressAI, run the following commands in a virtual environment:

git clone https://github.com/InterDigitalInc/CompressAI compressai
cd compressai
pip install -U pip && pip install -e .

For a custom installation, you can also run one of the following commands:

  • pip install -e '.[dev]': install the packages required for development (testing, linting, docs)
  • pip install -e '.[tutorials]': install the packages required for the tutorials (notebooks)

Note: Docker images will be released in the future. Conda environments are not officially supported.

Documentation

Usage

Examples

Script and notebook examples can be found in the examples/ directory.

To encode/decode images with the provided pre-trained models, run the codec.py example:

python3 examples/codec.py --help

An examplary training script with a rate-distortion loss is provided in examples/train.py. You can replace the model used in the training script with your own model implemented within CompressAI, and then run the script for a simple training pipeline:

python3 examples/train.py -d /path/to/my/image/dataset/ --epochs 300 -lr 1e-4 --batch-size 16 --cuda --save

Note: the training example uses a custom ImageFolder structure.

A jupyter notebook illustrating the usage of a pre-trained model for learned image compression is also provided in the examples directory:

pip install -U ipython jupyter ipywidgets matplotlib
jupyter notebook examples/

Evaluation

To evaluate a trained model on your own dataset, CompressAI provides an evaluation script:

python3 -m compressai.utils.eval_model checkpoint /path/to/images/folder/ -a $ARCH -p $MODEL_CHECKPOINT...

To evaluate provided pre-trained models:

python3 -m compressai.utils.eval_model pretrained /path/to/images/folder/ -a $ARCH -q $QUALITY_LEVELS...

To plot results from bench/eval_model simulations (requires matplotlib by default):

python3 -m compressai.utils.plot --help

To evaluate traditional codecs:

python3 -m compressai.utils.bench --help
python3 -m compressai.utils.bench bpg --help
python3 -m compressai.utils.bench vtm --help

For video, similar tests can be run, CompressAI only includes ssf2020 for now:

python3 -m compressai.utils.video.eval_model checkpoint /path/to/video/folder/ -a ssf2020 -p $MODEL_CHECKPOINT...
python3 -m compressai.utils.video.eval_model pretrained /path/to/video/folder/ -a ssf2020 -q $QUALITY_LEVELS...
python3 -m compressai.utils.video.bench x265 --help
python3 -m compressai.utils.video.bench VTM --help
python3 -m compressai.utils.video.plot --help

Tests

Run tests with pytest:

pytest -sx --cov=compressai --cov-append --cov-report term-missing tests

Slow tests can be skipped with the -m "not slow" option.

License

CompressAI is licensed under the BSD 3-Clause Clear License

Contributing

We welcome feedback and contributions. Please open a GitHub issue to report bugs, request enhancements or if you have any questions.

Before contributing, please read the CONTRIBUTING.md file.

Authors

  • Jean Bégaint, Fabien Racapé, Simon Feltman and Hyomin Choi, InterDigital AI Lab.

Citation

If you use this project, please cite the relevant original publications for the models and datasets, and cite this project as:

@article{begaint2020compressai,
	title={CompressAI: a PyTorch library and evaluation platform for end-to-end compression research},
	author={B{\'e}gaint, Jean and Racap{\'e}, Fabien and Feltman, Simon and Pushparaja, Akshay},
	year={2020},
	journal={arXiv preprint arXiv:2011.03029},
}

For any work related to the variable bitrate models, please cite

@article{kamisli2024dcc_vbrlic,
	title={Variable-Rate Learned Image Compression with Multi-Objective Optimization and Quantization-Reconstruction Offsets},
	author={Kamisli, Fatih and Racap{\'e}, Fabien and Choi, Hyomin},
	year={2024},
	booktitle={2024 Data Compression Conference (DCC)},
	eprint={2402.18930},
}

Release files for compressai 1.2.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for compressai 1.2.8
File Size Uploaded
compressai-1.2.8.tar.gz 183.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for compressai 1.2.8
File
compressai-1.2.8-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
compressai-1.2.8-cp312-cp312-macosx_10_14_universal2.whl CPython 3.12 CPython 3.12 macOS 10.14+ universal2 (ARM64, x86-64) Details
compressai-1.2.8-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details
compressai-1.2.8-cp311-cp311-macosx_10_14_universal2.whl CPython 3.11 CPython 3.11 macOS 10.14+ universal2 (ARM64, x86-64) Details
compressai-1.2.8-cp310-cp310-manylinux_2_34_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.34+ x86-64 Details
compressai-1.2.8-cp310-cp310-macosx_10_14_universal2.whl CPython 3.10 CPython 3.10 macOS 10.14+ universal2 (ARM64, x86-64) Details
compressai-1.2.8-cp39-cp39-manylinux_2_34_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.34+ x86-64 Details
compressai-1.2.8-cp39-cp39-macosx_10_14_universal2.whl CPython 3.9 CPython 3.9 macOS 10.14+ universal2 (ARM64, x86-64) Details
compressai-1.2.8-cp38-cp38-manylinux_2_34_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.34+ x86-64 Details
compressai-1.2.8-cp38-cp38-macosx_11_0_universal2.whl CPython 3.8 CPython 3.8 macOS 11.0+ universal2 (ARM64, x86-64) Details

Total release size: 5.1 MB

Release files / compressai-1.2.8.tar.gz

Download URL compressai-1.2.8.tar.gz
Size 183.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d90a923694b4b66c3e39bd90316e7f177a620787190ca7550731fc16c1bc7d5e
BLAKE2b-256 checksum
How to use checksums
a365c6e387c10f159a15f9c0099b6656636d4e2ab4e2df1412b1755c8aee55f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.18

Release files / compressai-1.2.8-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL compressai-1.2.8-cp312-cp312-manylinux_2_34_x86_64.whl
Size 444.5 kB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
df389dd0503213a7d0856d03286d4532c048afa7421a1cf1ff1097ddc0b564a6
BLAKE2b-256 checksum
How to use checksums
82bdc0a79dd7afe66e5d0efd49ec1aa199d8508c1bdd4e13de7b5cab21d5625c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / compressai-1.2.8-cp312-cp312-macosx_10_14_universal2.whl

Download URL compressai-1.2.8-cp312-cp312-macosx_10_14_universal2.whl
Size 540.9 kB
Tags CPython 3.12 macOS 10.14+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
2b0edf145f24d2eb2698b7e96c2332a8eac2cc8aea1416c13f3bf32a8fd5d33c
BLAKE2b-256 checksum
How to use checksums
d4d7fe36517c1f302647b3a7231b8ce233abd2b192e709a261cfb94e17bf13d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / compressai-1.2.8-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL compressai-1.2.8-cp311-cp311-manylinux_2_34_x86_64.whl
Size 445.1 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
65ad37fa12848bf11a597e37c4e527b993fc5ba736974a02137ab1026636c535
BLAKE2b-256 checksum
How to use checksums
3424fa2fcf454447bbdcaeede1884c4e9757d3b90c6b1fa8b5e06a7162f1f4da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / compressai-1.2.8-cp311-cp311-macosx_10_14_universal2.whl

Download URL compressai-1.2.8-cp311-cp311-macosx_10_14_universal2.whl
Size 544.6 kB
Tags CPython 3.11 macOS 10.14+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
dae7c6dac90cdb45575c1b144512defb243ea93c316d78dbfe76658d35286903
BLAKE2b-256 checksum
How to use checksums
0ce399399a27a1b3f738bcfc790b259ede02aa1b41bf106e01cfdad06d7d6003
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.9

Release files / compressai-1.2.8-cp310-cp310-manylinux_2_34_x86_64.whl

Download URL compressai-1.2.8-cp310-cp310-manylinux_2_34_x86_64.whl
Size 442.2 kB
Tags CPython 3.10 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
7ba289e3f8188845f8c02b6852ab3364e26c6d27d699f9cbd4e9a1cec8c486ca
BLAKE2b-256 checksum
How to use checksums
d5f7ce39375ab4cdfdfa704d8c24b781fccf932470ee9a2f8d5fe76427ff23e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Release files / compressai-1.2.8-cp310-cp310-macosx_10_14_universal2.whl

Download URL compressai-1.2.8-cp310-cp310-macosx_10_14_universal2.whl
Size 538.6 kB
Tags CPython 3.10 macOS 10.14+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
fad8b0cab994b2e5f3f9e99ccdc7054607fa785c99d21a61c6cfd6a904c57cac
BLAKE2b-256 checksum
How to use checksums
7ac487698640ebf2dbd02a33de38e5c93ac58be3afff6b840e48d8707a0fd0d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.11

Release files / compressai-1.2.8-cp39-cp39-manylinux_2_34_x86_64.whl

Download URL compressai-1.2.8-cp39-cp39-manylinux_2_34_x86_64.whl
Size 442.5 kB
Tags CPython 3.9 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
c805044a3f538c815487a87f0828db23c3e811b56d53b3385d02074aaa31658c
BLAKE2b-256 checksum
How to use checksums
4252db27ffef2affab1d66a63aa77383073f70a0c87579cd8bd7331d139d30f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release files / compressai-1.2.8-cp39-cp39-macosx_10_14_universal2.whl

Download URL compressai-1.2.8-cp39-cp39-macosx_10_14_universal2.whl
Size 539.0 kB
Tags CPython 3.9 macOS 10.14+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
c208f3d970a806b9187c0632e734dbd1aea7f50f6b144e7dd331fbb932b4b4d7
BLAKE2b-256 checksum
How to use checksums
892b523a106e54db068482b126f399c54a8f5c79b2617aa321244be3852ff757
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.13

Release files / compressai-1.2.8-cp38-cp38-manylinux_2_34_x86_64.whl

Download URL compressai-1.2.8-cp38-cp38-manylinux_2_34_x86_64.whl
Size 441.6 kB
Tags CPython 3.8 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
4d54986623f6840b931497dba84b758f6aca2775fe4249632e8e5ae14ae1b41c
BLAKE2b-256 checksum
How to use checksums
9fe5386f6fb0919fa02dc7a4daee1b9de139a3324e6c24998ad6491c2e785fee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / compressai-1.2.8-cp38-cp38-macosx_11_0_universal2.whl

Download URL compressai-1.2.8-cp38-cp38-macosx_11_0_universal2.whl
Size 538.1 kB
Tags CPython 3.8 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
d3ed57ad80cca0c3a60e1d7fba9d7718a5c26a77ccaa180b5ebef902eaf1656a
BLAKE2b-256 checksum
How to use checksums
c7fb99f530505016bee6cba3b8a04f682272155680591f8395535b553542894d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10
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