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

driver-action-recognition-adas-0002-decoder model conversion error #71

Closed ooe1123 closed 2 years ago

ooe1123 commented 2 years ago

OS: Ubuntu 20.04 OS Architecture: x86_64 Version of OpenVINO: 2021.4 Version of ONNX: 1.10.1 Download URL for OpenVINO IR (.bin/.xml) model: https://storage.openvinotoolkit.org/repositories/open_model_zoo/2021.4/models_bin/3/driver-action-recognition-adas-0002/driver-action-recognition-adas-0002-decoder/FP32/

I want to convert the open model zoo, driver-action-recognition-adas-0002-decoder into saved_model format.

openvino2tensorflow --model_path driver-action-recognition-adas-0002-decoder.xml --output_saved_model

But I recieve error.

ERROR: list index out of range
ERROR: model_path  : driver-action-recognition-adas-0002-decoder.xml
ERROR: weights_path: driver-action-recognition-adas-0002-decoder.bin
ERROR: layer_id    : 125
ERROR: input_layer0 layer_id=123: KerasTensor(type_spec=TensorSpec(shape=(1, 512, 16), dtype=tf.float32, name=None), name='tf.compat.v1.transpose_1/transpose:0', description="created by layer 'tf.compat.v1.transpose_1'")
ERROR: input_layer1 layer_id=124: Const(ndarray).shape  (1024, 512, 1)
array([[
  ...
  ]], dtype=float32)
ERROR: The trace log is below.
Traceback (most recent call last):
  File "/home/ooe/env1/bin/openvino2tensorflow", line 599, in convert
    kernel_size = [int(port1[2]), int(port1[3])]
IndexError: list index out of range

How can i solve the problem?

PINTO0309 commented 2 years ago

Fixes. https://github.com/PINTO0309/openvino2tensorflow/releases/tag/v1.21.1

ooe1123 commented 2 years ago

Thank you for updating. But next I get the following error.

====================================================================================
layer_type: Const
layer_id: 124
tf_layers_dict: (1024, 512, 1)
====================================================================================
ERROR: Depth of input (16) is not a multiple of input depth of filter (512) for '{{node tf.nn.conv1d/conv1d}} = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], explicit_paddings=[], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](tf.nn.conv1d/conv1d/ExpandDims, tf.nn.conv1d/conv1d/ExpandDims_1)' with input shapes: [1,1,512,16], [1,1,512,1024].
ERROR: model_path  : driver-action-recognition-adas-0002-decoder.xml
ERROR: weights_path: driver-action-recognition-adas-0002-decoder.bin
ERROR: layer_id    : 125
ERROR: input_layer0 layer_id=123: KerasTensor(type_spec=TensorSpec(shape=(1, 512, 16), dtype=tf.float32, name=None), name='tf.compat.v1.transpose_1/transpose:0', description="created by layer 'tf.compat.v1.transpose_1'")
ERROR: input_layer1 layer_id=124: Const(ndarray).shape  (1024, 512, 1)
array([[
        ...
        ]], dtype=float32)
ERROR: The trace log is below.
Traceback (most recent call last):
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/util/dispatch.py", line 206, in wrapper
    return target(*args, **kwargs)
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/util/deprecation.py", line 617, in new_func
    return func(*args, **kwargs)
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/util/deprecation.py", line 617, in new_func
    return func(*args, **kwargs)
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/ops/nn_ops.py", line 2003, in conv1d
    result = gen_nn_ops.conv2d(
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 936, in conv2d
    return conv2d_eager_fallback(
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/ops/gen_nn_ops.py", line 1019, in conv2d_eager_fallback
    _attr_T, _inputs_T = _execute.args_to_matching_eager([input, filter], ctx, [_dtypes.half, _dtypes.bfloat16, _dtypes.float32, _dtypes.float64, _dtypes.int32, ])
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/eager/execute.py", line 280, in args_to_matching_eager
    ret = [ops.convert_to_tensor(t, dtype, ctx=ctx) for t in l]
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/eager/execute.py", line 280, in <listcomp>
    ret = [ops.convert_to_tensor(t, dtype, ctx=ctx) for t in l]
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/profiler/trace.py", line 163, in wrapped
    return func(*args, **kwargs)
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/framework/ops.py", line 1566, in convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/framework/constant_op.py", line 346, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/framework/constant_op.py", line 271, in constant
    return _constant_impl(value, dtype, shape, name, verify_shape=False,
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/framework/constant_op.py", line 283, in _constant_impl
    return _constant_eager_impl(ctx, value, dtype, shape, verify_shape)
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/framework/constant_op.py", line 308, in _constant_eager_impl
    t = convert_to_eager_tensor(value, ctx, dtype)
  File "/home/ooe/env1/lib/python3.8/site-packages/tensorflow/python/framework/constant_op.py", line 106, in convert_to_eager_tensor
    return ops.EagerTensor(value, ctx.device_name, dtype)
  File "/home/ooe/env1/lib/python3.8/site-packages/keras/engine/keras_tensor.py", line 244, in __array__
    raise TypeError(
TypeError: Cannot convert a symbolic Keras input/output to a numpy array. This error may indicate that you're trying to pass a symbolic value to a NumPy call, which is not supported. Or, you may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model.
PINTO0309 commented 2 years ago

https://github.com/PINTO0309/openvino2tensorflow/tree/v1.21.1#6-7-replace-weights-or-constant-values-in-const-op-and-add-transpose-or-reshape-or-cast-just-beforeafter-the-operation-specified-by-layer_id

https://github.com/PINTO0309/PINTO_model_zoo/tree/main/154_driver-action-recognition-adas-0002-encoder https://github.com/PINTO0309/PINTO_model_zoo/tree/main/155_driver-action-recognition-adas-0002-decoder