@@ -2,9 +2,9 @@ This project contains data compression ops and layers for TensorFlow. The
2
2
project website is at
3
3
[ tensorflow.github.io/compression] ( https://tensorflow.github.io/compression ) .
4
4
5
- You can use this library to build your own ML models with optimized lossy data
6
- compression built in. It's useful to find storage-efficient representations of
7
- your data (features, examples, images, etc.) while only sacrificing a tiny
5
+ You can use this library to build your own ML models with end-to-end optimized
6
+ data compression built in. It's useful to find storage-efficient representations
7
+ of your data (features, examples, images, etc.) while only sacrificing a tiny
8
8
fraction of model performance. It can compress any floating point tensor to a
9
9
much smaller sequence of bits.
10
10
@@ -16,45 +16,97 @@ completed, it encodes floating point tensors into optimal bit sequences by
16
16
automating the design of probability tables and calling a range coder
17
17
implementation behind the scenes.
18
18
19
- For an introduction to lossy data compression with machine learning, take a look
20
- at @jonycgn 's
19
+ For an introduction to lossy image compression with machine learning, take a
20
+ look at @jonycgn 's
21
21
[ talk on Learned Image Compression] ( https://www.youtube.com/watch?v=x_q7cZviXkY ) .
22
22
23
23
# Quick start
24
24
25
- Install TensorFlow 1.13.
25
+ ## Installing release 1.1 (stable)
26
26
27
- ** Please note ** : We are currently transitioning to providing pip packages. At
28
- this point, the master will not work. Make sure to use the released version .
27
+ Install TensorFlow 1.13 using one of the methods described in the
28
+ [ TensorFlow installation instructions ] ( https://www.tensorflow.org/install ) .
29
29
30
- Download the
31
- [ ZIP file for release v1.1] ( https://github.com/tensorflow/compression/releases/tag/v1.1 )
30
+ Download the ZIP file for
31
+ [ release v1.1] ( https://github.com/tensorflow/compression/releases/tag/v1.1 )
32
32
and unpack it. Then include its root directory in your ` PYTHONPATH `
33
33
environment variable:
34
34
35
35
``` bash
36
36
cd < target directory>
37
- git clone https://github.com/tensorflow/compression.git tensorflow_compression
38
- export PYTHONPATH=" $PWD /tensorflow_compression:$PYTHONPATH "
37
+ wget https://github.com/tensorflow/compression/archive/v1.1.zip
38
+ unzip v1.1.zip
39
+ export PYTHONPATH=" $PWD /compression-1.1:$PYTHONPATH "
39
40
```
40
41
41
42
To make sure the library imports succeed, try running the unit tests:
42
43
43
44
``` bash
44
- cd tensorflow_compression
45
- for i in tensorflow_compression/python/* /* _test.py; do
46
- python $i
47
- done
45
+ cd compression-1.1
46
+ for i in tensorflow_compression/python/* /* _test.py; do python $i ; done
48
47
```
49
48
49
+ ## Installing release 1.2b1 (beta)
50
+
51
+ Set up an environment in which you can install precompiled binary Python
52
+ packages using the ` pip ` command. Refer to the
53
+ [ TensorFlow installation instructions] ( https://www.tensorflow.org/install/pip )
54
+ for more information on how to set up such a Python environment.
55
+
56
+ Run the following command to install the binary PIP package:
57
+
58
+ ``` bash
59
+ pip install tensorflow-compression
60
+ ```
61
+
62
+ *** Note: for this beta release, we only support Python 2.7 and 3.4 versions on
63
+ Linux platforms. We are working on Darwin (Mac) binaries as well. For the time
64
+ being, if you need to run the beta release on Mac, we suggest to use Docker
65
+ Desktop for Mac, and run the above command inside a container based on the
66
+ [ TensorFlow docker image] ( https://www.tensorflow.org/install/docker ) for
67
+ Python 2.7.***
68
+
69
+ ## Using the library
70
+
50
71
We recommend importing the library from your Python code as follows:
51
72
52
73
``` python
53
74
import tensorflow as tf
54
75
import tensorflow_compression as tfc
55
76
```
56
77
57
- ## Example model
78
+ ## Using a pre-trained model to compress an image
79
+
80
+ *** Note: you need to have a release >1.1 installed for pre-trained model
81
+ support.***
82
+
83
+ In the
84
+ [ examples directory] ( https://github.com/tensorflow/compression/tree/master/examples ) ,
85
+ you'll find a python script ` tfci.py ` . Download the file and run:
86
+
87
+ ``` bash
88
+ python tfci.py -h
89
+ ```
90
+
91
+ This will give you a list of options. Briefly, the command
92
+
93
+ ``` bash
94
+ python tfci.py compress < model> < PNG file>
95
+ ```
96
+
97
+ will compress an image using a pre-trained model and write a file ending in
98
+ ` .tfci ` . Execute ` python tfci.py models ` to give you a list of supported
99
+ pre-trained models. The command
100
+
101
+ ``` bash
102
+ python tfci.py decompress < TFCI file>
103
+ ```
104
+
105
+ will decompress a TFCI file and write a PNG file. By default, an output file
106
+ will be named like the input file, only with the appropriate file extension
107
+ appended (any existing extensions will not be removed).
108
+
109
+ ## Training your own model
58
110
59
111
The
60
112
[ examples directory] ( https://github.com/tensorflow/compression/tree/master/examples )
@@ -64,10 +116,9 @@ contains an implementation of the image compression model described in:
64
116
> J. Ballé, V. Laparra, E. P. Simoncelli<br />
65
117
> https://arxiv.org/abs/1611.01704
66
118
67
- To see a list of options, change to the directory and run:
119
+ To see a list of options, download the file ` bls2017.py ` and run:
68
120
69
121
``` bash
70
- cd examples
71
122
python bls2017.py -h
72
123
```
73
124
0 commit comments