Library / SDK
tensorflow/compression avatar
tensorflow/compression

TensorFlow Compression in maintenance mode: what the 2.17 freeze means for learned codecs

Data compression in TensorFlow

923 stars258 forksPythonApache-2.0

At a glance

What is it?
TensorFlow Compression bundles range coding ops, entropy models and Keras layers for building learned data compression into a TensorFlow model. Since February 2024 the feature set is frozen, and the packaging story now splits into two PyPI distributions with different TensorFlow ceilings.
Who is it for?
Adopt TensorFlow Compression if you are building or reproducing a learned compression model on TensorFlow 2.14 and want the range coder, entropy model classes and GDN layer available as ordinary TensorFlow ops. Do not adopt it if you need new features, Windows wheels without WSL2 or Docker, or a code path that survives past TF 2.18 through tensorflow-compression-ops.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 151 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

The problem TFC solves is a differentiable entropy bottleneck, not smaller files

Most compression libraries answer one question: how few bytes can this file become. TensorFlow Compression answers a different one. The README frames the library as a way to build ML models with end-to-end optimized data compression built in, so the model that consumes or produces the data and the code that compresses it are trained together. The intended use is finding storage-efficient representations of images, features or examples while sacrificing only a small fraction of model performance.

That framing matters for who the library is for. If you just want to shrink a PNG, a JPEG encoder or zstd will beat anything here on effort and usually on size. TFC is aimed at researchers and engineers who already have a TensorFlow model and want the bitrate to be part of the objective rather than a post-processing step. The README points to two entry points: a lossy data compression tutorial and a model compression tutorial, plus a paper on nonlinear transform coding for readers coming from a classical compression background and a review paper for readers coming from machine learning.

The scope is deliberately narrow. The library does not ship a finished image or video codec. It ships the pieces you would assemble into one.

Range coding ops, entropy models and the layers in between

The README lists three groups of components, and the split is worth understanding because each group has a different cost of adoption.

The first is range coding, also called arithmetic coding, implemented as flexible TensorFlow ops written in C++. One documented detail stands out: an optional overflow functionality that embeds an Elias gamma code into the range encoded bit sequence. That extends the encodable alphabet from a finite range to the entire set of signed integers. Without it, you would have to bound your symbols before encoding; with it, the bitstream handles tails that fall outside whatever range you tabulated.

The second is entropy model classes, which the README describes as simplifying the design of rate-distortion optimized codes. Their behaviour changes between phases. During training they act like likelihood models, so gradients flow through them. After training, they encode floating point tensors into bit sequences by automating the design of range coding tables and then calling the range coder behind the scenes. That two-phase design is the core mechanism: you never hand-write a frequency table, and you never call the range coder directly in the training loop.

The third group is supporting TensorFlow functions and Keras layers: methods to numerically find quantiles of density functions, expectations with respect to dithering noise, convolution layers with more flexible padding options, support for reparameterizing kernels and biases in the Fourier domain, and an implementation of generalized divisive normalization. GDN is the piece most associated with learned image compression, and having it as a layer rather than something you reimplement is a real convenience. The API docs are the place to check exact signatures, since the README only names the categories.

Installation is a pip line plus a version pin you have to get right

The README gives a direct install path. Create a Python environment that can install precompiled wheels with pip, then run:

python -m pip install tensorflow-compression

To check the install, run the bundled tests:

python -m tensorflow_compression.all_tests

The README says the last line should read something like OK (skipped=29).

The constraint that bites is version coupling. The README states that binary packages of TFC are tied to TensorFlow with the same minor version, so TFC 2.9.1 requires TF 2.9.x. The Colab instructions work around this with a shell substitution that reads the installed TensorFlow version and installs the matching TFC:

%pip install tensorflow-compression~=$(pip show tensorflow | perl -p -0777 -e 's/.*Version: (\d+\.\d+).*/\1.0/sg')

The README explains why this is necessary: Colab sometimes lags in deploying the latest TensorFlow, so a naive pip install tensorflow-compression may try to upgrade TensorFlow and create problems.

Platform coverage is also limited. Precompiled packages are provided only for Linux and Darwin/Mac OS. Windows users are directed to WSL2 or a TensorFlow Docker image, and the README gives a one-liner that installs the package and runs the tests inside the container:

docker run tensorflow/tensorflow:latest bash -c "python -m pip install tensorflow-compression && python -m tensorflow_compression.all_tests"

One more environment trap: the README states that Anaconda ships its own binary TensorFlow that is incompatible with the pip package, and the advice is to install TensorFlow via pip rather than conda, even when the conda environment is used for CUDA libraries.

Two packages, two TensorFlow ceilings, and no new features

The maintenance notice from February 1, 2024 is the single most important fact about this project. The README states it plainly: the full feature set is frozen, no new features will be developed, and the repository will receive maintenance fixes.

