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

Duplicate name in graph ones #1

Open
OndrejSzekely opened this issue Feb 14, 2021 · 2 comments
Open

Duplicate name in graph ones #1

OndrejSzekely opened this issue Feb 14, 2021 · 2 comments

Comments

@OndrejSzekely
Copy link

OndrejSzekely commented Feb 14, 2021

Hello, using TF 2.1 training fails during model export. It throws an error in box_decode function in box_coder.py. See traceback:

Traceback (most recent call last):
  File "/Users/ondra/opt/anaconda3/envs/tf_21_py37/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 1619, in _create_c_op
    c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Duplicate node name in graph: 'ones'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ondra/Downloads/ScaledYOLOv4-tensorflow2-main/train.py", line 272, in <module>
    main(args)
  File "/Users/ondra/Downloads/ScaledYOLOv4-tensorflow2-main/train.py", line 266, in main
    model = Yolov4(args, training=False)
  File "/Users/ondra/Downloads/ScaledYOLOv4-tensorflow2-main/model/yolov4.py", line 21, in Yolov4
    pre_nms_decoded_boxes, pre_nms__scores = postprocess(outputs,args)
  File "/Users/ondra/Downloads/ScaledYOLOv4-tensorflow2-main/model/postprocess.py", line 22, in postprocess
    decoded_boxes = box_decode(output[..., 0:4], args, index)
  File "/Users/ondra/Downloads/ScaledYOLOv4-tensorflow2-main/model/box_coder.py", line 22, in box_decode
    grid_xy = tf.stack(tf.meshgrid(tf.range(grid_width), tf.range(grid_height)), axis=-1)
  File "/Users/ondra/opt/anaconda3/envs/tf_21_py37/lib/python3.7/site-packages/tensorflow_core/python/ops/array_ops.py", line 3065, in meshgrid
    mult_fact = ones(shapes, output_dtype)
  File "/Users/ondra/opt/anaconda3/envs/tf_21_py37/lib/python3.7/site-packages/tensorflow_core/python/ops/array_ops.py", line 2671, in ones
    output = fill(shape, constant(one, dtype=dtype), name=name)
  File "/Users/ondra/opt/anaconda3/envs/tf_21_py37/lib/python3.7/site-packages/tensorflow_core/python/ops/array_ops.py", line 233, in fill
    result = gen_array_ops.fill(dims, value, name=name)
  File "/Users/ondra/opt/anaconda3/envs/tf_21_py37/lib/python3.7/site-packages/tensorflow_core/python/ops/gen_array_ops.py", line 3247, in fill
    "Fill", dims=dims, value=value, name=name)
  File "/Users/ondra/opt/anaconda3/envs/tf_21_py37/lib/python3.7/site-packages/tensorflow_core/python/framework/op_def_library.py", line 742, in _apply_op_helper
    attrs=attr_protos, op_def=op_def)
  File "/Users/ondra/opt/anaconda3/envs/tf_21_py37/lib/python3.7/site-packages/tensorflow_core/python/framework/func_graph.py", line 595, in _create_op_internal
    compute_device)
  File "/Users/ondra/opt/anaconda3/envs/tf_21_py37/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 3322, in _create_op_internal
    op_def=op_def)
  File "/Users/ondra/opt/anaconda3/envs/tf_21_py37/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 1786, in __init__
    control_input_ops)
  File "/Users/ondra/opt/anaconda3/envs/tf_21_py37/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 1622, in _create_c_op
    raise ValueError(str(e))
ValueError: Duplicate node name in graph: 'ones'

The problem is in repeated call of tf.meshgrid function which calls ones function with same naming which works for the first YOLO head, but second time it fails because of already existing name.

Maybe in higher TF version the problem is handled on framework level. My solution is to run postprocess block in for loop in postprocess.py (for loop stats on line 18) under unique name space for each head (iteration).

@wangermeng2021
Copy link
Owner

Thanks for the feedback, My test environment is Tensorflow2.3. I will check it. It should generate new different tensor name in every loop

@OndrejSzekely
Copy link
Author

Please do that, thank you!

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

No branches or pull requests

2 participants