PINTO0309 / openvino2tensorflow

This script converts the ONNX/OpenVINO IR model to Tensorflow's saved_model, tflite, h5, tfjs, tftrt(TensorRT), CoreML, EdgeTPU, ONNX and pb. PyTorch (NCHW) -> ONNX (NCHW) -> OpenVINO (NCHW) -> openvino2tensorflow -> Tensorflow/Keras (NHWC/NCHW) -> TFLite (NHWC/NCHW). And the conversion from .pb to saved_model and from saved_model to .pb and from .pb to .tflite and saved_model to .tflite and saved_model to onnx. Support for building environments with Docker. It is possible to directly access the host PC GUI and the camera to verify the operation. NVIDIA GPU (dGPU) support. Intel iHD GPU (iGPU) support.
MIT License
334 stars 40 forks source link

Ranks of all input tensors should match: shape[0] = [1,1] vs. shape[1] = [1] [Op:ConcatV2] name: concat #142

Closed niteshbaghel95 closed 10 months ago

niteshbaghel95 commented 10 months ago

Issue Type

Bug

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

OpenVINO, TensorFlow

Download URL for ONNX / OpenVINO IR

yolov4.xml yolov4.bin

Convert Script

openvino2tensorflow --model_path /home/nitesh/media/models/phone/saved_model.xml --output_saved_model --output_pb --output_weight_quant_tflite --output_float16_quant_tflite --output_no_quant_float32_tflite

Description

==================================================================================== ERROR: {{function_node wrappedConcatV2_N_4device/job:localhost/replica:0/task:0/device:CPU:0}} ConcatOp : Ranks of all input tensors should match: shape[0] = [1,1] vs. shape[1] = [1] [Op:ConcatV2] name: concat ERROR: model_path : /home/nitesh/media/models/phone/saved_model.xml ERROR: weights_path: /home/nitesh/media/models/phone/saved_model.bin ERROR: layer_id : 31 ERROR: input_layer0 layer_id=27: tf.Tensor([[1]], shape=(1, 1), dtype=int64) ERROR: input_layer1 layer_id=28: Const(ndarray).shape (1,) array([1]) ERROR: input_layer2 layer_id=29: Const(ndarray).shape (1,) array([1]) ERROR: input_layer3 layer_id=30: Const(ndarray).shape (1,) array([16]) ERROR: The trace log is below. Traceback (most recent call last): File "/home/nitesh/.local/bin/openvino2tensorflow", line 2377, in convert inp = tf.concat( File "/home/nitesh/.local/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler raise e.with_traceback(filtered_tb) from None File "/home/nitesh/.local/lib/python3.8/site-packages/tensorflow/python/framework/ops.py", line 6656, in raise_from_not_ok_status raise core._status_to_exception(e) from None # pylint: disable=protected-access tensorflow.python.framework.errors_impl.InvalidArgumentError: {{function_node wrappedConcatV2_N_4device/job:localhost/replica:0/task:0/device:CPU:0}} ConcatOp : Ranks of all input tensors should match: shape[0] = [1,1] vs. shape[1] = [1] [Op:ConcatV2] name: concat ERROR: Please refer to 6-7 in the README first. https://github.com/PINTO0309/openvino2tensorflow nitesh@nitesh-HP-Laptop-14s-dr1xxx:~/drp-ai_translator_release/DRP-AI_translator/drp_converter$ openvino2tensorflow --model_path /home/nitesh/media/models/phone/saved_model.xml --output_saved_model --output_pb --output_weight_quant_tflite --output_float16_quant_tflite --output_no_quant_float32_tflite

Relevant Log Output

====================================================================================
ERROR: {{function_node __wrapped__ConcatV2_N_4_device_/job:localhost/replica:0/task:0/device:CPU:0}} ConcatOp : Ranks of all input tensors should match: shape[0] = [1,1] vs. shape[1] = [1] [Op:ConcatV2] name: concat
ERROR: model_path  : /home/nitesh/media/models/phone/saved_model.xml
ERROR: weights_path: /home/nitesh/media/models/phone/saved_model.bin
ERROR: layer_id    : 31
ERROR: input_layer0 layer_id=27: tf.Tensor([[1]], shape=(1, 1), dtype=int64)
ERROR: input_layer1 layer_id=28: Const(ndarray).shape  (1,)
array([1])
ERROR: input_layer2 layer_id=29: Const(ndarray).shape  (1,)
array([1])
ERROR: input_layer3 layer_id=30: Const(ndarray).shape  (1,)
array([16])
ERROR: The trace log is below.
Traceback (most recent call last):
  File "/home/nitesh/.local/bin/openvino2tensorflow", line 2377, in convert
    inp = tf.concat(
  File "/home/nitesh/.local/lib/python3.8/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/home/nitesh/.local/lib/python3.8/site-packages/tensorflow/python/framework/ops.py", line 6656, in raise_from_not_ok_status
    raise core._status_to_exception(e) from None  # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: {{function_node __wrapped__ConcatV2_N_4_device_/job:localhost/replica:0/task:0/device:CPU:0}} ConcatOp : Ranks of all input tensors should match: shape[0] = [1,1] vs. shape[1] = [1] [Op:ConcatV2] name: concat
ERROR: Please refer to 6-7 in the README first. https://github.com/PINTO0309/openvino2tensorflow
nitesh@nitesh-HP-Laptop-14s-dr1xxx:~/drp-ai_translator_release/DRP-AI_translator/drp_converter$ openvino2tensorflow   --model_path /home/nitesh/media/models/phone/saved_model.xml   --output_saved_model   --output_pb   --output_weight_quant_tflite   --output_float16_quant_tflite   --output_no_quant_float32_tflite

Source code for simple inference testing code

nitesh@nitesh-HP-Laptop-14s-dr1xxx:~/drp-ai_translator_release/DRP-AI_translator/drp_converter$ openvino2tensorflow --model_path /home/nitesh/media/models/phone/saved_model.xml --output_saved_model --output_pb --output_weight_quant_tflite --output_float16_quant_tflite --output_no_quant_float32_tflite

PINTO0309 commented 10 months ago

I can't offer any useful comments since there is no indication of what framework the model was generated by before conversion to opnevino, but I recommend the following flow for conversion.

openvino2tensorflow is out of maintenance for a while.

  1. tensorflow -> onnx -> tensorflow / tflite
  2. onnx -> tensorflow /tflite
  3. PyTroch -> onnx -> tensorflow / tflite

https://github.com/PINTO0309/onnx2tf