Skip to content

AttributeError: 'FuncGraph' object has no attribute '_captures' #2172

Open
@rgaufman

Description

@rgaufman

Describe the bug
I installed tf2onnx.convert with (I also tried the stable version, same result):

pip uninstall tf2onnx
pip3 install git+https://github.com/onnx/tensorflow-onnx

When I run it, I see:

$ python3 -m tf2onnx.convert --opset 10 \
  --saved-model ssd_mobilenet_v1_coco_2018_01_28/saved_model \
  --output model.onnx
<frozen runpy>:128: RuntimeWarning: 'tf2onnx.convert' found in sys.modules after import of package 'tf2onnx', but prior to execution of 'tf2onnx.convert'; this may result in unpredictable behaviour
2023-05-10 18:55:25,257 - WARNING - '--tag' not specified for saved_model. Using --tag serve
INFO:tensorflow:Saver not created because there are no variables in the graph to restore
2023-05-10 18:55:25,739 - INFO - Saver not created because there are no variables in the graph to restore
2023-05-10 18:55:26,926 - INFO - Fingerprint not found. Saved model loading will continue.
2023-05-10 18:55:26,927 - INFO - Signatures found in model: [serving_default].
2023-05-10 18:55:26,927 - WARNING - '--signature_def' not specified, using first signature: serving_default
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/homebrew/lib/python3.11/site-packages/tf2onnx/convert.py", line 710, in <module>
    main()
  File "/opt/homebrew/lib/python3.11/site-packages/tf2onnx/convert.py", line 242, in main
    graph_def, inputs, outputs, initialized_tables, tensors_to_rename = tf_loader.from_saved_model(
                                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/tf2onnx/tf_loader.py", line 611, in from_saved_model
    _from_saved_model_v2(model_path, input_names, output_names,
  File "/opt/homebrew/lib/python3.11/site-packages/tf2onnx/tf_loader.py", line 573, in _from_saved_model_v2
    graph_captures = concrete_func.graph._captures  # pylint: disable=protected-access
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'FuncGraph' object has no attribute '_captures'. Did you mean: 'captures'?

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 18.04*): MacOS 13.3.1 on Apple Silicon M1
  • TensorFlow Version: 2.13.0rc0
  • Python version: 3.11.3

To Reproduce
I'm following the instructions here: https://ankane.org/tensorflow-ruby - I downloaded this pre-trained model: https://storage.googleapis.com/download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_coco_2018_01_28.tar.gz and trying to convert it to onnx format.

Unfortunately I am not able to install any other versions of tensorflow, only 2.13.0rc0 appears to be available:

$ pip3 install tensorflow==2.11.1
ERROR: Could not find a version that satisfies the requirement tensorflow==2.11.1 (from versions: 2.13.0rc0)
ERROR: No matching distribution found for tensorflow==2.11.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn unexpected problem or unintended behaviorpending on user responseWaiting for more information or validation from user

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions