@@ -2,14 +2,20 @@ 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
- What does this library do, you ask?
6
-
7
- In a nutshell, you can use it to build your own ML models with optimized lossy
5
+ You can use this library to build your own ML models with optimized lossy
8
6
data compression built in. It's useful to find storage-efficient representations
9
7
of your data (features, examples, images, 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
11
+ Specifically, the
12
+ [ EntropyBottleneck class] ( https://tensorflow.github.io/compression/docs/entropy_bottleneck.html )
13
+ in this library simplifies the process of designing rate–distortion optimized
14
+ codes. During training, it acts like a likelihood model. Once training is
15
+ completed, it encodes floating point tensors into optimal bit sequences by
16
+ automating the design of probability tables and calling a range coder
17
+ implementation behind the scenes.
18
+
13
19
For an introduction to lossy data compression with machine learning, take a look
14
20
at @jonycgn 's
15
21
[ talk on Learned Image Compression] ( https://www.youtube.com/watch?v=x_q7cZviXkY ) .
58
64
To see a list of options, change to the directory and run:
59
65
60
66
``` bash
67
+ cd examples
61
68
python bls2017.py -h
62
69
```
63
70
64
71
To train the model, you need to supply it with a dataset of RGB training images.
65
- They should be provided in PNG format and must all have the same shape.
66
- Following training, the Python script can be used to compress and decompress
67
- images as follows:
72
+ They should be provided in PNG format. Training can be as simple as the
73
+ following command:
74
+
75
+ ``` bash
76
+ python bls2017.py -v --train_glob=images/* .png train
77
+ ```
78
+
79
+ This will use the default settings. The most important parameter is ` --lambda ` ,
80
+ which controls the trade-off between bitrate and distortion that the model will
81
+ be optimized for. The number of channels per layer is important, too: models
82
+ tuned for higher bitrates (or, equivalently, lower distortion) tend to require
83
+ transforms with a greater approximation capacity (i.e. more channels), so to
84
+ optimize performance, you want to make sure that the number of channels is large
85
+ enough (or larger). This is described in more detail in:
86
+
87
+ > "Efficient nonlinear transforms for lossy image compression"<br />
88
+ > J. Ballé<br />
89
+ > https://arxiv.org/abs/1802.00847
90
+
91
+ If you wish, you can monitor progress with Tensorboard. To do this, create a
92
+ Tensorboard instance in the background before starting the training, then point
93
+ your web browser to [ port 6006 on your machine] ( http://localhost:6006 ) :
94
+
95
+ ``` bash
96
+ tensorboard --logdir=. &
97
+ ```
98
+
99
+ When training has finished, the Python script can be used to compress and
100
+ decompress images as follows. The same model checkpoint must be accessible to
101
+ both commands.
68
102
69
103
``` bash
70
104
python bls2017.py [options] compress original.png compressed.bin
0 commit comments