The reason given is technical, not a lack of interest. An incompatibility introduced in the Keras version shipped with TF 2.15 would require a rewrite of the layer and entropy model classes. Rather than do that, the maintainers capped new TFC packages at TensorFlow 2.14 and split out a second package, tensorflow-compression-ops, which contains only the C++ ops. That package is meant to let existing models keep running on TF 2.15 and later.

That second package has its own deadline. The README's update note says that due to technical challenges in maintaining C++ custom ops with newer TensorFlow releases, TF 2.18 will be the last version supported by tensorflow-compression-ops. Both are on PyPI as tensorflow-compression and tensorflow-compression-ops.

So the practical picture is a hard split. If you want the entropy models and Keras layers, you are on TF 2.14. If you only need the range coder ops and you are on a newer TensorFlow, you can use the ops-only package, but only up to TF 2.18. There is no documented path for the entropy model classes on TF 2.15 or later, and the README does not promise one.

Where TFC is the wrong tool

The clearest failure mode is a project that needs to track upstream TensorFlow. If your team upgrades TensorFlow on a schedule, TFC's entropy model classes will hold you at 2.14, and the ops-only escape hatch stops at 2.18. A model that depends on both the entropy models and a newer TensorFlow has no supported configuration according to the README.

A second case is general-purpose file compression. TFC is built around rate-distortion optimized codes for data your model already understands. For compressing logs, archives or arbitrary binaries, a classical codec is simpler, has no TensorFlow version coupling, and needs no training run to produce its tables.

A third case is deployment on Windows without containers. The README offers WSL2 or a TensorFlow Docker image as the routes, and while both work, they add a layer between your build and your target. If your constraint is a native Windows wheel, this project does not provide one.

Finally, there is the maintenance-mode risk itself. A frozen feature set with maintenance fixes is a reasonable state for a library that is finished, but it is a poor fit for a team that needs bug fixes in the entropy model classes tied to a Keras change. The README's own explanation shows that the maintainers chose to freeze rather than absorb that rewrite.

The alternative is usually a classical codec, and the difference is where the model sits

The honest alternative for most readers is a conventional codec: JPEG or WebP for images, zstd or Brotli for general bytes. The difference in approach is structural. A classical codec has a fixed transform and a fixed entropy model designed by people and tuned over years. It is fast, it is available everywhere, and it does not care what TensorFlow version you run.

TFC inverts that. The transform and the entropy model are learned, which is what lets the README describe sacrificing only a small fraction of model performance in exchange for storage-efficient representations. The cost is that the codec is now part of your training pipeline. You need training data, a training run, and a checkpoint before you can encode anything, and you inherit the TensorFlow version constraints described above.

There is a middle path worth naming, though the README does not discuss it: use a classical codec and let your model work on the decoded data. That is the right call when the compression ratio is not the thing you are optimizing. TFC only earns its complexity when the bitrate is inside the loss and the model and the coder have to be trained together. If you cannot state that requirement for your project, the classical codec is the better default.

Maintenance cost, licensing and what to verify before you commit

Maintenance cost here is mostly version arithmetic. You are pinning TensorFlow to a minor version, and the README states that TFC wheels are tied to TensorFlow at the same minor version. Upgrading TensorFlow is therefore not a routine dependency bump; it is a decision about which TFC package you can use. The ops-only package buys time to TF 2.18, and the README does not indicate what happens after that.

On licensing, the repository is Apache-2.0. That is a permissive license, and it is the same family TensorFlow itself uses. I am not a lawyer and this is not legal advice; if you are redistributing binaries or linking the C++ ops into a product, read the license text and your own counsel's guidance rather than relying on a summary.

What to verify first, concretely. Pin your TensorFlow version and install the matching TFC wheel, then run python -m tensorflow_compression.all_tests and confirm the OK line. Check the API docs for the exact entropy model and GDN classes you plan to use, since the README names categories rather than signatures. Decide which of the two PyPI packages you actually need, because the choice determines your TensorFlow ceiling. And read the maintenance notice in full before you plan a multi-year dependency on the entropy model classes.

Editorial conclusion

Adopt TensorFlow Compression if you are building or reproducing a learned compression model on TensorFlow 2.14 and want the range coder, entropy model classes and GDN layer available as ordinary TensorFlow ops. Do not adopt it if you need new features, Windows wheels without WSL2 or Docker, or a code path that survives past TF 2.18 through tensorflow-compression-ops. Before committing, pin your TensorFlow minor version, confirm that python -m tensorflow_compression.all_tests prints OK in your environment, and check whether the C++ ops you depend on are covered by the tensorflow-compression-ops ceiling.

Official sources

  1. Issues
  2. License: Apache-2.0
  3. README
  4. Releases
  5. tensorflow/compression on GitHub
Community notes

Community notes