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

error in converting openvino to tflite #128

Closed zeckireck closed 1 year ago

zeckireck commented 1 year ago

Issue Type

Others

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

OpenVINO, TensorFlowLite

Download URL for ONNX / OpenVINO IR

openvino.zip

Convert Script

--model_path ./openvino/FP32/pphuman_new.xml --output_no_quant_float32_tflite --string_formulas_for_normalization 'data / 255'

Description

i want to convert pphuman_v2.onnx to tflite,but get the below errors, pls help me!

Relevant Log Output

ERROR: {{function_node __wrapped__GatherV2_device_/job:localhost/replica:0/task:0/device:CPU:0}} indices[0] = -1 is not in [0, 4) [Op:GatherV2]
ERROR: model_path  : ./openvino/FP32/pphuman_new.xml
ERROR: weights_path: ./openvino/FP32/pphuman_new.bin
ERROR: layer_id    : 924
ERROR: input_layer0 layer_id=921: tf.Tensor([  1 192 192   2], shape=(4,), dtype=int64)
ERROR: input_layer1 layer_id=922: Const(ndarray).shape  (1,)
array([-1])
ERROR: input_layer2 layer_id=923: Const(ndarray).shape  (1,)
array([0])
ERROR: The trace log is below.
Traceback (most recent call last):
  File "/usr/local/bin/openvino2tensorflow", line 3759, in convert
    tf_layers_dict[layer_id] = tf.gather(
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/eager/execute.py", line 54, in quick_execute
    tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
tensorflow.python.framework.errors_impl.InvalidArgumentError: {{function_node __wrapped__GatherV2_device_/job:localhost/replica:0/task:0/device:CPU:0}} indices[0] = -1 is not in [0, 4) [Op:GatherV2]
ERROR: Please refer to 6-7 in the README first. https://github.com/PINTO0309/openvino2tensorflow

Source code for simple inference testing code

No response

zeckireck commented 1 year ago

pphumanv2.zip this is pphumanv2.onnx

PINTO0309 commented 1 year ago

First, follow the instructions in the error message and then ask the question. I am very fed up with all the same questions being posted.

ERROR: Please refer to 6-7 in the README first. https://github.com/PINTO0309/openvino2tensorflow
zeckireck commented 1 year ago

sorry, i have tried to follow the 6-7 instructions , i use this weight_replacement_config_sample.zip to fix the error. but i use the converted tflite model to test the picture, its output seems wrong. i dont know why. pls help me!

zeckireck commented 1 year ago

OpenVINO output @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ elapsed time: 4.8351287841796875ms shape: (1, 2, 192, 192) array([[[[0.9663402 , 0.9663402 , 0.9663843 , ..., 0.97900313, 0.97851515, 0.97851515], [0.9663402 , 0.9663402 , 0.9663843 , ..., 0.97900313, 0.97851515, 0.97851515], [0.9661546 , 0.9661546 , 0.96603453, ..., 0.97858983, 0.9781536 , 0.9781536 ], ..., [0.9730858 , 0.9730858 , 0.9736771 , ..., 0.942102 , 0.9384238 , 0.9384238 ], [0.9740615 , 0.9740615 , 0.97480416, ..., 0.94147056, 0.93764687, 0.93764687], [0.9740615 , 0.9740615 , 0.97480416, ..., 0.94147056, 0.93764687, 0.93764687]],

    [[0.03365977, 0.03365977, 0.0336157 , ..., 0.02099684,
      0.02148488, 0.02148488],
     [0.03365977, 0.03365977, 0.0336157 , ..., 0.02099684,
      0.02148488, 0.02148488],
     [0.03384542, 0.03384542, 0.03396554, ..., 0.02141015,
      0.02184643, 0.02184643],
     ...,
     [0.02691418, 0.02691418, 0.02632285, ..., 0.05789805,
      0.06157618, 0.06157618],
     [0.02593851, 0.02593851, 0.02519586, ..., 0.05852949,
      0.0623531 , 0.0623531 ],
     [0.02593851, 0.02593851, 0.02519586, ..., 0.05852949,
      0.0623531 , 0.0623531 ]]]], dtype=float32)

tflite output @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ elapsed time: 18.19753646850586ms shape: (1, 192, 192, 2) array([[[[1., 1.], [1., 1.], [1., 1.], ..., [1., 1.], [1., 1.], [1., 1.]],

    [[1., 1.],
     [1., 1.],
     [1., 1.],
     ...,
     [1., 1.],
     [1., 1.],
     [1., 1.]],

    [[1., 1.],
     [1., 1.],
     [1., 1.],
     ...,
     [1., 1.],
     [1., 1.],
     [1., 1.]],

    ...,

    [[1., 1.],
     [1., 1.],
     [1., 1.],
     ...,
     [1., 1.],
     [1., 1.],
     [1., 1.]],

    [[1., 1.],
     [1., 1.],
     [1., 1.],
     ...,
     [1., 1.],
     [1., 1.],
     [1., 1.]],

    [[1., 1.],
     [1., 1.],
     [1., 1.],
     ...,
     [1., 1.],
     [1., 1.],
     [1., 1.]]]], dtype=float32)
zeckireck commented 1 year ago

image