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

xml/bin to tflite conversion error : Dimension size must be evenly divisible by 2 but is 17 #96

Closed zhenzhen1003 closed 2 years ago

zhenzhen1003 commented 2 years ago

Issue Type

Others

OS

Windows

OS architecture

x86_64

Programming Language

Python

Framework

OpenVINO, ONNX, TensorFlow

Download URL for ONNX / OpenVINO IR

robust.zip robust-onnx.zip

Convert Script

From openvino to tensorflow script : python E:/Desk/openvino2tensorflow-main/openvino2tensorflow/openvino2tensorflow.py --model_path D:/tflite/robust.xml --model_output_path D:/tflite --output_no_quant_float32_tflite --output_weight_quant_tflite

From onnx to openvino script: python mo.py --framework=onnx --data_type=FP32 --output_dir=D:\public\FP32 --model_name=robust --input=src --output=pha --scale_values=src[255,255,255] --reverse_input_channels --input_model=D:\public\robust.onnx --input_shape [1,3,1080,1920]

Description

I have succeeded converting model from onnx to xml, but getting error in tflite conversion. Onnx and xml/bin models are well working. Thanks for your read and hope you can solve my problem.

Relevant Log Output

====================================================================================
layer_type: Const
layer_id: 539
tf_layers_dict_shape: (2,)
tf_layers_dict_value: [64 64]
====================================================================================
ERROR: Dimension size must be evenly divisible by 2 but is 17
        Number of ways to split should evenly divide the split dimension for '{{node lambda_1/Split}} = Split[T=DT_FLOAT, num_split=2](lambda_1/Split/split_dim, Placeholder)' with input shapes: [], [1,17,30,128] and with computed input tensors: input[0] = <-3>.
ERROR: model_path  : D:/tflite/robust.xml
ERROR: weights_path: D:/tflite/robust.bin
ERROR: layer_id    : 540
ERROR: The trace log is below.
Traceback (most recent call last):
  File "E:\miniconda3\envs\openvino\lib\site-packages\tensorflow\python\framework\ops.py", line 1880, in _create_c_op
    c_op = pywrap_tf_session.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimension size must be evenly divisible by 2 but is 17
        Number of ways to split should evenly divide the split dimension for '{{node lambda_1/Split}} = Split[T=DT_FLOAT, num_split=2](lambda_1/Split/split_dim, Placeholder)' with input shapes: [], [1,17,30,128] and with computed input tensors: input[0] = <-3>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:/Desk/openvino2tensorflow-main/openvino2tensorflow/openvino2tensorflow.py", line 5120, in convert
    )(tf_layers_dict[get_tf_edges_from(tf_edges, layer_id, 0)])
  File "E:\miniconda3\envs\openvino\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 970, in __call__
    input_list)
  File "E:\miniconda3\envs\openvino\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 1108, in _functional_construction_call
    inputs, input_masks, args, kwargs)
  File "E:\miniconda3\envs\openvino\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 840, in _keras_tensor_symbolic_call
    return self._infer_output_signature(inputs, args, kwargs, input_masks)
  File "E:\miniconda3\envs\openvino\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 880, in _infer_output_signature
    outputs = call_fn(inputs, *args, **kwargs)
  File "E:\miniconda3\envs\openvino\lib\site-packages\tensorflow\python\keras\layers\core.py", line 919, in call
    result = self.function(inputs, **kwargs)
  File "E:/Desk/openvino2tensorflow-main/openvino2tensorflow/openvino2tensorflow.py", line 5112, in split_tensor
    return tf.raw_ops.Split(axis=axis, value=x, num_split=num_split)
  File "E:\miniconda3\envs\openvino\lib\site-packages\tensorflow\python\util\tf_export.py", line 404, in wrapper
    return f(**kwargs)
  File "E:\miniconda3\envs\openvino\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 10040, in split
    "Split", split_dim=axis, value=value, num_split=num_split, name=name)
  File "E:\miniconda3\envs\openvino\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 750, in _apply_op_helper
    attrs=attr_protos, op_def=op_def)
  File "E:\miniconda3\envs\openvino\lib\site-packages\tensorflow\python\framework\func_graph.py", line 601, in _create_op_internal
    compute_device)
  File "E:\miniconda3\envs\openvino\lib\site-packages\tensorflow\python\framework\ops.py", line 3565, in _create_op_internal
    op_def=op_def)
  File "E:\miniconda3\envs\openvino\lib\site-packages\tensorflow\python\framework\ops.py", line 2042, in __init__
    control_input_ops, op_def)
  File "E:\miniconda3\envs\openvino\lib\site-packages\tensorflow\python\framework\ops.py", line 1883, in _create_c_op
    raise ValueError(str(e))
ValueError: Dimension size must be evenly divisible by 2 but is 17
        Number of ways to split should evenly divide the split dimension for '{{node lambda_1/Split}} = Split[T=DT_FLOAT, num_split=2](lambda_1/Split/split_dim, Placeholder)' with input shapes: [], [1,17,30,128] and with computed input tensors: input[0] = <-3>.
ERROR: Please refer to 6-7 in the README first. https://github.com/PINTO0309/openvino2tensorflow

Source code for simple inference testing code

python E:/Desk/openvino2tensorflow-main/openvino2tensorflow/openvino2tensorflow.py --model_path D:/tflite/robust.xml --model_output_path D:/tflite --output_no_quant_float32_tflite --output_weight_quant_tflite

PINTO0309 commented 2 years ago

See.

ERROR: Please refer to 6-7 in the README first. https://github.com/PINTO0309/openvino2tensorflow

https://github.com/PINTO0309/PINTO_model_zoo/tree/main/242_RobustVideoMatting

zhenzhen1003 commented 2 years ago

See.

ERROR: Please refer to 6-7 in the README first. https://github.com/PINTO0309/openvino2tensorflow

https://github.com/PINTO0309/PINTO_model_zoo/tree/main/242_RobustVideoMatting

Thank you very much for replying to me in such a short time. I'm sorry I didn't notice this existing transformation. I'm sorry to trouble you.