tensorflow-yolo-v3
tensorflow-yolo-v3 copied to clipboard
converting to Tensorflow 2.0 size issue
I am trying to remove slim and contrib from this repo to convert to Tensorflow 2.0 using the instructions here: https://www.tensorflow.org/alpha/guide/migration_guide but this line inputs = inputs + shortcuts
is giving an error: ValueError: Dimensions must be equal, but are 256 and 512 for 'detector/darknet-53/add_3' (op: 'Add') with input shapes: [?,256,52,52], [?,512,52,52].
My code for the conversion is here: https://github.com/ArifSohaib/tensorflow-yolo-v3/blob/master/yolo_v3_tf2.py
The full log is:
W0423 11:49:47.761766 9576 deprecation.py:323] From D:\Users\Sohaib\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\compat\v2_compat.py:63: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
W0423 11:49:47.792684 9576 deprecation.py:323] From D:\repos\TensorflowResearch\tf_slim_to_tf2\tensorflow-yolo-v3\yolo_v3_tf2.py:53: batch_normalization (from tensorflow.python.layers.normalization) is deprecated and will be removed in a future version.
Instructions for updating:
Use keras.layers.BatchNormalization instead.
W0423 11:49:47.813628 9576 deprecation.py:323] From D:\repos\TensorflowResearch\tf_slim_to_tf2\tensorflow-yolo-v3\yolo_v3_tf2.py:59: conv2d (from tensorflow.python.layers.convolutional) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.keras.layers.Conv2D` instead.
W0423 11:49:47.817616 9576 deprecation.py:506] From D:\Users\Sohaib\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\ops\init_ops.py:1257: calling VarianceScaling.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
Traceback (most recent call last):
File "D:\Users\Sohaib\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\framework\ops.py", line 1819, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 256 and 512 for 'detector/darknet-53/add_3' (op: 'Add') with input shapes: [?,256,52,52], [?,512,52,52].
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "convert_weights_tf2.py", line 55, in <module>
tf.app.run()
File "D:\Users\Sohaib\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\platform\app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "D:\Users\Sohaib\Anaconda3\envs\tensorflow2\lib\site-packages\absl\app.py", line 300, in run
_run_main(main, args)
File "D:\Users\Sohaib\Anaconda3\envs\tensorflow2\lib\site-packages\absl\app.py", line 251, in _run_main
sys.exit(main(argv))
File "convert_weights_tf2.py", line 41, in main
data_format=FLAGS.data_format)
File "D:\repos\TensorflowResearch\tf_slim_to_tf2\tensorflow-yolo-v3\yolo_v3_tf2.py", line 231, in yolo_v3
inputs, data_format=data_format, activation_fn=activation_fn, batch_norm_params=batch_norm_params)
File "D:\repos\TensorflowResearch\tf_slim_to_tf2\tensorflow-yolo-v3\yolo_v3_tf2.py", line 28, in darknet53
inputs, filters=128, activation_fn=activation_fn, batch_norm_params=batch_norm_params, data_format=data_format)
File "D:\repos\TensorflowResearch\tf_slim_to_tf2\tensorflow-yolo-v3\yolo_v3_tf2.py", line 70, in _darknet53_block
inputs = inputs + shortcuts
File "D:\Users\Sohaib\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\ops\math_ops.py", line 863, in binary_op_wrapper
return func(x, y, name=name)
File "D:\Users\Sohaib\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 396, in add
"Add", x=x, y=y, name=name)
File "D:\Users\Sohaib\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 800, in _apply_op_helper
op_def=op_def)
File "D:\Users\Sohaib\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "D:\Users\Sohaib\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\framework\ops.py", line 3479, in create_op
op_def=op_def)
File "D:\Users\Sohaib\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\framework\ops.py", line 1983, in __init__
control_input_ops)
File "D:\Users\Sohaib\Anaconda3\envs\tensorflow2\lib\site-packages\tensorflow\python\framework\ops.py", line 1822, in _create_c_op
raise ValueError(str(e))
ValueError: Dimensions must be equal, but are 256 and 512 for 'detector/darknet-53/add_3' (op: 'Add') with input shapes: [?,256,52,52], [?,512,52,52].
Is there any way to fix this?
Hi @ArifSohaib I took reference from this repo and made my own version of yolov3 with just the core API 1.12 (I think it will work in 1.13 too). Maybe you will find it helpful in converting to TF2.0. Link is here: https://github.com/anhminh3105/YOLOw