monti
monti

Reputation: 794

no add_to_collection was found when using tensorflowjs_converter

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'

Upvotes: 1

Views: 1217

Answers (1)

monti
monti

Reputation: 794

Problem solved by downgrading tensorflowjs 1.0.1 to 0.6.4

Upvotes: 2

Related Questions