Skip to content

Commit 8a4a7b6

Browse files
Johannes Ballécopybara-github
authored andcommitted
Updates for v2.0b2 to match TF v2.4.
PiperOrigin-RevId: 350246641 Change-Id: I87f4096d2745fb280bae94b21b8465f3916d2049
1 parent fd634d9 commit 8a4a7b6

File tree

4 files changed

+51
-21
lines changed

4 files changed

+51
-21
lines changed

README.md

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,40 @@ packages using the `pip` command. Refer to the
4848
for more information on how to set up such a Python environment.
4949

5050
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
51+
beta release of TFC (2.0b2) is built for TensorFlow 2.4. For versions compatible
5252
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.
53+
releases](https://github.com/tensorflow/compression/releases).
54+
55+
### pip
56+
57+
To install TF and TFC via `pip`, run the following command:
5658

57-
You can
58-
install TensorFlow from any source. To install it via `pip`, run the following
59-
command:
60-
```bash
61-
pip install tensorflow-gpu==1.15
62-
```
63-
for GPU support, or
6459
```bash
65-
pip install tensorflow==1.15
60+
pip install tensorflow-gpu==1.15 tensorflow-compression==1.3
6661
```
67-
for CPU-only.
6862

69-
Then, run the following command to install the tensorflow-compression pip
70-
package:
63+
for the stable release, or
64+
7165
```bash
72-
pip install tensorflow-compression==1.3
66+
pip install tensorflow-gpu==2.4 tensorflow-probability==0.12.1 tensorflow-compression==2.0b2
7367
```
7468

69+
for the beta release. If you don't need GPU support, you can drop the `-gpu`
70+
part.
71+
7572
To test that the installation works correctly, you can run the unit tests with
73+
(respectively):
74+
7675
```bash
7776
python -m tensorflow_compression.python.all_test
7877
```
78+
79+
or
80+
81+
```bash
82+
python -m tensorflow_compression.all_tests
83+
```
84+
7985
Once the command finishes, you should see a message ```OK (skipped=12)``` or
8086
similar in the last line.
8187

@@ -86,11 +92,21 @@ To use a Docker container (e.g. on Windows), be sure to install Docker
8692
use a [TensorFlow Docker image](https://www.tensorflow.org/install/docker),
8793
and then run the `pip install` command inside the Docker container, not on the
8894
host. For instance, you can use a command line like this:
95+
8996
```bash
9097
docker run tensorflow/tensorflow:1.15.0-py3 bash -c \
9198
"pip install tensorflow-compression==1.3 &&
9299
python -m tensorflow_compression.python.all_test"
93100
```
101+
102+
or (for the beta version):
103+
104+
```bash
105+
docker run tensorflow/tensorflow:2.4.0 bash -c \
106+
"pip install tensorflow-probability==0.12.1 tensorflow-compression==2.0b2 &&
107+
python -m tensorflow_compression.all_tests"
108+
```
109+
94110
This will fetch the TensorFlow Docker image if it's not already cached, install
95111
the pip package and then run the unit tests to confirm that it works.
96112

@@ -102,6 +118,7 @@ solve this, always install TensorFlow via `pip` rather than `conda`. For
102118
example, this creates an Anaconda environment with Python 3.6 and CUDA
103119
libraries, and then installs TensorFlow and tensorflow-compression with GPU
104120
support:
121+
105122
```bash
106123
conda create --name ENV_NAME python=3.6 cudatoolkit=10.0 cudnn
107124
conda activate ENV_NAME
@@ -122,20 +139,25 @@ import tensorflow_compression as tfc
122139
In the
123140
[models directory](https://github.com/tensorflow/compression/tree/master/models),
124141
you'll find a python script `tfci.py`. Download the file and run:
142+
125143
```bash
126144
python tfci.py -h
127145
```
128146

129147
This will give you a list of options. Briefly, the command
148+
130149
```bash
131150
python tfci.py compress <model> <PNG file>
132151
```
152+
133153
will compress an image using a pre-trained model and write a file ending in
134154
`.tfci`. Execute `python tfci.py models` to give you a list of supported
135155
pre-trained models. The command
156+
136157
```bash
137158
python tfci.py decompress <TFCI file>
138159
```
160+
139161
will decompress a TFCI file and write a PNG file. By default, an output file
140162
will be named like the input file, only with the appropriate file extension
141163
appended (any existing extensions will not be removed).
@@ -151,13 +173,15 @@ contains an implementation of the image compression model described in:
151173
> https://arxiv.org/abs/1611.01704
152174
153175
To see a list of options, download the file `bls2017.py` and run:
176+
154177
```bash
155178
python bls2017.py -h
156179
```
157180

158181
To train the model, you need to supply it with a dataset of RGB training images.
159182
They should be provided in PNG format. Training can be as simple as the
160183
following command:
184+
161185
```bash
162186
python bls2017.py --verbose train --train_glob="images/*.png"
163187
```
@@ -177,13 +201,15 @@ enough (or larger). This is described in more detail in:
177201
If you wish, you can monitor progress with Tensorboard. To do this, create a
178202
Tensorboard instance in the background before starting the training, then point
179203
your web browser to [port 6006 on your machine](http://localhost:6006):
204+
180205
```bash
181206
tensorboard --logdir=. &
182207
```
183208

184209
When training has finished, the Python script can be used to compress and
185210
decompress images as follows. The same model checkpoint must be accessible to
186211
both commands.
212+
187213
```bash
188214
python bls2017.py [options] compress original.png compressed.tfci
189215
python bls2017.py [options] decompress compressed.tfci reconstruction.png
@@ -209,6 +235,7 @@ Inside a Docker container from the image, the following steps need to be taken.
209235
2. Run `:build_pip_pkg` inside the cloned repo.
210236

211237
For example:
238+
212239
```bash
213240
sudo docker run -v /tmp/tensorflow_compression:/tmp/tensorflow_compression \
214241
tensorflow/tensorflow:nightly-custom-op-ubuntu16 bash -c \
@@ -222,6 +249,7 @@ The wheel file is created inside `/tmp/tensorflow_compression`. Optimization
222249
flags can be passed via `--copt` to the `bazel run` command above.
223250

224251
To test the created package, first install the resulting wheel file:
252+
225253
```bash
226254
pip install /tmp/tensorflow_compression/tensorflow_compression-*.whl
227255
```
@@ -230,13 +258,15 @@ Then run the unit tests (Do not run the tests in the workspace directory where
230258
`WORKSPACE` of `tensorflow_compression` repo lives. In that case, the Python
231259
interpreter would attempt to import `tensorflow_compression` packages from the
232260
source tree, rather than from the installed package system directory):
261+
233262
```bash
234263
pushd /tmp
235264
python -m tensorflow_compression.all_tests
236265
popd
237266
```
238267

239268
When done, you can uninstall the pip package again:
269+
240270
```bash
241271
pip uninstall tensorflow-compression
242272
```

build_pip_pkg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def main(srcdir):
6464
packages=setuptools.find_packages(),
6565
install_requires=[
6666
'scipy >= 1',
67-
'tensorflow_probability >= 0.9',
67+
'tensorflow_probability >= 0.12.1',
6868
],
6969
script_args=['sdist', 'bdist_wheel'],
7070
# Add in any packaged data.
@@ -78,7 +78,7 @@ def main(srcdir):
7878
'Intended Audience :: Education',
7979
'Intended Audience :: Science/Research',
8080
'License :: OSI Approved :: Apache Software License',
81-
'Programming Language :: Python :: 3.5',
81+
'Programming Language :: Python :: 3',
8282
'Programming Language :: Python :: 3.6',
8383
'Programming Language :: Python :: 3.7',
8484
'Programming Language :: Python :: 3.8',

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
scipy >= 1
2-
tensorflow_probability >= 0.9
2+
tensorflow_probability >= 0.12.1

tensorflow_compression/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
try:
1818
import tensorflow as _tensorflow
1919
_tf_version = [int(v) for v in _tensorflow.version.VERSION.split(".")]
20-
assert _tf_version[0] == 2 and _tf_version[1] == 3
20+
assert _tf_version[0] == 2 and _tf_version[1] == 4
2121
except (ImportError, AssertionError):
2222
raise RuntimeError(
23-
"For tensorflow_compression, please install TensorFlow 2.3.")
23+
"For tensorflow_compression, please install TensorFlow 2.4.")
2424

2525
# pylint: disable=wildcard-import
2626
from tensorflow_compression.python.distributions.deep_factorized import *

0 commit comments

Comments
 (0)