onnx / onnx-tensorflow

Tensorflow Backend for ONNX
Other
1.29k stars 295 forks source link

ValueError: 'image_tensor:0' is not a valid scope name #426

Open mrgloom opened 5 years ago

mrgloom commented 5 years ago
pip install git+https://github.com/onnx/onnx-tensorflow.git
onnx-tf convert -t tf -i ./faceboxes_feature_extractor.onnx -o ./faceboxes_feature_extractor_with_shapes.pb
/Users/my_user/external_projects/converter/onnx_tf_env/lib/python3.6/site-packages/onnx_tf/common/__init__.py:87: UserWarning: onnx_tf.common.get_outputs_names is deprecated. It will be removed in future release. Use TensorflowGraph.get_outputs_names instead.
  warnings.warn(message)

WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
If you depend on functionality not listed there, please file an issue.

/Users/my_user/external_projects/converter/onnx_tf_env/lib/python3.6/site-packages/onnx_tf/common/__init__.py:87: UserWarning: FrontendHandler.get_outputs_names is deprecated. It will be removed in future release. Use node.outputs instead.
  warnings.warn(message)
INFO:root:Start converting onnx pb to tf pb:
Traceback (most recent call last):
  File "/Users/my_user/external_projects/converter/onnx_tf_env/bin/onnx-tf", line 11, in <module>
    load_entry_point('onnx-tf==1.2.1', 'console_scripts', 'onnx-tf')()
  File "/Users/my_user/external_projects/converter/onnx_tf_env/lib/python3.6/site-packages/onnx_tf/cli.py", line 22, in main
    return onnx_tf.converter.main(args[1:])
  File "/Users/my_user/external_projects/converter/onnx_tf_env/lib/python3.6/site-packages/onnx_tf/converter.py", line 24, in main
    convert(**{k: v for k, v in vars(args).items() if v is not None})
  File "/Users/my_user/external_projects/converter/onnx_tf_env/lib/python3.6/site-packages/onnx_tf/converter.py", line 185, in convert
    tf_rep = backend.prepare(onnx_model, **kwargs)
  File "/Users/my_user/external_projects/converter/onnx_tf_env/lib/python3.6/site-packages/onnx_tf/backend.py", line 55, in prepare
    return cls.onnx_model_to_tensorflow_rep(model, strict)
  File "/Users/my_user/external_projects/converter/onnx_tf_env/lib/python3.6/site-packages/onnx_tf/backend.py", line 75, in onnx_model_to_tensorflow_rep
    return cls._onnx_graph_to_tensorflow_rep(model.graph, opset_import, strict)
  File "/Users/my_user/external_projects/converter/onnx_tf_env/lib/python3.6/site-packages/onnx_tf/backend.py", line 112, in _onnx_graph_to_tensorflow_rep
    shape=shape)
  File "/Users/my_user/external_projects/converter/onnx_tf_env/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 2077, in placeholder
    return gen_array_ops.placeholder(dtype=dtype, shape=shape, name=name)
  File "/Users/my_user/external_projects/converter/onnx_tf_env/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 5791, in placeholder
    "Placeholder", dtype=dtype, shape=shape, name=name)
  File "/Users/my_user/external_projects/converter/onnx_tf_env/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 394, in _apply_op_helper
    with g.as_default(), ops.name_scope(name) as scope:
  File "/Users/my_user/external_projects/converter/onnx_tf_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 6088, in __enter__
    return self._name_scope.__enter__()
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/Users/my_user/external_projects/converter/onnx_tf_env/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3994, in name_scope
    raise ValueError("'%s' is not a valid scope name" % name)
ValueError: 'image_tensor:0' is not a valid scope name

What is the meaning of this error?

saeidsoheily commented 4 years ago

Valid scope names match one of the following regular expressions:

[A-Za-z0-9.][A-Za-z0-9_.\\-/]* (for scopes at the root)
[A-Za-z0-9_.\\-/]* (for other scopes)

I think one (or more) of your column name does not support the above rule! Try to rename your column name. For example, if you use pandas data frame, you can rename your column name as:

df = df.rename(columns={"old name": "new_name"}