@@ -48,34 +48,40 @@ packages using the `pip` command. Refer to the
4848for more information on how to set up such a Python environment.
4949
5050The 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
5252with 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+
7572To test that the installation works correctly, you can run the unit tests with
73+ (respectively):
74+
7675``` bash
7776python -m tensorflow_compression.python.all_test
7877```
78+
79+ or
80+
81+ ``` bash
82+ python -m tensorflow_compression.all_tests
83+ ```
84+
7985Once the command finishes, you should see a message ``` OK (skipped=12) ``` or
8086similar in the last line.
8187
@@ -86,11 +92,21 @@ To use a Docker container (e.g. on Windows), be sure to install Docker
8692use a [ TensorFlow Docker image] ( https://www.tensorflow.org/install/docker ) ,
8793and then run the ` pip install ` command inside the Docker container, not on the
8894host. For instance, you can use a command line like this:
95+
8996``` bash
9097docker 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+
94110This will fetch the TensorFlow Docker image if it's not already cached, install
95111the 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
102118example, this creates an Anaconda environment with Python 3.6 and CUDA
103119libraries, and then installs TensorFlow and tensorflow-compression with GPU
104120support:
121+
105122``` bash
106123conda create --name ENV_NAME python=3.6 cudatoolkit=10.0 cudnn
107124conda activate ENV_NAME
@@ -122,20 +139,25 @@ import tensorflow_compression as tfc
122139In the
123140[ models directory] ( https://github.com/tensorflow/compression/tree/master/models ) ,
124141you'll find a python script ` tfci.py ` . Download the file and run:
142+
125143``` bash
126144python tfci.py -h
127145```
128146
129147This will give you a list of options. Briefly, the command
148+
130149``` bash
131150python tfci.py compress < model> < PNG file>
132151```
152+
133153will 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
135155pre-trained models. The command
156+
136157``` bash
137158python tfci.py decompress < TFCI file>
138159```
160+
139161will decompress a TFCI file and write a PNG file. By default, an output file
140162will be named like the input file, only with the appropriate file extension
141163appended (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
153175To see a list of options, download the file ` bls2017.py ` and run:
176+
154177``` bash
155178python bls2017.py -h
156179```
157180
158181To train the model, you need to supply it with a dataset of RGB training images.
159182They should be provided in PNG format. Training can be as simple as the
160183following command:
184+
161185``` bash
162186python bls2017.py --verbose train --train_glob=" images/*.png"
163187```
@@ -177,13 +201,15 @@ enough (or larger). This is described in more detail in:
177201If you wish, you can monitor progress with Tensorboard. To do this, create a
178202Tensorboard instance in the background before starting the training, then point
179203your web browser to [ port 6006 on your machine] ( http://localhost:6006 ) :
204+
180205``` bash
181206tensorboard --logdir=. &
182207```
183208
184209When training has finished, the Python script can be used to compress and
185210decompress images as follows. The same model checkpoint must be accessible to
186211both commands.
212+
187213``` bash
188214python bls2017.py [options] compress original.png compressed.tfci
189215python 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.
2092352 . Run ` :build_pip_pkg ` inside the cloned repo.
210236
211237For example:
238+
212239``` bash
213240sudo 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
222249flags can be passed via ` --copt ` to the ` bazel run ` command above.
223250
224251To test the created package, first install the resulting wheel file:
252+
225253``` bash
226254pip 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
231259interpreter would attempt to import ` tensorflow_compression ` packages from the
232260source tree, rather than from the installed package system directory):
261+
233262``` bash
234263pushd /tmp
235264python -m tensorflow_compression.all_tests
236265popd
237266```
238267
239268When done, you can uninstall the pip package again:
269+
240270``` bash
241271pip uninstall tensorflow-compression
242272```
0 commit comments