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

fail to run tf2 example. #2129

Open
hellc3c opened this issue Mar 1, 2023 · 2 comments
Open

fail to run tf2 example. #2129

hellc3c opened this issue Mar 1, 2023 · 2 comments
Labels
bug An unexpected problem or unintended behavior pending on user response Waiting for more information or validation from user

Comments

@hellc3c
Copy link

hellc3c commented Mar 1, 2023

I want to convert a tf2 model to onnx, but it report a error.I go back to run example of convert a pretrained resnet50 model to test my usage. I run the notebook, the first way using scripts to convert running successfully, but the command line approach failed. the reported error are the same as my encountered when i convert my own model. how someone familiar with tf2onnx can help me with this.
Describe the bug

2023-03-01 14:31:35,400 - WARNING - '--tag' not specified for saved_model. Using --tag serve
2023-03-01 14:31:38,317 - INFO - Signatures found in model: [serving_default].
2023-03-01 14:31:38,318 - WARNING - '--signature_def' not specified, using first signature: serving_default
2023-03-01 14:31:38,318 - INFO - Output names: ['predictions']
Traceback (most recent call last):
File "convert.py", line 706, in
main()
File "convert.py", line 238, in main
graph_def, inputs, outputs, initialized_tables, tensors_to_rename = tf_loader.from_saved_model(
File "/home/hellc/miniconda3/envs/test/lib/python3.8/site-packages/tf2onnx/tf_loader.py", line 611, in from_saved_model
_from_saved_model_v2(model_path, input_names, output_names,
File "/home/hellc/miniconda3/envs/test/lib/python3.8/site-packages/tf2onnx/tf_loader.py", line 595, in _from_saved_model_v2
frozen_graph, initialized_tables = from_trackable(imported, concrete_func, inputs, outputs, large_model)
File "/home/hellc/miniconda3/envs/test/lib/python3.8/site-packages/tf2onnx/tf_loader.py", line 229, in from_trackable
_get_hash_table_info_from_trackable(trackable, table_info,
File "/home/hellc/miniconda3/envs/test/lib/python3.8/site-packages/tf2onnx/tf_loader.py", line 464, in _get_hash_table_info_from_trackable
for t in r.dict.values() if hasattr(r, 'dict') else []:
File "/home/hellc/miniconda3/envs/test/lib/python3.8/site-packages/tensorflow/python/training/tracking/data_structures.py", line 828, in getattribute
return super(_DictWrapper, self).getattribute(name)
TypeError: this dict descriptor does not support '_DictWrapper' objects
Urgency

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 18.04*): Unbuntu 22.04
  • TensorFlow Version: 2.7.0
  • Python version: 3.8.15
  • ONNX version (if applicable, e.g. 1.11*): 1.13.1
  • ONNXRuntime version (if applicable, e.g. 1.11*):1.14.1
  • tf2onnx: 1.13.0

To Reproduce

just run the notebook, the command line part goes wrong.
Screenshots

image
image

Additional context

@hellc3c hellc3c added the bug An unexpected problem or unintended behavior label Mar 1, 2023
@julianstrietzel
Copy link

julianstrietzel commented Mar 6, 2023

Hey @hellc3c ,
could you check which version of the package wrapt is installed?
I had the same issue using tf2onnx for model optimizing. The problem came out of no where, as the same code worked only days before. I pinned the problem down to one unfreezed dependency (I think in tensorflow).
You should be able to solve the problem by installing wrapt in version 1.14.1, while tensorflow would install the most recent version 1.15.0 by default.
pip install wrapt==1.14.1
I'd be happy to hear if i could help you.

And for the team: Maybe you could add the requirement for wrapt being < 1.15 till this is fixed from tensorflow or wrapt.

Background:

I am using tf2onnx in a Databricks environment to optimize tf models by converting them to onnx. Had the same issue with the following requirements:

opencv-python==4.7.0.68
segmentation-models==1.0.1
tensorflow==2.7.4
numpy ==1.24.2
tensorflow-addons==0.15.0
pandas==1.3.5
Pillow==9.4.0
scikit-image==0.18.3
tqdm==4.62.3
fire==0.5.0
tf2onnx==1.12.1

File "/databricks/conda/envs/mlflow-.../lib/python3.8/site-packages/tensorflow/python/training/tracking/data_structures.py", line 828, in __getattribute__ return super(_DictWrapper, self).__getattribute__(name) TypeError: this __dict__ descriptor does not support '_DictWrapper' objects

By adding the requirement wrapt==1.14.1 I was able to solve this issue

@fatcat-z
Copy link
Collaborator

fatcat-z commented Mar 7, 2023

Please try to upgrade tensorflow to 2.8.0 or above, this issue will also be fixed.

@fatcat-z fatcat-z added the pending on user response Waiting for more information or validation from user label Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior pending on user response Waiting for more information or validation from user
Projects
None yet
Development

No branches or pull requests

3 participants