11# Introduction
22
3- This project contains data compression ops and layers for TensorFlow. The
4- project website is at
5- [ tensorflow.github.io/compression] ( https://tensorflow.github.io/compression ) .
3+ This project contains data compression ops and layers for TensorFlow.
64
75You can use this library to build your own ML models with end-to-end optimized
86data compression built in. It's useful to find storage-efficient representations
9- of your data (features, examples, images , etc.) while only sacrificing a tiny
7+ of your data (images, features, examples , etc.) while only sacrificing a tiny
108fraction of model performance. It can compress any floating point tensor to a
119much smaller sequence of bits.
1210
13- Specifically, the
14- [ EntropyBottleneck class] ( https://tensorflow.github.io/compression/docs/entropy_bottleneck.html )
15- in this library simplifies the process of designing rate–distortion optimized
16- codes. During training, it acts like a likelihood model. Once training is
17- completed, it encodes floating point tensors into optimal bit sequences by
18- automating the design of probability tables and calling a range coder
19- implementation behind the scenes.
11+ Specifically, the entropy model classes in this library simplify the process of
12+ designing rate–distortion optimized codes. During training, they act like
13+ likelihood models. Once training is completed, they encode floating point
14+ tensors into optimal bit sequences by automating the design of probability
15+ tables and calling a range coder implementation behind the scenes.
2016
21- For an introduction to lossy image compression with machine learning, take a
22- look at @jonycgn 's
23- [ talk on Learned Image Compression] ( https://www.youtube.com/watch?v=x_q7cZviXkY ) .
17+ The main novelty of this method over traditional transform coding is the
18+ stochastic minimization of the rate-distortion Lagrangian, and using nonlinear
19+ transforms implemented by neural networks. For an introduction to this, consider
20+ our [ paper on nonlinear transform coding] ( https://arxiv.org/abs/2007.03034 ) , or
21+ watch @jonycgn 's [ talk on learned image
22+ compression] ( https://www.youtube.com/watch?v=x_q7cZviXkY ) .
2423
2524## Documentation & getting help
2625
27- For usage questions and discussions, please head over to our
28- [ Google group] ( https://groups.google.com/forum/#!forum/tensorflow-compression ) .
26+ Please post all questions or comments in our [ Google
27+ group] ( https://groups.google.com/forum/#!forum/tensorflow-compression ) . Only
28+ file Github issues for actual bugs or feature requests. If you post to the group
29+ instead, you may get a faster answer, and you help other people find the
30+ question or answer more easily later.
2931
30- Refer to
31- [ the API documentation] ( https://tensorflow.github.io/compression/docs/api_docs/python/tfc.html )
32+ Refer to [ the API
33+ documentation] ( https://tensorflow.github.io/compression/docs/api_docs/python/tfc.html )
3234for a complete description of the Keras layers and TensorFlow ops this package
3335implements.
34-
35- There's also an introduction to our ` EntropyBottleneck ` class
36- [ here] ( https://tensorflow.github.io/compression/docs/entropy_bottleneck.html ) ,
37- and a description of the range coding operators
38- [ here] ( https://tensorflow.github.io/compression/docs/range_coding.html ) .
36+ *** Note: the API docs have not been updated for the current beta release yet.***
3937
4038## Installation
4139
42- *** Note: Precompiled packages are currently only provided for Linux (Python 2.7,
43- 3.3-3.6) and Darwin/Mac OS (Python 2.7, 3.7). To use these packages on Windows,
44- consider using a
45- [ TensorFlow Docker image] ( https://www.tensorflow.org/install/docker ) and
46- installing tensorflow-compression using pip inside the Docker container.***
40+ *** Note: Precompiled packages are currently only provided for Linux and
41+ Darwin/Mac OS. To use these packages on Windows, consider using a [ TensorFlow
42+ Docker image] ( https://www.tensorflow.org/install/docker ) and installing
43+ tensorflow-compression using pip inside the Docker container.***
4744
4845Set up an environment in which you can install precompiled binary Python
4946packages using the ` pip ` command. Refer to the
5047[ TensorFlow installation instructions] ( https://www.tensorflow.org/install/pip )
5148for more information on how to set up such a Python environment.
5249
53- The current version of tensorflow-compression requires TensorFlow 1.15. For
54- TensorFlow 1.14 or earlier, see our
55- [ previous releases] ( https://github.com/tensorflow/compression/releases ) . You can
50+ The current stable version of TFC (1.3) requires TensorFlow 1.15. The current
51+ beta release of TFC (2.0b1) is built for TensorFlow 2.3. For versions compatible
52+ with TensorFlow 1.14 or earlier, see our [ previous
53+ releases] ( https://github.com/tensorflow/compression/releases ) . The following
54+ instructions are for the stable release. To install the beta, replace the
55+ version numbers with 2.0b1 and 2.3, respectively.
56+
57+ You can
5658install TensorFlow from any source. To install it via ` pip ` , run the following
5759command:
5860``` bash
@@ -67,7 +69,7 @@ for CPU-only.
6769Then, run the following command to install the tensorflow-compression pip
6870package:
6971``` bash
70- pip install tensorflow-compression
72+ pip install tensorflow-compression==1.3
7173```
7274
7375To test that the installation works correctly, you can run the unit tests with
@@ -86,7 +88,7 @@ and then run the `pip install` command inside the Docker container, not on the
8688host. For instance, you can use a command line like this:
8789``` bash
8890docker run tensorflow/tensorflow:1.15.0-py3 bash -c \
89- " pip install tensorflow-compression &&
91+ " pip install tensorflow-compression==1.3 &&
9092 python -m tensorflow_compression.python.all_test"
9193```
9294This will fetch the TensorFlow Docker image if it's not already cached, install
@@ -95,16 +97,15 @@ the pip package and then run the unit tests to confirm that it works.
9597### Anaconda
9698
9799It seems that [ Anaconda] ( https://www.anaconda.com/distribution/ ) ships its own
98- binary version of TensorFlow which is incompatible with our pip package. It
99- also installs Python 3.7 by default, which we currently don't support on Linux.
100- To solve this, make sure to use Python 3.6 on Linux, and always install
101- TensorFlow via ` pip ` rather than ` conda ` . For example, this creates an Anaconda
102- environment with Python 3.6 and CUDA libraries, and then installs TensorFlow
103- and tensorflow-compression with GPU support:
100+ binary version of TensorFlow which is incompatible with our pip package. To
101+ solve this, always install TensorFlow via ` pip ` rather than ` conda ` . For
102+ example, this creates an Anaconda environment with Python 3.6 and CUDA
103+ libraries, and then installs TensorFlow and tensorflow-compression with GPU
104+ support:
104105``` bash
105106conda create --name ENV_NAME python=3.6 cudatoolkit=10.0 cudnn
106107conda activate ENV_NAME
107- pip install tensorflow-gpu==1.15 tensorflow-compression
108+ pip install tensorflow-gpu==1.15 tensorflow-compression==1.3
108109```
109110
110111## Usage
@@ -194,24 +195,24 @@ This section describes the necessary steps to build your own pip packages of
194195tensorflow-compression. This may be necessary to install it on platforms for
195196which we don't provide precompiled binaries (currently only Linux and Darwin).
196197
197- We use the Docker image ` tensorflow/tensorflow:custom-op-ubuntu16 ` for building
198- pip packages for Linux. Note that this is different from
199- ` tensorflow/tensorflow:devel ` . To be compatible with the TensorFlow pip package,
200- the GCC version must match, but ` tensorflow/tensorflow:devel ` has a different
201- GCC version installed.
198+ We use the custom-op Docker images (e.g.
199+ ` tensorflow/tensorflow:nightly-custom-op-ubuntu16 ` ) for building pip packages
200+ for Linux. Note that this is different from ` tensorflow/tensorflow:devel ` . To be
201+ compatible with the TensorFlow pip package, the GCC version must match, but
202+ ` tensorflow/tensorflow:devel ` has a different GCC version installed. For more
203+ information, refer to the [ custom-op
204+ instructions] ( https://github.com/tensorflow/custom-op ) .
202205
203206Inside a Docker container from the image, the following steps need to be taken.
204207
205- 1 . Install the TensorFlow pip package.
206- 2 . Clone the ` tensorflow/compression ` repo from GitHub.
207- 3 . Run ` :build_pip_pkg ` inside the cloned repo.
208+ 1 . Clone the ` tensorflow-compression ` repo from GitHub.
209+ 2 . Run ` :build_pip_pkg ` inside the cloned repo.
208210
209211For example:
210212``` bash
211213sudo docker run -v /tmp/tensorflow_compression:/tmp/tensorflow_compression \
212- tensorflow/tensorflow:custom-op-ubuntu16 bash -c \
213- " pip install tensorflow==1.15 &&
214- git clone https://github.com/tensorflow/compression.git
214+ tensorflow/tensorflow:nightly-custom-op-ubuntu16 bash -c \
215+ " git clone https://github.com/tensorflow/compression.git
215216 /tensorflow_compression &&
216217 cd /tensorflow_compression &&
217218 bazel run -c opt --copt=-mavx :build_pip_pkg"
@@ -228,7 +229,7 @@ pip install /tmp/tensorflow_compression/tensorflow_compression-*.whl
228229Then run the unit tests (Do not run the tests in the workspace directory where
229230` WORKSPACE ` of ` tensorflow_compression ` repo lives. In that case, the Python
230231interpreter would attempt to import ` tensorflow_compression ` packages from the
231- source tree rather than from the installed package system directory):
232+ source tree, rather than from the installed package system directory):
232233``` bash
233234pushd /tmp
234235python -m tensorflow_compression.python.all_test
@@ -256,5 +257,6 @@ for more information.
256257* Sung Jin Hwang (github: [ ssjhv] ( https://github.com/ssjhv ) )
257258* Nick Johnston (github: [ nmjohn] ( https://github.com/nmjohn ) )
258259* David Minnen (github: [ minnend] ( https://github.com/minnend ) )
260+ * Eirikur Agustsson (github: [ relational] ( https://github.com/relational ) )
259261
260262Note that this is not an officially supported Google product.
0 commit comments