Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tfjs-converter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ virtualenv --no-site-packages venv

__1. Install the TensorFlow.js pip package:__

Install the library with interactive CLI:
```bash
pip install tensorflowjs
pip install tensorflowjs[wizard]
```

__2. Run the converter script provided by the pip package:__
Expand Down
5 changes: 5 additions & 0 deletions tfjs-converter/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@

The **tensorflowjs** pip package contains libraries and tools for
[TensorFlow.js](https://js.tensorflow.org).

Use following command to install the library with support of interactive CLI:
```bash
pip install tensorflowjs[wizard]
```
7 changes: 6 additions & 1 deletion tfjs-converter/python/build-pip-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ echo
echo "Copying requirements.txt"
cp "${SCRIPTS_DIR}/requirements.txt" "${TMP_DIR}/"

# Copy requirements.txt
echo
echo "Copying extra-requirements.txt"
cp "${SCRIPTS_DIR}/extra-requirements.txt" "${TMP_DIR}/"

# Copy README.md.
echo
echo "Copying README.md"
Expand Down Expand Up @@ -239,7 +244,7 @@ for VENV_PYTHON_BIN in ${VENV_PYTHON_BINS}; do

pushd "${TEST_ON_INSTALL_DIR}" > /dev/null

pip install "${WHEEL_PATH}"
pip install "${WHEEL_PATH}[wizard]"
echo "Successfully installed ${WHEEL_PATH} for $(python --version 2>&1)."
echo

Expand Down
1 change: 1 addition & 0 deletions tfjs-converter/python/extra-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PyInquirer==1.0.3: wizard
1 change: 1 addition & 0 deletions tfjs-converter/python/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-r requirements.txt
PyInquirer==1.0.3
pylint==1.9.4; python_version < '3.0'
pylint==2.5.0; python_version > '3.0'
3 changes: 1 addition & 2 deletions tfjs-converter/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
h5py>=2.8.0
numpy>=1.16.4,<1.19.0
six>=1.12.0
tensorflow-cpu>=2.1.0,<3
tensorflow-hub==0.7.0
PyInquirer==1.0.3
tensorflow>=2.1.0,<3
23 changes: 23 additions & 0 deletions tfjs-converter/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ def _get_requirements(file):
with open(os.path.join(DIR_NAME, file), 'r') as requirements:
return requirements.readlines()

def get_extra_requires(path, add_all=True):
import re
from collections import defaultdict

with open(path) as fp:
extra_deps = defaultdict(set)
for k in fp:
if k.strip() and not k.startswith('#'):
tags = set()
if ':' in k:
k, v = k.split(':')
tags.update(vv.strip() for vv in v.split(','))
tags.add(re.split('[<=>]', k)[0])
for t in tags:
extra_deps[t].add(k)

# add tag `all` at the end
if add_all:
extra_deps['all'] = set(vv for v in extra_deps.values() for vv in v)

return extra_deps

CONSOLE_SCRIPTS = [
'tensorflowjs_converter = tensorflowjs.converters.converter:pip_main',
'tensorflowjs_wizard = tensorflowjs.converters.wizard:pip_main',
Expand Down Expand Up @@ -78,6 +100,7 @@ def _get_requirements(file):
'tensorflowjs/op_list': ['*.json']
},
install_requires=_get_requirements('requirements.txt'),
extras_require=get_extra_requires('extra-requirements.txt'),
entry_points={
'console_scripts': CONSOLE_SCRIPTS,
},
Expand Down
7 changes: 6 additions & 1 deletion tfjs-converter/python/tensorflowjs/converters/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
import tempfile
import traceback

import PyInquirer
try:
import PyInquirer
except ImportError:
sys.exit("""Please install PyInquirer using following command:
pip install PyInquirer==1.0.3""")

import h5py
import tensorflow.compat.v2 as tf
from tensorflow.core.framework import types_pb2
Expand Down