Skip to content

Commit

Permalink
Check output_names attr as well.
Browse files Browse the repository at this point in the history
Signed-off-by: Jay Zhang <[email protected]>
  • Loading branch information
fatcat-z committed Dec 31, 2024
1 parent 6d1f789 commit b75fe78
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tf2onnx/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ def _rename_duplicate_keras_model_names(model):
IMPORTANT: model may be edited. Assign model.output_names to old_out_names to restore.
"""
old_out_names = None
if model.output_names and len(set(model.output_names)) != len(model.output_names):
if hasattr(model, "output_names") and model.output_names \
and len(set(model.output_names)) != len(model.output_names):
# In very rare cases, keras has a bug where it will give multiple outputs the same name
# We must edit the model or the TF trace will fail
old_out_names = model.output_names
Expand Down

0 comments on commit b75fe78

Please sign in to comment.