Thank you for all the work you have done on this code. We have enjoyed using it. The training has worked fine for us, but we got the error in the title during testing. This may have to do with tensorflow versions (we are using 2.1.0). There is a thread on this same error on tensorflow/tensorflow#43534, but it is not clear if the error was resolved.
In your code it happens on this line in process_layer:
grid_x, grid_y = tf.meshgrid(grid_x, grid_y)
which then leads to this line in array_ops:
mult_fact = ones(shapes, output_dtype)
But the error only happens when process_layer is called from predict (during testing), but not when called from process_loss (during training).
Do you have any suggestions for us? I am including the full error traceback below.
Thanks.
Traceback (most recent call last):
File "/home/martin/.pycharm_helpers/pydev/pydevd.py", line 1741, in
main()
File "/home/martin/.pycharm_helpers/pydev/pydevd.py", line 1735, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/martin/.pycharm_helpers/pydev/pydevd.py", line 1135, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/martin/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/media/martin/Storage/Kaggle/ChestXray/YOLOv5/test_new.py", line 90, in
main()
File "/media/martin/Storage/Kaggle/ChestXray/YOLOv5/test_new.py", line 69, in main
model = nn.build_model(training=False)
File "/media/martin/Storage/Kaggle/ChestXray/YOLOv5/nets/nn.py", line 103, in build_model
return tf.keras.Model(inputs, predict([p5, p4, p3]))
File "/media/martin/Storage/Kaggle/ChestXray/YOLOv5/nets/nn.py", line 150, in predict
reorg_results = [process_layer(feature_map, anchors) for (feature_map, anchors) in feature_map_anchors]
File "/media/martin/Storage/Kaggle/ChestXray/YOLOv5/nets/nn.py", line 150, in
reorg_results = [process_layer(feature_map, anchors) for (feature_map, anchors) in feature_map_anchors]
File "/media/martin/Storage/Kaggle/ChestXray/YOLOv5/nets/nn.py", line 118, in process_layer
grid_x, grid_y = tf.meshgrid(grid_x, grid_y)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/array_ops.py", line 3065, in meshgrid
mult_fact = ones(shapes, output_dtype)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/array_ops.py", line 2671, in ones
output = fill(shape, constant(one, dtype=dtype), name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/array_ops.py", line 233, in fill
result = gen_array_ops.fill(dims, value, name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/gen_array_ops.py", line 3247, in fill
"Fill", dims=dims, value=value, name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/op_def_library.py", line 742, in _apply_op_helper
attrs=attr_protos, op_def=op_def)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/func_graph.py", line 595, in _create_op_internal
compute_device)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py", line 3322, in _create_op_internal
op_def=op_def)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py", line 1786, in init
control_input_ops)
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/framework/ops.py", line 1622, in _create_c_op
raise ValueError(str(e))
ValueError: Duplicate node name in graph: 'ones'