no add_to_collection was found when using tensorflowjs_converter

↘锁芯ラ 提交于 2019-12-24 07:38:34

问题


I am trying to convert a savedModel into TensorFlow.js web format.

I installed tensorflowjs via sudo pip3 install tensorflowjs

When running tensorflowjs_converter--input_path=full_path_to/saved_model/saved_model.pb --outputpath=full_path_to/js

I get an error saying ImportError: cannot import name 'add_to_collection'

Even if I run tensorflowjs_converter --help, I get the exact same error.

Here is the full error:

Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tensorflow_hub/tf_v1.py", line 29, in <module>
    from tensorflow.compat.v1 import *  # pylint: disable=wildcard-import
ModuleNotFoundError: No module named 'tensorflow.compat.v1'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/.local/bin/tensorflowjs_converter", line 7, in <module>
    from tensorflowjs.converters.converter import main
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tensorflowjs/__init__.py", line 21, in <module>
    from tensorflowjs import converters
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tensorflowjs/converters/__init__.py", line 24, in <module>
    from tensorflowjs.converters.tf_saved_model_conversion_v2 import convert_tf_saved_model
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tensorflowjs/converters/tf_saved_model_conversion_v2.py", line 37, in <module>
    import tensorflow_hub as hub
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tensorflow_hub/__init__.py", line 30, in <module>
    from tensorflow_hub.estimator import LatestModuleExporter
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tensorflow_hub/estimator.py", line 25, in <module>
    from tensorflow_hub import tf_utils
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tensorflow_hub/tf_utils.py", line 28, in <module>
    from tensorflow_hub import tf_v1
  File "/home/ubuntu/.local/lib/python3.6/site-packages/tensorflow_hub/tf_v1.py", line 32, in <module>
    from tensorflow import add_to_collection
ImportError: cannot import name 'add_to_collection'

回答1:


Problem solved by downgrading tensorflowjs 1.0.1 to 0.6.4



来源:https://stackoverflow.com/questions/56003095/no-add-to-collection-was-found-when-using-tensorflowjs-converter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!