Skip to content

Commit f1d9824

Browse files
author
jballe
committed
Build and documentation changes for v1.2b1.
PiperOrigin-RevId: 243877030
1 parent 540110a commit f1d9824

File tree

6 files changed

+147
-22
lines changed

6 files changed

+147
-22
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
recursive-include tensorflow_compression/ *.so

README.md

Lines changed: 70 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ This project contains data compression ops and layers for TensorFlow. The
22
project website is at
33
[tensorflow.github.io/compression](https://tensorflow.github.io/compression).
44

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
88
fraction of model performance. It can compress any floating point tensor to a
99
much smaller sequence of bits.
1010

@@ -16,45 +16,97 @@ completed, it encodes floating point tensors into optimal bit sequences by
1616
automating the design of probability tables and calling a range coder
1717
implementation behind the scenes.
1818

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
2121
[talk on Learned Image Compression](https://www.youtube.com/watch?v=x_q7cZviXkY).
2222

2323
# Quick start
2424

25-
Install TensorFlow 1.13.
25+
## Installing release 1.1 (stable)
2626

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).
2929

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)
3232
and unpack it. Then include its root directory in your `PYTHONPATH`
3333
environment variable:
3434

3535
```bash
3636
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"
3940
```
4041

4142
To make sure the library imports succeed, try running the unit tests:
4243

4344
```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
4847
```
4948

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+
5071
We recommend importing the library from your Python code as follows:
5172

5273
```python
5374
import tensorflow as tf
5475
import tensorflow_compression as tfc
5576
```
5677

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
58110

59111
The
60112
[examples directory](https://github.com/tensorflow/compression/tree/master/examples)
@@ -64,10 +116,9 @@ contains an implementation of the image compression model described in:
64116
> J. Ballé, V. Laparra, E. P. Simoncelli<br />
65117
> https://arxiv.org/abs/1611.01704
66118
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:
68120

69121
```bash
70-
cd examples
71122
python bls2017.py -h
72123
```
73124

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
theme: jekyll-theme-cayman
22
title: TensorFlow/compression
3-
show_downloads: true
3+
show_downloads: false

python/ops/range_coding_ops_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
# Copyright 2018 Google LLC. All Rights Reserved.
23
#
34
# Licensed under the Apache License, Version 2.0 (the "License");

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
numpy
2-
scipy
1+
scipy >= 1.0.0
32
tensorflow >= 1.13.0

setup.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Copyright 2019 Google LLC. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
"""Setup for pip package."""
16+
17+
from __future__ import absolute_import
18+
from __future__ import division
19+
from __future__ import print_function
20+
21+
from setuptools import find_packages
22+
from setuptools import setup
23+
from setuptools.dist import Distribution
24+
25+
__version__ = '1.2b1'
26+
27+
28+
class BinaryDistribution(Distribution):
29+
"""This class is needed in order to create OS specific wheels."""
30+
31+
def has_ext_modules(self):
32+
return True
33+
34+
35+
setup(
36+
name='tensorflow-compression',
37+
version=__version__,
38+
description=('Data compression in TensorFlow'),
39+
url='https://tensorflow.github.io/compression/',
40+
author='Google LLC',
41+
author_email='[email protected]',
42+
# Contained modules and scripts.
43+
packages=find_packages(),
44+
install_requires=[
45+
'scipy >= 1.0.0',
46+
'tensorflow >= 1.13.0',
47+
],
48+
# Add in any packaged data.
49+
include_package_data=True,
50+
zip_safe=False,
51+
distclass=BinaryDistribution,
52+
# PyPI package information.
53+
classifiers=[
54+
'Development Status :: 4 - Beta',
55+
'Intended Audience :: Developers',
56+
'Intended Audience :: Education',
57+
'Intended Audience :: Science/Research',
58+
'License :: OSI Approved :: Apache Software License',
59+
'Programming Language :: Python :: 2.7',
60+
'Programming Language :: Python :: 3.4',
61+
'Topic :: Scientific/Engineering :: Mathematics',
62+
'Topic :: Software Development :: Libraries :: Python Modules',
63+
'Topic :: Software Development :: Libraries',
64+
],
65+
project_urls={
66+
'Documentation': 'https://tensorflow.github.io/compression/docs/api_docs/python/tfc.html',
67+
'Discussion': 'https://groups.google.com/forum/#!forum/tensorflow-compression',
68+
'Source': 'https://github.com/tensorflow/compression',
69+
'Tracker': 'https://github.com/tensorflow/compression/issues',
70+
},
71+
license='Apache 2.0',
72+
keywords='compression data-compression tensorflow machine-learning python deep-learning deep-neural-networks neural-network ml',
73+
)

0 commit comments

Comments
 (0)