0

I'm trying to convert frozen graph to json file. I use this command:

tensorflowjs_converter --input_format=tf_frozen_model --output_node_names="SemanticPredictions" --saved_model_tags=serve frozen_inference_graph.pb mymodal

But it gives this error:

Traceback (most recent call last):
  File "d:\programdata\anaconda3\envs\tensorflow0\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\programdata\anaconda3\envs\tensorflow0\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\ProgramData\Anaconda3\envs\tensorflow0\Scripts\tensorflowjs_converter.exe\__main__.py", line 7, in <module>
  File "d:\programdata\anaconda3\envs\tensorflow0\lib\site-packages\tensorflowjs\converters\converter.py", line 645, in pip_main
    main([' '.join(sys.argv[1:])])
  File "d:\programdata\anaconda3\envs\tensorflow0\lib\site-packages\tensorflowjs\converters\converter.py", line 649, in main
    convert(argv[0].split(' '))
  File "d:\programdata\anaconda3\envs\tensorflow0\lib\site-packages\tensorflowjs\converters\converter.py", line 632, in convert
    strip_debug_ops=args.strip_debug_ops)
  File "d:\programdata\anaconda3\envs\tensorflow0\lib\site-packages\tensorflowjs\converters\tf_saved_model_conversion_v2.py", line 379, in convert_tf_frozen_model
    strip_debug_ops=strip_debug_ops)
  File "d:\programdata\anaconda3\envs\tensorflow0\lib\site-packages\tensorflowjs\converters\tf_saved_model_conversion_v2.py", line 133, in optimize_graph
    graph.add_to_collection('train_op', graph.get_operation_by_name(name))
  File "d:\programdata\anaconda3\envs\tensorflow0\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3633, in get_operation_by_name
    return self.as_graph_element(name, allow_tensor=False, allow_operation=True)
  File "d:\programdata\anaconda3\envs\tensorflow0\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3505, in as_graph_element
    return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
  File "d:\programdata\anaconda3\envs\tensorflow0\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3565, in _as_graph_element_locked
    "graph." % repr(name))
KeyError: "The name 'SemanticPredictions' refers to an Operation not in the graph."

I don't why it gives KeyError: "The name 'SemanticPredictions' refers to an Operation not in the graph." error.

sundowatch
  • 3,012
  • 3
  • 38
  • 66
  • hi, are you able to confirm the `SemanticPredictions` is indeed the name to a node in the graph? if not you may want to try using something like: https://github.com/lutzroeder/Netron to check the node names. – vabarbosa Mar 02 '20 at 17:15
  • I've tried netron but there are so many connection of lines. So I can't decide which one should I use – sundowatch Mar 02 '20 at 21:22
  • you can also check https://stackoverflow.com/a/48632134 which answers how to determine input/output nodes. the suggestion is to use the `summarize_graph` tool: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/graph_transforms/README.md#inspecting-graphs – vabarbosa Mar 03 '20 at 22:58

0 Answers0