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

Help convert person-detection-0302 from openvino to onnx #123

Closed HeXCZ1028 closed 1 year ago

HeXCZ1028 commented 1 year ago

Issue Type

Feature Request

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

OpenVINO, ONNX

Download URL for ONNX / OpenVINO IR

https://storage.openvinotoolkit.org/repositories/open_model_zoo/2022.1/models_bin/3/person-detection-0302/FP32/person-detection-0302.xml

https://storage.openvinotoolkit.org/repositories/open_model_zoo/2022.1/models_bin/3/person-detection-0302/FP32/person-detection-0302.bin

Convert Script

H=544 W=920 MODEL=person-detection-0302

sudo openvino2tensorflow --model_path ${MODEL}.xml --output_saved_model --output_pb --output_no_quant_float32_tflite --output_dynamic_range_quant_tflite --output_weight_quant_tflite --output_float16_quant_tflite --output_integer_quant_tflite --string_formulas_for_normalization 'data / 255.0' --output_tfjs --output_coreml

Description

I want to convert person-detection-0302 from openvino model to onnx, but I get error message and I truely do not know how to fit these error by reading 6-7 part in the README.

I have read 6-7 part in the README several times. But I'm still confused about how to do fix then. There are many error type information. For example , "dims must represent a vector, got shape [160,1] [Op:Fill]", "ValueError: Dimensions must be equal, but are 80 and 3", etc.

Can you elaborate on how you can fininsh replace.json file step by step for a new model?

It is better to teach a man to fish than to give him a fish

Thank you

Relevant Log Output

input_layer1_shape: layer_id=419: Const(ndarray).shape (2,)
input_layer1_value: layer_id=419: [160   1]
tf_layers_dict_shape: (160, 1)
tf_layers_dict: [[   0]
 [   8]
 [  16]
 [  24]
 [  32]
 [  40]
 [  48]
 [  56]
 [  64]
 [  72]
 [  80]
 [  88]
 [  96]
 [ 104]
 [ 112]
 [ 120]
 [ 128]
 [ 136]
 [ 144]
 [ 152]
 [ 160]
 [ 168]
 [ 176]
 [ 184]
 [ 192]
 [ 200]
 [ 208]
 [ 216]
 [ 224]
 [ 232]
 [ 240]
 [ 248]
 [ 256]
 [ 264]
 [ 272]
 [ 280]
 [ 288]
 [ 296]
 [ 304]
 [ 312]
 [ 320]
 [ 328]
 [ 336]
 [ 344]
 [ 352]
 [ 360]
 [ 368]
 [ 376]
 [ 384]
 [ 392]
 [ 400]
 [ 408]
 [ 416]
 [ 424]
 [ 432]
 [ 440]
 [ 448]
 [ 456]
 [ 464]
 [ 472]
 [ 480]
 [ 488]
 [ 496]
 [ 504]
 [ 512]
 [ 520]
 [ 528]
 [ 536]
 [ 544]
 [ 552]
 [ 560]
 [ 568]
 [ 576]
 [ 584]
 [ 592]
 [ 600]
 [ 608]
 [ 616]
 [ 624]
 [ 632]
 [ 640]
 [ 648]
 [ 656]
 [ 664]
 [ 672]
 [ 680]
 [ 688]
 [ 696]
 [ 704]
 [ 712]
 [ 720]
 [ 728]
 [ 736]
 [ 744]
 [ 752]
 [ 760]
 [ 768]
 [ 776]
 [ 784]
 [ 792]
 [ 800]
 [ 808]
 [ 816]
 [ 824]
 [ 832]
 [ 840]
 [ 848]
 [ 856]
 [ 864]
 [ 872]
 [ 880]
 [ 888]
 [ 896]
 [ 904]
 [ 912]
 [ 920]
 [ 928]
 [ 936]
 [ 944]
 [ 952]
 [ 960]
 [ 968]
 [ 976]
 [ 984]
 [ 992]
 [1000]
 [1008]
 [1016]
 [1024]
 [1032]
 [1040]
 [1048]
 [1056]
 [1064]
 [1072]
 [1080]
 [1088]
 [1096]
 [1104]
 [1112]
 [1120]
 [1128]
 [1136]
 [1144]
 [1152]
 [1160]
 [1168]
 [1176]
 [1184]
 [1192]
 [1200]
 [1208]
 [1216]
 [1224]
 [1232]
 [1240]
 [1248]
 [1256]
 [1264]
 [1272]]
====================================================================================
ERROR: dims must represent a vector, got shape [160,1] [Op:Fill]
ERROR: model_path  : person-detection-0302.xml
ERROR: weights_path: person-detection-0302.bin
ERROR: layer_id    : 421
ERROR: input_layer0 layer_id=414: tf.Tensor([160   2], shape=(2,), dtype=int64)
ERROR: input_layer1 layer_id=420: tf.Tensor(
[[   0]
 [   8]
 [  16]
 [  24]
 [  32]
 [  40]
 [  48]
 [  56]
 [  64]
 [  72]
 [  80]
 [  88]
 [  96]
 [ 104]
 [ 112]
 [ 120]
 [ 128]
 [ 136]
 [ 144]
 [ 152]
 [ 160]
 [ 168]
 [ 176]
 [ 184]
 [ 192]
 [ 200]
 [ 208]
 [ 216]
 [ 224]
 [ 232]
 [ 240]
 [ 248]
 [ 256]
 [ 264]
 [ 272]
 [ 280]
 [ 288]
 [ 296]
 [ 304]
 [ 312]
 [ 320]
 [ 328]
 [ 336]
 [ 344]
 [ 352]
 [ 360]
 [ 368]
 [ 376]
 [ 384]
 [ 392]
 [ 400]
 [ 408]
 [ 416]
 [ 424]
 [ 432]
 [ 440]
 [ 448]
 [ 456]
 [ 464]
 [ 472]
 [ 480]
 [ 488]
 [ 496]
 [ 504]
 [ 512]
 [ 520]
 [ 528]
 [ 536]
 [ 544]
 [ 552]
 [ 560]
 [ 568]
 [ 576]
 [ 584]
 [ 592]
 [ 600]
 [ 608]
 [ 616]
 [ 624]
 [ 632]
 [ 640]
 [ 648]
 [ 656]
 [ 664]
 [ 672]
 [ 680]
 [ 688]
 [ 696]
 [ 704]
 [ 712]
 [ 720]
 [ 728]
 [ 736]
 [ 744]
 [ 752]
 [ 760]
 [ 768]
 [ 776]
 [ 784]
 [ 792]
 [ 800]
 [ 808]
 [ 816]
 [ 824]
 [ 832]
 [ 840]
 [ 848]
 [ 856]
 [ 864]
 [ 872]
 [ 880]
 [ 888]
 [ 896]
 [ 904]
 [ 912]
 [ 920]
 [ 928]
 [ 936]
 [ 944]
 [ 952]
 [ 960]
 [ 968]
 [ 976]
 [ 984]
 [ 992]
 [1000]
 [1008]
 [1016]
 [1024]
 [1032]
 [1040]
 [1048]
 [1056]
 [1064]
 [1072]
 [1080]
 [1088]
 [1096]
 [1104]
 [1112]
 [1120]
 [1128]
 [1136]
 [1144]
 [1152]
 [1160]
 [1168]
 [1176]
 [1184]
 [1192]
 [1200]
 [1208]
 [1216]
 [1224]
 [1232]
 [1240]
 [1248]
 [1256]
 [1264]
 [1272]], shape=(160, 1), dtype=int64)
ERROR: The trace log is below.
Traceback (most recent call last):
  File "/usr/local/bin/openvino2tensorflow", line 5310, in convert
    tf.ones(
  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/framework/ops.py", line 7164, in raise_from_not_ok_status
    raise core._status_to_exception(e) from None  # pylint: disable=protected-access
tensorflow.python.framework.errors_impl.InvalidArgumentError: dims must represent a vector, got shape [160,1] [Op:Fill]
ERROR: Please refer to 6-7 in the README first. https://github.com/PINTO0309/openvino2tensorflow

Source code for simple inference testing code

No response

PINTO0309 commented 1 year ago

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