patlevin / tfjs-to-tf

A TensorFlow.js Graph Model Converter
MIT License
139 stars 18 forks source link

Ensure compatibility with TF 2.2 and 2.3 #14

Closed patlevin closed 4 years ago

patlevin commented 4 years ago

Thank you for the quick fix! While testing it, I ran into some import issues.

The traceback below is common when I:

Traceback (most recent call last):
  File "/usr/local/bin/tfjs_graph_converter", line 5, in <module>
    from tfjs_graph_converter.converter import pip_main
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/__init__.py", line 4, in <module>
    from tfjs_graph_converter import api                    # noqa: F401
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/api.py", line 29, in <module>
    from tfjs_graph_converter.optimization import optimize_graph
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/optimization.py", line 19, in <module>
    from tfjs_graph_converter.util import get_input_nodes, get_output_nodes
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/util.py", line 13, in <module>
    from tensorflow_core.core.protobuf.meta_graph_pb2 import SignatureDef
ModuleNotFoundError: No module named 'tensorflow_core'

This comment says that tensorflow_core only exists in 1.15, 2.0 and 2.1 so I gave it another try:

The tensorflow_core module was imported successfully but there was an issue importing AttrValue.

Traceback (most recent call last):
  File "/usr/local/bin/tfjs_graph_converter", line 5, in <module>
    from tfjs_graph_converter.converter import pip_main
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/__init__.py", line 4, in <module>
    from tfjs_graph_converter import api                    # noqa: F401
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/api.py", line 29, in <module>
    from tfjs_graph_converter.optimization import optimize_graph
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/optimization.py", line 19, in <module>
    from tfjs_graph_converter.util import get_input_nodes, get_output_nodes
  File "/usr/local/lib/python3.6/dist-packages/tfjs_graph_converter/util.py", line 13, in <module>
    from tensorflow_core.core.protobuf.meta_graph_pb2 import SignatureDef
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/__init__.py", line 46, in <module>
    from . _api.v2 import compat
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/_api/v2/compat/__init__.py", line 39, in <module>
    from . import v1
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/_api/v2/compat/v1/__init__.py", line 32, in <module>
    from . import compat
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/_api/v2/compat/v1/compat/__init__.py", line 39, in <module>
    from . import v1
  File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/_api/v2/compat/v1/compat/v1/__init__.py", line 82, in <module>
    from tensorflow.python import AttrValue
ImportError: cannot import name 'AttrValue'
  1. I suggest that if TensorFlow.js Graph Model Converter depends on TF==2.1.0 and doesn't support TF>2.1.0, the documentation should mention it.
  2. I would like to ask if there is some other dependency needed to solve the AttrValue import error? Below is pip freeze of tensorflow/tensorflow:2.1.0-py3 and pip install tfjs-graph-converter==1.1.0:
absl-py==0.9.0
asn1crypto==0.24.0
astor==0.8.1
astunparse==1.6.3
cachetools==4.0.0
certifi==2019.11.28
chardet==3.0.4
cryptography==2.1.4
gast==0.3.3
google-auth==1.10.0
google-auth-oauthlib==0.4.1
google-pasta==0.1.8
grpcio==1.26.0
h5py==2.10.0
idna==2.6
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.2
keyring==10.6.0
keyrings.alt==3.0
Markdown==3.1.1
numpy==1.18.1
oauthlib==3.1.0
opt-einsum==3.1.0
prompt-toolkit==1.0.14
protobuf==3.11.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycrypto==2.6.1
Pygments==2.6.1
pygobject==3.26.1
PyInquirer==1.0.3
pyxdg==0.25
regex==2020.7.14
requests==2.22.0
requests-oauthlib==1.3.0
rsa==4.0
scipy==1.4.1
SecretStorage==2.3.1
six==1.13.0
tensorboard==2.3.0
tensorboard-plugin-wit==1.7.0
tensorflow==2.1.0
tensorflow-cpu==2.3.0
tensorflow-estimator==2.3.0
tensorflow-hub==0.7.0
tensorflowjs==2.0.1.post1
termcolor==1.1.0
tfjs-graph-converter==1.1.0
urllib3==1.25.7
wcwidth==0.2.5
Werkzeug==0.16.0
wrapt==1.11.2

Originally posted by @glenvorel in https://github.com/patlevin/tfjs-to-tf/issues/13#issuecomment-665586803