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

The DetectionOutput layer is not yet implemented. #118

Closed HeXCZ1028 closed 2 years ago

HeXCZ1028 commented 2 years ago

Issue Type

Feature Request

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

OpenVINO, ONNX

Download URL for ONNX / OpenVINO IR

https://docs.openvino.ai/latest/omz_models_model_person_detection_0202.html

https://docs.openvino.ai/latest/omz_models_model_person_detection_0301.html

Convert Script

openvino2tensorflow --model_path /openvino_converter_data/person-detection-0202/FP32/person-detection-0202.xml --model_output_path ./ --output_onnx

Description

Hello!

I'm trying to convert models(person-detection-0202 and person-detection-0301) from openVINO-IR to ONNX but during conversion I stumble upon the following message The Loop layer is not yet implemented.

And I also find you alread implemented person-detection-0202 in your PINTO_model_zoo i an wonder why I can not convert it and get "The Loop layer is not yet implemented" message.

can you kindly suggest any workaround / improvement that can be made in my case? (model structure, conversion code and anything needed should be in the link provided)

Thanks in advance, happy to share more info if needed!

Relevant Log Output

The Loop layer is not yet implemented.

Source code for simple inference testing code

No response

HeXCZ1028 commented 2 years ago

Sorry to bother you, and I fixed it by delete detectionOut layer in .xml file. It converter well.

I'm new to the inference program, can you kindly suggest any ideas that implement post-processing programmatically and any workaround that can converter model directly from openvino to onnx ?

Thanks in advance, happy to share more info if needed!

PINTO0309 commented 2 years ago

https://github.com/PINTO0309/openvino2tensorflow/issues?q=person-detection-0202

HeXCZ1028 commented 2 years ago

Hello I want to convert person-detection-0301 to onnx and get following message

==================================================================================== ERROR: Exception encountered when calling layer "tf.math.subtract" (type TFOpLambda).

Dimensions must be equal, but are 800 and 3 for '{{node tf.math.subtract/Sub}} = Sub[T=DT_FLOAT](Placeholder, tf.math.subtract/Sub/y)' with input shapes: [1,800,1344,3], [1,3,1,1].

Call arguments received by layer "tf.math.subtract" (type TFOpLambda): • x=tf.Tensor(shape=(1, 800, 1344, 3), dtype=float32) • y=tf.Tensor(shape=(1, 3, 1, 1), dtype=float32) • name=None ERROR: model_path : /openvino_converter_data/person-detection-0301/FP16/person-detection-0301.xml ERROR: weights_path: /openvino_converter_data/person-detection-0301/FP16/person-detection-0301.bin ERROR: layer_id : 3 ERROR: input_layer0 layer_id=0: KerasTensor(type_spec=TensorSpec(shape=(1, 800, 1344, 3), dtype=tf.float32, name='image'), name='image', description="created by layer 'image'") ERROR: input_layer1 layer_id=2: tf.Tensor( [[[[103.5 ]]

[[116.25 ]]

[[123.6875]]]], shape=(1, 3, 1, 1), dtype=float32) ERROR: The trace log is below. Traceback (most recent call last): File "/usr/local/bin/openvino2tensorflow", line 5027, in convert inp = tf.math.subtract(x, y) 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/keras/layers/core/tf_op_layer.py", line 107, in handle return TFOpLambda(op)(*args, **kwargs) File "/usr/local/lib/python3.8/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler raise e.with_traceback(filtered_tb) from None ValueError: Exception encountered when calling layer "tf.math.subtract" (type TFOpLambda).

Dimensions must be equal, but are 800 and 3 for '{{node tf.math.subtract/Sub}} = Sub[T=DT_FLOAT](Placeholder, tf.math.subtract/Sub/y)' with input shapes: [1,800,1344,3], [1,3,1,1].

Call arguments received by layer "tf.math.subtract" (type TFOpLambda): • x=tf.Tensor(shape=(1, 800, 1344, 3), dtype=float32) • y=tf.Tensor(shape=(1, 3, 1, 1), dtype=float32) • name=None ERROR: Please refer to 6-7 in the README first. https://github.com/PINTO0309/openvino2tensorflow`

I followed https://github.com/PINTO0309/openvino2tensorflow#6-7-replace-weights-or-constant-values-in-const-op-and-add-transpose-or-reshape-or-cast-or-squeeze-or-unsqueeze-or-add-or-multiply-just-beforeafter-the-operation-specified-by-layer_id and find "layer 1" should be replaced the constants 图片

I create a JSON file { "format_version": 2, "layers": [ { "layer_id": "1", "type": "Const", "replace_mode": "direct", "values": [ xxxx ] } ] } and I do not know what should to fill in "values" .

can you kindly suggest any ideas ?

Thanks in advance, happy to share more info if needed!