Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google.protobuf.json_format.ParseError: Message type "tensorflow.GraphDef" has no field named "class_name" #28

Closed
msyazwan opened this issue Dec 3, 2020 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@msyazwan
Copy link

msyazwan commented Dec 3, 2020

Hi,

I'm trying to convert my tfjs model (downloaded from Teachable Machine) to tf model with .pb format.

I ran the command below and get the following error.

google.protobuf.json_format.ParseError: Message type "tensorflow.GraphDef" has no field named "class_name".

(venv) C:\Users\moham\Desktop\fastapi>tfjs_graph_converter .\tfjs_model\model.json .\tfjs2tf_model\my_model --output_format tf_saved_model
TensorFlow.js Graph Model Converter

Graph model:    .\tfjs_model\model.json
Output:         .\tfjs2tf_model\my_model
Target format:  tf_saved_model

Converting.... Traceback (most recent call last):
  File "c:\users\moham\desktop\fastapi\venv\lib\site-packages\google\protobuf\json_format.py", line 528, in _ConvertFieldValuePair
    [f.json_name for f in message_descriptor.fields]))
google.protobuf.json_format.ParseError: Message type "tensorflow.GraphDef" has no field named "class_name".
 Available Fields(except extensions): ['node', 'versions', 'version', 'library']

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\python\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\moham\Desktop\fastapi\venv\Scripts\tfjs_graph_converter.exe\__main__.py", line 7, in <module>
  File "c:\users\moham\desktop\fastapi\venv\lib\site-packages\tfjs_graph_converter\converter.py", line 214, in pip_main
    main([' '.join(sys.argv[1:])])
  File "c:\users\moham\desktop\fastapi\venv\lib\site-packages\tfjs_graph_converter\converter.py", line 225, in main
    convert(argv[0].split(' '))
  File "c:\users\moham\desktop\fastapi\venv\lib\site-packages\tfjs_graph_converter\converter.py", line 199, in convert
    compat_mode=args.compat_mode)
  File "c:\users\moham\desktop\fastapi\venv\lib\site-packages\tfjs_graph_converter\api.py", line 418, in graph_model_to_saved_model
    compat_mode)
  File "c:\users\moham\desktop\fastapi\venv\lib\site-packages\tfjs_graph_converter\api.py", line 294, in load_graph_model_and_signature
    return _convert_graph_model_to_graph(model_json, model_path, compat_mode)
  File "c:\users\moham\desktop\fastapi\venv\lib\site-packages\tfjs_graph_converter\api.py", line 263, in _convert_graph_model_to_graph
    graph_def = _convert_graph_def(topology)
  File "c:\users\moham\desktop\fastapi\venv\lib\site-packages\tfjs_graph_converter\api.py", line 130, in _convert_graph_def
    return ParseDict(message_dict, tf.compat.v1.GraphDef())
  File "c:\users\moham\desktop\fastapi\venv\lib\site-packages\google\protobuf\json_format.py", line 454, in ParseDict
    parser.ConvertMessage(js_dict, message)
  File "c:\users\moham\desktop\fastapi\venv\lib\site-packages\google\protobuf\json_format.py", line 485, in ConvertMessage
    self._ConvertFieldValuePair(value, message)
  File "c:\users\moham\desktop\fastapi\venv\lib\site-packages\google\protobuf\json_format.py", line 599, in _ConvertFieldValuePair
    raise ParseError(str(e))
google.protobuf.json_format.ParseError: Message type "tensorflow.GraphDef" has no field named "class_name".
 Available Fields(except extensions): ['node', 'versions', 'version', 'library']
@patlevin patlevin added the documentation Improvements or additions to documentation label Dec 3, 2020
@patlevin patlevin self-assigned this Dec 3, 2020
@patlevin
Copy link
Owner

patlevin commented Dec 3, 2020

Your model is a TFJS layer model.
This converter only supports TFJS graph models as input.

You can load and save TFJS layer models directly without using a converter like so:

import tensorflowjs as tfjs

model = tfjs.converters.load_keras_model('./content/')
model.save('./content/saved_model')

Since this is the second time within just a few days this came up, I'll leave this open anyway and change the error message in the converter accordingly to avoid confusion in the future.

@msyazwan
Copy link
Author

msyazwan commented Dec 3, 2020

Your model is a TFJS layer model.
This converter only supports TFJS graph models as input.

You can load and save TFJS layer models directly without using a converter like so:

import tensorflowjs as tfjs

model = tfjs.converters.load_keras_model('./content/')
model.save('./content/saved_model')

Since this is the second time within just a few days this came up, I'll leave this open anyway and change the error message in the converter accordingly to avoid confusion in the future.

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants