uber / neuropod

A uniform interface to run deep learning models from multiple frameworks
https://neuropod.ai
Apache License 2.0
936 stars 77 forks source link

create_keras_neuropod() does not work with TF 2.6 (AttributeError: 'KerasTensor' object has no attribute 'graph') #514

Closed thuningxu closed 3 years ago

thuningxu commented 3 years ago

Bug

  File "...neuropod/backends/keras/packager.py", line 85, in create_keras_neuropod
    graph_def = model.outputs[0].graph.as_graph_def()
AttributeError: 'KerasTensor' object has no attribute 'graph'

To Reproduce

Steps to reproduce the behavior:

This is test script running with Neuropod 0.3.0rc3 and TF 2.6 https://gist.github.com/thuningxu/659c8d4ed355e5c544a2bb2eb002415b

Expected behavior

Neuropod created and inference made

Environment

If this bug report is about running a specific model:

If running on GPU:

Additional context

thuningxu commented 3 years ago

I figured out this...basically I need to call tensorflow.disable_v2_behavior() before creating the Keras model. This way the model will not have KerasTensor.