1
1
# Introduction
2
2
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.
6
4
7
5
You can use this library to build your own ML models with end-to-end optimized
8
6
data 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
10
8
fraction of model performance. It can compress any floating point tensor to a
11
9
much smaller sequence of bits.
12
10
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.
20
16
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 ) .
24
23
25
24
## Documentation & getting help
26
25
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.
29
31
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 )
32
34
for a complete description of the Keras layers and TensorFlow ops this package
33
35
implements.
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.***
39
37
40
38
## Installation
41
39
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.***
47
44
48
45
Set up an environment in which you can install precompiled binary Python
49
46
packages using the ` pip ` command. Refer to the
50
47
[ TensorFlow installation instructions] ( https://www.tensorflow.org/install/pip )
51
48
for more information on how to set up such a Python environment.
52
49
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
56
58
install TensorFlow from any source. To install it via ` pip ` , run the following
57
59
command:
58
60
``` bash
@@ -67,7 +69,7 @@ for CPU-only.
67
69
Then, run the following command to install the tensorflow-compression pip
68
70
package:
69
71
``` bash
70
- pip install tensorflow-compression
72
+ pip install tensorflow-compression==1.3
71
73
```
72
74
73
75
To 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
86
88
host. For instance, you can use a command line like this:
87
89
``` bash
88
90
docker run tensorflow/tensorflow:1.15.0-py3 bash -c \
89
- " pip install tensorflow-compression &&
91
+ " pip install tensorflow-compression==1.3 &&
90
92
python -m tensorflow_compression.python.all_test"
91
93
```
92
94
This 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.
95
97
### Anaconda
96
98
97
99
It 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:
104
105
``` bash
105
106
conda create --name ENV_NAME python=3.6 cudatoolkit=10.0 cudnn
106
107
conda activate ENV_NAME
107
- pip install tensorflow-gpu==1.15 tensorflow-compression
108
+ pip install tensorflow-gpu==1.15 tensorflow-compression==1.3
108
109
```
109
110
110
111
## Usage
@@ -194,24 +195,24 @@ This section describes the necessary steps to build your own pip packages of
194
195
tensorflow-compression. This may be necessary to install it on platforms for
195
196
which we don't provide precompiled binaries (currently only Linux and Darwin).
196
197
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 ) .
202
205
203
206
Inside a Docker container from the image, the following steps need to be taken.
204
207
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.
208
210
209
211
For example:
210
212
``` bash
211
213
sudo 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
215
216
/tensorflow_compression &&
216
217
cd /tensorflow_compression &&
217
218
bazel run -c opt --copt=-mavx :build_pip_pkg"
@@ -228,7 +229,7 @@ pip install /tmp/tensorflow_compression/tensorflow_compression-*.whl
228
229
Then run the unit tests (Do not run the tests in the workspace directory where
229
230
` WORKSPACE ` of ` tensorflow_compression ` repo lives. In that case, the Python
230
231
interpreter 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):
232
233
``` bash
233
234
pushd /tmp
234
235
python -m tensorflow_compression.python.all_test
@@ -256,5 +257,6 @@ for more information.
256
257
* Sung Jin Hwang (github: [ ssjhv] ( https://github.com/ssjhv ) )
257
258
* Nick Johnston (github: [ nmjohn] ( https://github.com/nmjohn ) )
258
259
* David Minnen (github: [ minnend] ( https://github.com/minnend ) )
260
+ * Eirikur Agustsson (github: [ relational] ( https://github.com/relational ) )
259
261
260
262
Note that this is not an officially supported Google product.
0 commit comments