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

KeyError #100

Closed hayoyo12 closed 2 years ago

hayoyo12 commented 2 years ago

Issue Type

Others

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

OpenVINO, ONNX, TensorFlow

Download URL for ONNX / OpenVINO IR

https://github.com/onnx/models/blob/main/vision/classification/mnist/model/mnist-8.onnx

I used pre-trained mnist-8.onnx model. And I converted the onnx model to OpenVINO IR. So, Now I am trying to convert the OpenVINO IR model to pb model by using openvino2tensorflow

Convert Script

# https://pypi.org/project/openvino/
source ../openvino_env/bin/activate
cd  ../openvino_env/bin
mo --input_model 'ONNX MODEL PATH' --output_dir 'SAVE DIR PATH'
deactivate

# https://github.com/PINTO0309/openvino2tensorflow
openvino2tensorflow --model_path 'XML PATH' --model_output_path ''SAVE DIR PATH'  --output_saved_model

Description

While I reset the environment, I needed to re-install onnx-tf, tensorflow-cpu, openvino, openvino2tensorflow.

(all PYPI: onnx-tf==1.9.0, tensorflow-cpu==2.6.2, openvino-dev==2022.1.0[onnx, tensorflow2], openvino2tensorflow==1.29.3 or 1.29.4, tensorflow-datasets==4.5.2)

Before, there was no problem to convert mnist-8.xml (OpenVINO IR) to tensorflow model using openvino2tensorflow. However, after the reset up environment, it gets 'KeyError' problem. I cannot find what is the 'KeyError'. And I want to know why it suddenly showed up............

It does not show only for the mnist model, other models do too :(. Firstly, I thought it showed up only after the maxpool node, but sometimes it showed up at weird layers...:( Is this issue can solve to change input shape? like 6-7 in the README? https://github.com/PINTO0309/openvino2tensorflow

I tried to search the issue, but I cannot find any related issue. I really want to understand the problem. Please help me.

Relevant Log Output

Start! -------------------------------------
> /home/worker/onnxZoo/onnx2tflite.py(42)main()
-> subprocess.call(['sh', './runTrial2.sh', name, model_name, args.topic])
(Pdb) c
Model Optimizer arguments:
Common parameters:
        - Path to the Input Model:      /home/worker/openvino_env/bin/../../onnxZoo/./models/onnx_models/classification/mnist-8.onnx
        - Path for generated IR:        /home/worker/openvino_env/bin/../../onnxZoo/ir_models
        - IR output name:       mnist-8
        - Log level:    ERROR
        - Batch:        Not specified, inherited from the model
        - Input layers:         Not specified, inherited from the model
        - Output layers:        Not specified, inherited from the model
        - Input shapes:         Not specified, inherited from the model
        - Source layout:        Not specified
        - Target layout:        Not specified
        - Layout:       Not specified
        - Mean values:  Not specified
        - Scale values:         Not specified
        - Scale factor:         Not specified
        - Precision of IR:      FP32
        - Enable fusing:        True
        - User transformations:         Not specified
        - Reverse input channels:       False
        - Enable IR generation for fixed input shape:   False
        - Use the transformations config file:  None
Advanced parameters:
        - Force the usage of legacy Frontend of Model Optimizer for model conversion into IR:   False
        - Force the usage of new Frontend of Model Optimizer for model conversion into IR:      False
OpenVINO runtime found in:      /home/worker/openvino_env/lib/python3.6/site-packages/openvino
OpenVINO runtime version:       2022.1.0-7019-cdb9bec7210-releases/2022/1
Model Optimizer version:        2022.1.0-7019-cdb9bec7210-releases/2022/1
[ SUCCESS ] Generated IR version 11 model.
[ SUCCESS ] XML file: /home/worker/onnxZoo/ir_models/mnist-8.xml
[ SUCCESS ] BIN file: /home/worker/onnxZoo/ir_models/mnist-8.bin
[ SUCCESS ] Total execution time: 0.67 seconds. 
[ SUCCESS ] Memory consumed: 82 MB. 
[ INFO ] The model was converted to IR v11, the latest model format that corresponds to the source DL framework input/output format. While IR v11 is backwards compatible with OpenVINO Inference Engine API v1.0, please use API v2.0 (as of 2022.1) to take advantage of the latest improvements in IR v11.
Find more information about API v2.0 and IR v11 at https://docs.openvino.ai
Converted to OpenVINO model
TensorFlow/Keras model building process starts ======================================
Layer structure =====================================================================
layer_type: Input
layer_id: 0
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 1), dtype=tf.float32, name='Input3'), name='Input3', description="created by layer 'Input3'")
====================================================================================
layer_type: Const
layer_id: 1
tf_layers_dict_shape: (8, 1, 5, 5)
tf_layers_dict_value: [[[[-0.00890567 -0.23690744 -0.50882167 -0.06456178  0.14181185]
   [-0.59197617 -0.47528538 -0.04934815  0.7682156   0.2634652 ]
   [-0.49176344  0.05561765  1.0189645   0.5547042  -0.4416644 ]
   [-0.15953699  0.5575415   0.59209126 -0.2947414  -0.6131798 ]
   [ 0.03849885  0.22601931 -0.2185563  -0.4771943  -0.29170495]]]

 [[[-0.03988235  0.21859981  0.49872705  0.42367178  0.04854779]
   [-0.10118173 -0.27690947 -0.00439903  0.5271722   0.40340957]
   [-0.1508379  -0.32669756 -0.15898573  0.35899585  0.37263557]
   [-0.56767666 -0.38571644 -0.17369562  0.22803734  0.332749  ]
   [-0.3807818  -0.2294796  -0.06623971 -0.01456076  0.28491208]]]

 [[[-0.02368524  0.10450535  0.2536272   0.36177155  0.6909625 ]
   [ 0.33491653  0.4169997   0.38482845  0.32941008  0.24301495]
   [-0.4690707  -0.07595889 -0.14452498 -0.1735626  -0.24677062]
   [-0.9726812  -0.71561736 -0.5382127  -0.61677986 -0.44845152]
   [-0.1989828  -0.33335587 -0.34907654 -0.14603578 -0.06359775]]]

 [[[-0.29535022 -0.3324157  -0.32799459 -0.07920787 -0.22243108]
   [-0.47676286 -0.2107162  -0.05752905  0.16373888  0.16197436]
   [-0.3917259  -0.02351397  0.12326627  0.04240002  0.22804907]
   [ 0.09454049  0.3720371   0.21938726 -0.01120029  0.18117614]
   [ 0.32751948  0.35111636  0.02906522  0.2092223   0.3407169 ]]]

 [[[-0.21453875 -0.12204789 -0.00238051 -0.22573917 -0.16116439]
   [ 0.089048    0.20497592 -0.15634817 -0.22565392 -0.5620983 ]
   [-0.06023458  0.41043168 -0.0144875  -0.4749248  -0.56405544]
   [-0.11556228  0.14209686  0.27673882  0.04259896 -0.0115494 ]
   [ 0.00969626  0.24611405  0.6256133   0.6832639   0.23607053]]]

 [[[-0.16604583 -0.33381453 -0.19119442  0.05349814  0.1415748 ]
   [ 0.1828711  -0.5480814  -0.73328096 -0.58826745 -0.38422403]
   [ 0.54028374  0.34612697 -0.2522935  -0.3465349  -0.21091518]
   [ 0.2201506   0.65891546  0.36478418  0.12937376 -0.10955952]
   [ 0.06022694  0.30285308  0.23698604  0.46915197  0.22329305]]]

 [[[ 0.09797149  0.5594847  -0.21443209 -0.45767716 -0.2118259 ]
   [ 0.3644098   0.4870626  -0.40767926 -0.42920235 -0.24754335]
   [ 0.4149288   0.3000133  -0.4578934  -0.3039155  -0.08953924]
   [ 0.27805483  0.11443112 -0.17231403 -0.35167804 -0.15202881]
   [ 0.34867072  0.18579686  0.07088676  0.13417654 -0.04618286]]]

 [[[-0.02208574 -0.13200486  0.09168619  0.23160681  0.33974218]
   [ 0.16504957  0.37648347  0.19502994  0.3151701   0.5671407 ]
   [-0.11800449  0.19598189  0.13255526  0.04779052  0.1336434 ]
   [ 0.02837657 -0.13915083 -0.1207771  -0.19753224 -0.5022868 ]
   [-0.03582329 -0.18982808 -0.4275368  -0.28474832 -0.19034995]]]]
====================================================================================
layer_type: Convolution
layer_id: 2
input_layer0: layer_id=0: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 1), dtype=tf.float32, name='Input3'), name='Input3', description="created by layer 'Input3'")
input_layer1_value: layer_id=1: [[[[-0.00890567 -0.23690744 -0.50882167 -0.06456178  0.14181185]
   [-0.59197617 -0.47528538 -0.04934815  0.7682156   0.2634652 ]
   [-0.49176344  0.05561765  1.0189645   0.5547042  -0.4416644 ]
   [-0.15953699  0.5575415   0.59209126 -0.2947414  -0.6131798 ]
   [ 0.03849885  0.22601931 -0.2185563  -0.4771943  -0.29170495]]]

 [[[-0.03988235  0.21859981  0.49872705  0.42367178  0.04854779]
   [-0.10118173 -0.27690947 -0.00439903  0.5271722   0.40340957]
   [-0.1508379  -0.32669756 -0.15898573  0.35899585  0.37263557]
   [-0.56767666 -0.38571644 -0.17369562  0.22803734  0.332749  ]
   [-0.3807818  -0.2294796  -0.06623971 -0.01456076  0.28491208]]]

 [[[-0.02368524  0.10450535  0.2536272   0.36177155  0.6909625 ]
   [ 0.33491653  0.4169997   0.38482845  0.32941008  0.24301495]
   [-0.4690707  -0.07595889 -0.14452498 -0.1735626  -0.24677062]
   [-0.9726812  -0.71561736 -0.5382127  -0.61677986 -0.44845152]
   [-0.1989828  -0.33335587 -0.34907654 -0.14603578 -0.06359775]]]

 [[[-0.29535022 -0.3324157  -0.32799459 -0.07920787 -0.22243108]
   [-0.47676286 -0.2107162  -0.05752905  0.16373888  0.16197436]
   [-0.3917259  -0.02351397  0.12326627  0.04240002  0.22804907]
   [ 0.09454049  0.3720371   0.21938726 -0.01120029  0.18117614]
   [ 0.32751948  0.35111636  0.02906522  0.2092223   0.3407169 ]]]

 [[[-0.21453875 -0.12204789 -0.00238051 -0.22573917 -0.16116439]
   [ 0.089048    0.20497592 -0.15634817 -0.22565392 -0.5620983 ]
   [-0.06023458  0.41043168 -0.0144875  -0.4749248  -0.56405544]
   [-0.11556228  0.14209686  0.27673882  0.04259896 -0.0115494 ]
   [ 0.00969626  0.24611405  0.6256133   0.6832639   0.23607053]]]

 [[[-0.16604583 -0.33381453 -0.19119442  0.05349814  0.1415748 ]
   [ 0.1828711  -0.5480814  -0.73328096 -0.58826745 -0.38422403]
   [ 0.54028374  0.34612697 -0.2522935  -0.3465349  -0.21091518]
   [ 0.2201506   0.65891546  0.36478418  0.12937376 -0.10955952]
   [ 0.06022694  0.30285308  0.23698604  0.46915197  0.22329305]]]

 [[[ 0.09797149  0.5594847  -0.21443209 -0.45767716 -0.2118259 ]
   [ 0.3644098   0.4870626  -0.40767926 -0.42920235 -0.24754335]
   [ 0.4149288   0.3000133  -0.4578934  -0.3039155  -0.08953924]
   [ 0.27805483  0.11443112 -0.17231403 -0.35167804 -0.15202881]
   [ 0.34867072  0.18579686  0.07088676  0.13417654 -0.04618286]]]

 [[[-0.02208574 -0.13200486  0.09168619  0.23160681  0.33974218]
   [ 0.16504957  0.37648347  0.19502994  0.3151701   0.5671407 ]
   [-0.11800449  0.19598189  0.13255526  0.04779052  0.1336434 ]
   [ 0.02837657 -0.13915083 -0.1207771  -0.19753224 -0.5022868 ]
   [-0.03582329 -0.18982808 -0.4275368  -0.28474832 -0.19034995]]]]
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 8), dtype=tf.float32, name=None), name='conv2d/Conv2D:0', description="created by layer 'conv2d'")
====================================================================================
layer_type: Const
layer_id: 3
tf_layers_dict_shape: (1, 8, 1, 1)
tf_layers_dict_value: [[[[-0.16153972]]

  [[-0.43383566]]

  [[ 0.09164136]]

  [[-0.01685222]]

  [[-0.06502644]]

  [[-0.13173787]]

  [[ 0.02041755]]

  [[-0.12111023]]]]
====================================================================================
layer_type: Add
layer_id: 4
input_layer0: layer_id=2: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 8), dtype=tf.float32, name=None), name='conv2d/Conv2D:0', description="created by layer 'conv2d'")
input_layer1_value: layer_id=3: [[[[-0.16153972]]

  [[-0.43383566]]

  [[ 0.09164136]]

  [[-0.01685222]]

  [[-0.06502644]]

  [[-0.13173787]]

  [[ 0.02041755]]

  [[-0.12111023]]]]
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 8), dtype=tf.float32, name=None), name='tf.math.add/Add:0', description="created by layer 'tf.math.add'")
====================================================================================
layer_type: ReLU
layer_id: 5
input_layer0: layer_id=4: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 8), dtype=tf.float32, name=None), name='tf.math.add/Add:0', description="created by layer 'tf.math.add'")
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 8), dtype=tf.float32, name=None), name='tf.nn.relu/Relu:0', description="created by layer 'tf.nn.relu'")
====================================================================================
layer_type: MaxPool
layer_id: 6
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 14, 14, 8), dtype=tf.float32, name=None), name='tf.nn.max_pool2d/MaxPool2d:0', description="created by layer 'tf.nn.max_pool2d'")
====================================================================================
layer_type: Const
layer_id: 7
tf_layers_dict_shape: (16, 8, 5, 5)
tf_layers_dict_value: [[[[-0.04855637 -0.09101364 -0.00656792 -0.12840344  0.10890023]
   [ 0.0842415  -0.16838944 -0.27132806 -0.01902547  0.06926256]
   [ 0.03975068 -0.01177552 -0.06318892 -0.15085994 -0.11244389]
   [ 0.06987237  0.00076877  0.08335788 -0.18104656 -0.11850579]
   [ 0.00338067  0.25130084  0.19361533 -0.05452343 -0.12814029]]

  [[-0.42404833 -0.27062434 -0.25944936  0.08103777  0.08797059]
   [ 0.00970472 -0.22942823 -0.0640166   0.02181791 -0.04962887]
   [ 0.16946658  0.23561102 -0.01943492 -0.13503303 -0.04280879]
   [-0.06604432  0.18613818  0.18148549 -0.14488591  0.03010414]
   [-0.13984767  0.11360442  0.10504804  0.05129308  0.05778695]]

  [[-0.15506516 -0.1339793   0.07886299  0.11649573 -0.1353052 ]
   [-0.1245205  -0.20714167 -0.14239712 -0.06145667 -0.08481514]
   [-0.1894358  -0.22062841 -0.2165672  -0.08668345  0.06490639]
   [-0.25929776 -0.10393437 -0.33296993 -0.13464974 -0.03164594]
   [ 0.02828334  0.08956132 -0.10871702 -0.18743896 -0.2238083 ]]

  ...

  [[ 0.14385527  0.01971263 -0.33717677 -0.22315596 -0.16203   ]
   [ 0.16747892  0.452033    0.26782203 -0.12484311 -0.21825446]
   [-0.14916153 -0.07604195  0.25750208  0.10287621  0.06509303]
   [-0.42091805 -0.311435   -0.03601533  0.04679396  0.11451203]
   [-0.05323717 -0.13615927 -0.26634207 -0.21306744 -0.03097531]]

  [[ 0.0543469  -0.17052768 -0.28975818 -0.04141962 -0.24664004]
   [ 0.09930239  0.19524506 -0.09816951 -0.27048928 -0.14976917]
   [-0.08557458  0.00197728  0.05408528  0.04674766 -0.16107847]
   [ 0.0232796   0.06521863  0.24592797  0.06063867  0.01283132]
   [-0.09471377 -0.10581238  0.2293426   0.20430349 -0.08989682]]

  [[-0.24754013  0.14427026  0.05195838 -0.02395635  0.10000109]
   [-0.05712178 -0.07585286 -0.05744583  0.05116294  0.086584  ]
   [ 0.06227578 -0.15449947 -0.14051668  0.02021716  0.02763801]
   [-0.10162953  0.02873158 -0.12800914 -0.22699958 -0.26877925]
   [ 0.13324091  0.07806968 -0.1234531  -0.14539756 -0.17290524]]]

 [[[ 0.07490882  0.21472266 -0.018659   -0.01161768 -0.15776567]
   [-0.03929408 -0.01434089 -0.03494421  0.13751233  0.2517472 ]
   [ 0.04373861 -0.39266604 -0.07790732  0.14997633  0.20618163]
   [-0.14093179 -0.19314402 -0.04336024  0.09022608  0.21707259]
   [-0.08400165 -0.20222805 -0.13156745 -0.09987357 -0.00171874]]

  [[-0.36749223 -0.310116   -0.4124709  -0.03239437 -0.14428607]
   [-0.08322117 -0.06490826 -0.26588988 -0.0590595  -0.10231654]
   [ 0.03635904  0.13712583 -0.03748298 -0.09332706  0.00689956]
   [ 0.02024583  0.22991383 -0.0090179  -0.17117624 -0.18040526]
   [ 0.0231686  -0.15403837 -0.01306731 -0.03320103 -0.08521425]]

  [[-0.22192258 -0.25213218 -0.18472578 -0.05622471  0.09550839]
   [-0.10368501 -0.16978149 -0.15736239  0.00182227  0.00611189]
   [-0.00599908  0.2090409   0.0638989   0.16539031  0.27662873]
   [-0.05749264  0.08701781  0.14773016  0.13645263 -0.00953868]
   [ 0.12781827 -0.01767723 -0.07789589 -0.03270945 -0.15162915]]

  ...

  [[-0.21034789 -0.08713002 -0.13168517 -0.11911161 -0.14957951]
   [ 0.09994124  0.11954653  0.2284407  -0.02858674  0.04422474]
   [ 0.15751743  0.09188351  0.2274437  -0.02180751  0.1916884 ]
   [ 0.07369085  0.04892595 -0.03920923 -0.04705292 -0.22891617]
   [-0.03614076  0.04142634 -0.07762393 -0.2611229  -0.0912008 ]]

  [[-0.1729268  -0.23834316  0.10433737 -0.0311839  -0.00399544]
   [-0.04988625  0.13645552  0.2172389  -0.05016836 -0.04197771]
   [-0.06343708 -0.06891166  0.00854106  0.24360664  0.13791727]
   [-0.01115368 -0.14292924  0.11151274  0.07313501 -0.0877879 ]
   [ 0.04911565 -0.04676543 -0.18753792 -0.16639704 -0.05079735]]

  [[-0.08475663  0.02682617 -0.08649285 -0.18647975  0.00736134]
   [-0.1363809  -0.24112748 -0.27554122 -0.10601148 -0.00082078]
   [-0.07741783  0.11260539  0.09809847 -0.03961804  0.12805608]
   [ 0.08752225  0.27042076  0.20268431  0.20752102  0.03979965]
   [-0.14928001 -0.09358218 -0.10785189 -0.19471133 -0.27080098]]]

 [[[-0.15667844 -0.02662173  0.09703121 -0.00868859 -0.01509532]
   [-0.17963722 -0.05860816 -0.07910809 -0.22067845  0.10759262]
   [-0.5088579  -0.30990946 -0.14241962  0.01391789 -0.03327215]
   [-0.06117298 -0.22797768 -0.16890411 -0.11738067 -0.09099238]
   [ 0.06495464 -0.23562115 -0.01674976  0.0292209   0.20967637]]

  [[-0.17133778  0.3138743   0.2220789  -0.23740323 -0.17076886]
   [-0.21799678  0.19849348  0.1689264   0.06156664 -0.04281147]
   [-0.26838493  0.06630816  0.29191306  0.03754885  0.167334  ]
   [-0.32384786 -0.25886795 -0.07261534 -0.19538733  0.07085316]
   [ 0.01921442 -0.0729776  -0.05503611 -0.02640322 -0.18798932]]

  [[ 0.09289582 -0.01183095 -0.18425335 -0.03038418 -0.08106336]
   [ 0.11830869  0.03395436 -0.1515959  -0.12462119  0.3598714 ]
   [ 0.3038527   0.15977822  0.11741941  0.17384164  0.21723999]
   [-0.02462257 -0.05187756 -0.02010146  0.106444   -0.1154613 ]
   [ 0.10250865 -0.06351887 -0.11650703 -0.13352986 -0.0727139 ]]

  ...

  [[-0.00464051  0.00377145 -0.18882048  0.09153606 -0.08869077]
   [-0.04644588 -0.16173416 -0.03840525 -0.04863326 -0.05188758]
   [ 0.0659112   0.02194789 -0.12757677 -0.19363862 -0.27008572]
   [ 0.09438394  0.2273089   0.09536141 -0.04072289 -0.23792697]
   [-0.14005755  0.04009477  0.21479023  0.06942731  0.30465835]]

  [[-0.06758856 -0.06033667 -0.01388032  0.22329551  0.12044027]
   [-0.06250725 -0.07773168  0.00438899 -0.06604526 -0.30084234]
   [-0.1387333  -0.22090954 -0.16132496 -0.2721668  -0.2839723 ]
   [-0.21563233 -0.07375    -0.19594881 -0.2732315  -0.26251367]
   [-0.18629584  0.22544762  0.02118117  0.00081224  0.01118591]]

  [[ 0.06582364 -0.03368504 -0.20650512 -0.20560867 -0.20746237]
   [-0.01983178  0.05050734  0.00471616 -0.05031268  0.23621652]
   [-0.06442952  0.05346967  0.26903063  0.34563366  0.20448674]
   [-0.4155077  -0.24614383 -0.10449036 -0.04480655  0.02693212]
   [ 0.08706801 -0.22441278 -0.22899637  0.0065083  -0.01807739]]]

 ...

 [[[ 0.0932951  -0.03888171 -0.2074255  -0.19547367 -0.17629768]
   [-0.11726799  0.16203699 -0.17936659 -0.22182453  0.05722651]
   [-0.07165323  0.00649594  0.20411332  0.56472117  0.19953321]
   [-0.13235675  0.290194    0.26939514  0.31379196  0.11655485]
   [ 0.1039958   0.07897383  0.26021174  0.16149318 -0.04899951]]

  [[-0.09173513 -0.05643381 -0.12425086 -0.26255158 -0.1404029 ]
   [ 0.03324513 -0.06115134  0.009861    0.236495   -0.19861805]
   [ 0.06706179  0.03209666  0.3241948   0.1504427  -0.01762817]
   [ 0.19966517 -0.17567095  0.15665084 -0.11615198 -0.17095849]
   [ 0.00340519 -0.11347205  0.03153498 -0.13322797 -0.20983107]]

  [[ 0.00815549 -0.01831565 -0.03628381 -0.1472346  -0.22431614]
   [ 0.12160256  0.0939576   0.03802406 -0.07208721 -0.3028866 ]
   [ 0.09381438  0.12930398 -0.11919525 -0.20404503 -0.1001998 ]
   [ 0.08316077 -0.2920718  -0.3246195  -0.13758802  0.07741625]
   [ 0.05675008  0.04821287 -0.16695571 -0.1683111  -0.25714663]]

  ...

  [[ 0.01044599  0.12186531  0.12172021 -0.06771471  0.04841994]
   [ 0.11444834  0.07363673  0.04923733 -0.08311908 -0.11450047]
   [-0.01275357 -0.12205453 -0.08805417  0.165906   -0.12613283]
   [ 0.15344344 -0.10184059 -0.28491405 -0.19720799  0.14513484]
   [-0.11697839 -0.15852833 -0.2358179  -0.14284603  0.08243904]]

  [[ 0.00620046  0.03099493 -0.20916966 -0.19504885 -0.03647194]
   [-0.15777381 -0.19751424 -0.32161587 -0.23731713  0.03052381]
   [-0.31225562 -0.3323539  -0.35620943  0.07318214  0.20391344]
   [-0.16811995 -0.24756414 -0.21656933  0.2908965   0.39868036]
   [-0.12157081  0.04372076  0.32752955  0.361718   -0.25216746]]

  [[ 0.10686428 -0.02736383 -0.19672269 -0.20128205 -0.25445586]
   [ 0.09724858  0.23113957  0.07206568  0.12388995  0.11896011]
   [ 0.1574829   0.03015683 -0.08820478  0.17075673  0.15868682]
   [-0.12648992 -0.20787328 -0.05014434  0.10365675 -0.14081213]
   [ 0.14581238 -0.07897355 -0.09284721 -0.03098458 -0.08686869]]]

 [[[ 0.21250397  0.06007371  0.07954877 -0.0484124  -0.02888481]
   [-0.03859134 -0.0247219  -0.11523936  0.03985869 -0.03194594]
   [-0.23824951 -0.03458088 -0.09721175  0.06683378 -0.01698507]
   [ 0.10067277 -0.10495479 -0.1388139  -0.14210717 -0.27682474]
   [ 0.31375098 -0.04183318 -0.2135565  -0.0411934  -0.12977244]]

  [[-0.06019408  0.0481153   0.08899697  0.10683768  0.23293199]
   [-0.16326867 -0.23055558 -0.15439843 -0.07647205 -0.00467722]
   [ 0.05517739 -0.07482249 -0.0250687   0.16921832  0.08354384]
   [ 0.17827296  0.05370162  0.03027512  0.14360961  0.09926435]
   [ 0.26433018  0.03360091  0.00843983  0.27800286  0.21687323]]

  [[-0.07522462  0.13471325  0.07948551  0.21037662  0.22001961]
   [-0.09812973 -0.0631008  -0.00993251 -0.18071176 -0.19588363]
   [-0.18373388 -0.10958927  0.01903403  0.14254017  0.16627477]
   [-0.03602448 -0.10233362 -0.05939797 -0.04436993  0.00576816]
   [-0.03136305 -0.13877004 -0.20925424 -0.27202556 -0.18175155]]

  ...

  [[-0.18458177 -0.08262212 -0.02669326 -0.10781821 -0.10106638]
   [ 0.05303821 -0.15798625 -0.06392887  0.0986118   0.02990116]
   [ 0.00151929  0.26066047  0.05618865 -0.2325279   0.00483533]
   [-0.17480142  0.19722985  0.06807365  0.00101786  0.06233601]
   [-0.12367811 -0.14416957 -0.14910942 -0.18400131  0.14620245]]

  [[-0.1869119  -0.17437503  0.00413144 -0.13937342 -0.05424838]
   [ 0.02287149 -0.05463291  0.01101912 -0.12462515 -0.0404655 ]
   [ 0.21297662  0.0982841   0.08395457 -0.06253014 -0.1052995 ]
   [ 0.00071332  0.29081023  0.09346265 -0.0461424   0.0210295 ]
   [ 0.07995676  0.37412438  0.05228714 -0.16835096  0.08178928]]

  [[ 0.11373837  0.15297242  0.2352121   0.18708639  0.13726968]
   [-0.1158395  -0.12688139 -0.21673328 -0.16336857 -0.22900572]
   [-0.19121961 -0.09777348 -0.04152448 -0.05148942 -0.02906441]
   [-0.09864502 -0.09059234 -0.19799444 -0.06620555 -0.11525478]
   [ 0.08191222  0.03780449 -0.24397716 -0.1562102  -0.03560324]]]

 [[[-0.26549575 -0.02601303  0.03324811 -0.1462994   0.03898627]
   [-0.31809562  0.14133175  0.21758069 -0.0233753  -0.19773053]
   [-0.1299099   0.17232671  0.17374192 -0.02669185 -0.05974301]
   [ 0.15082419  0.17710276 -0.05646876 -0.19448881 -0.11257061]
   [ 0.10200331  0.06413102  0.0223931  -0.04866609 -0.06719962]]

  [[-0.1603999   0.29884505  0.09396981 -0.05188736 -0.20511776]
   [-0.06740389  0.3760121   0.07105679 -0.08999726 -0.08873165]
   [ 0.10997026  0.31108746 -0.03982112 -0.17280616 -0.08821405]
   [ 0.08216695  0.17704299 -0.01785421 -0.26170045 -0.04061751]
   [ 0.13885964 -0.06293936 -0.23392893 -0.16718319 -0.06548524]]

  [[-0.08285007  0.01288547  0.0306893  -0.17983876  0.01556403]
   [ 0.05010106 -0.1082849  -0.18234165 -0.04937426  0.11945353]
   [-0.24500553 -0.17728892 -0.2574589  -0.12697686  0.10940859]
   [-0.19667374 -0.18263571 -0.12250763 -0.12210494 -0.1913027 ]
   [-0.3059133  -0.09151965 -0.05769869  0.00814513 -0.11922466]]

  ...

  [[-0.22862376 -0.31468934 -0.31722403 -0.09822339  0.01201572]
   [-0.08609749 -0.24985394 -0.02578314 -0.15795857  0.01019723]
   [ 0.01569889  0.04351767 -0.0143838   0.02584854  0.14021894]
   [-0.17387813 -0.00874916 -0.1115209   0.11364456 -0.06834573]
   [-0.25240716 -0.06570333 -0.11186472 -0.10149777 -0.14316894]]

  [[-0.12045607 -0.22813015 -0.24143243 -0.087703   -0.13444285]
   [ 0.00594213 -0.3077272  -0.01332572  0.03267451 -0.02363727]
   [ 0.09723945 -0.2049521   0.0427835   0.14275058  0.09182457]
   [-0.18678048  0.14678445  0.16653329  0.1315818   0.00987079]
   [-0.16178305  0.36403444  0.2036282   0.09525342 -0.00348261]]

  [[-0.1466715   0.0075295   0.06498174  0.05966807  0.06855358]
   [-0.3084825  -0.24865519  0.01457857  0.13278897  0.1972042 ]
   [-0.43237156  0.06938603 -0.06515297 -0.14105871 -0.09422451]
   [-0.10208546 -0.00592919 -0.00175133 -0.20891097 -0.09509706]
   [-0.20856659  0.05150071 -0.14073417  0.01365604 -0.11389369]]]]
====================================================================================
ERROR: '6:1'
ERROR: model_path  : ./ir_models/mnist-8.xml
ERROR: weights_path: ./ir_models/mnist-8.bin
ERROR: layer_id    : 8
ERROR: The trace log is below.
Traceback (most recent call last):
  File "/home/worker/.local/bin/openvino2tensorflow", line 719, in convert
    temp = tf_layers_dict[get_tf_edges_from(tf_edges, layer_id, 0)]
  File "/home/worker/.local/bin/openvino2tensorflow", line 260, in get_tf_edges_from
    before_layer_type = get_bere_layer_type(tf_edges[layer_id][edge_index])
  File "/home/worker/.local/bin/openvino2tensorflow", line 233, in get_bere_layer_type
    t = type(tf_layers_dict[before_layer])
KeyError: '6:1'
ERROR: Please refer to 6-7 in the README first. https://github.com/PINTO0309/openvino2tensorflow

Source code for simple inference testing code

It is same as convert script.

PINTO0309 commented 2 years ago

There is no information on your environment and no way to investigate. I will not support any use of containers other than those I provide. I am not a handyman.

docker run --gpus all -it --rm \
-v `pwd`:/home/user/workdir \
ghcr.io/pinto0309/openvino2tensorflow:latest

$INTEL_OPENVINO_DIR/deployment_tools/model_optimizer/mo.py \
--input_model mnist-8.onnx \
--data_type FP32 \
--output_dir openvino/FP32 \
--model_name mnist_8

openvino2tensorflow \
--model_path openvino/FP32/mnist_8.xml \
--output_saved_model \
--output_pb \
--output_no_quant_float32_tflite \
--non_verbose
TensorFlow/Keras model building process starts ======================================
Layer structure =====================================================================
layer_type: Input
layer_id: 0
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 1), dtype=tf.float32, name='Input3'), name='Input3', description="created by layer 'Input3'")
====================================================================================
layer_type: Const
layer_id: 1
tf_layers_dict_shape: (8, 1, 5, 5)
====================================================================================
layer_type: Convolution
layer_id: 2
input_layer0: layer_id=0: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 1), dtype=tf.float32, name='Input3'), name='Input3', description="created by layer 'Input3'")
input_layer1_shape: layer_id=1: (8, 1, 5, 5)
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 8), dtype=tf.float32, name=None), name='conv2d/Conv2D:0', description="created by layer 'conv2d'")
====================================================================================
layer_type: Const
layer_id: 3
tf_layers_dict_shape: (1, 8, 1, 1)
====================================================================================
layer_type: Add
layer_id: 4
input_layer0: layer_id=2: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 8), dtype=tf.float32, name=None), name='conv2d/Conv2D:0', description="created by layer 'conv2d'")
input_layer1_shape: layer_id=3: (1, 8, 1, 1)
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 8), dtype=tf.float32, name=None), name='tf.math.add/Add:0', description="created by layer 'tf.math.add'")
====================================================================================
layer_type: ReLU
layer_id: 5
input_layer0: layer_id=4: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 8), dtype=tf.float32, name=None), name='tf.math.add/Add:0', description="created by layer 'tf.math.add'")
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 8), dtype=tf.float32, name=None), name='tf.nn.relu/Relu:0', description="created by layer 'tf.nn.relu'")
====================================================================================
layer_type: MaxPool
layer_id: 6
input_layer0: layer_id=5: KerasTensor(type_spec=TensorSpec(shape=(1, 28, 28, 8), dtype=tf.float32, name=None), name='tf.nn.relu/Relu:0', description="created by layer 'tf.nn.relu'")
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 14, 14, 8), dtype=tf.float32, name=None), name='tf.nn.max_pool2d/MaxPool2d:0', description="created by layer 'tf.nn.max_pool2d'")
====================================================================================
layer_type: Const
layer_id: 7
tf_layers_dict_shape: (16, 8, 5, 5)
====================================================================================
layer_type: Convolution
layer_id: 8
input_layer0: layer_id=6: KerasTensor(type_spec=TensorSpec(shape=(1, 14, 14, 8), dtype=tf.float32, name=None), name='tf.nn.max_pool2d/MaxPool2d:0', description="created by layer 'tf.nn.max_pool2d'")
input_layer1_shape: layer_id=7: (16, 8, 5, 5)
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 14, 14, 16), dtype=tf.float32, name=None), name='conv2d_1/Conv2D:0', description="created by layer 'conv2d_1'")
====================================================================================
layer_type: Const
layer_id: 9
tf_layers_dict_shape: (1, 16, 1, 1)
====================================================================================
layer_type: Add
layer_id: 10
input_layer0: layer_id=8: KerasTensor(type_spec=TensorSpec(shape=(1, 14, 14, 16), dtype=tf.float32, name=None), name='conv2d_1/Conv2D:0', description="created by layer 'conv2d_1'")
input_layer1_shape: layer_id=9: (1, 16, 1, 1)
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 14, 14, 16), dtype=tf.float32, name=None), name='tf.math.add_1/Add:0', description="created by layer 'tf.math.add_1'")
====================================================================================
layer_type: ReLU
layer_id: 11
input_layer0: layer_id=10: KerasTensor(type_spec=TensorSpec(shape=(1, 14, 14, 16), dtype=tf.float32, name=None), name='tf.math.add_1/Add:0', description="created by layer 'tf.math.add_1'")
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 14, 14, 16), dtype=tf.float32, name=None), name='tf.nn.relu_1/Relu:0', description="created by layer 'tf.nn.relu_1'")
====================================================================================
layer_type: MaxPool
layer_id: 12
input_layer0: layer_id=11: KerasTensor(type_spec=TensorSpec(shape=(1, 14, 14, 16), dtype=tf.float32, name=None), name='tf.nn.relu_1/Relu:0', description="created by layer 'tf.nn.relu_1'")
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 4, 4, 16), dtype=tf.float32, name=None), name='tf.nn.max_pool2d_1/MaxPool2d:0', description="created by layer 'tf.nn.max_pool2d_1'")
====================================================================================
layer_type: Const
layer_id: 13
tf_layers_dict_shape: (2,)
====================================================================================
layer_type: Reshape
layer_id: 14
input_layer0: layer_id=12: KerasTensor(type_spec=TensorSpec(shape=(1, 4, 4, 16), dtype=tf.float32, name=None), name='tf.nn.max_pool2d_1/MaxPool2d:0', description="created by layer 'tf.nn.max_pool2d_1'")
input_layer1_shape: layer_id=13: (2,)
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 256), dtype=tf.float32, name=None), name='tf.reshape/Reshape:0', description="created by layer 'tf.reshape'")
====================================================================================
layer_type: Const
layer_id: 15
tf_layers_dict_shape: (10, 256)
====================================================================================
layer_type: MatMul
layer_id: 16
input_layer0: layer_id=14: KerasTensor(type_spec=TensorSpec(shape=(1, 256), dtype=tf.float32, name=None), name='tf.reshape/Reshape:0', description="created by layer 'tf.reshape'")
input_layer1_shape: layer_id=15: (10, 256)
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 10), dtype=tf.float32, name=None), name='tf.linalg.matmul/MatMul:0', description="created by layer 'tf.linalg.matmul'")
====================================================================================
layer_type: Const
layer_id: 17
tf_layers_dict_shape: (1, 10)
====================================================================================
layer_type: Add
layer_id: 18
input_layer0: layer_id=16: KerasTensor(type_spec=TensorSpec(shape=(1, 10), dtype=tf.float32, name=None), name='tf.linalg.matmul/MatMul:0', description="created by layer 'tf.linalg.matmul'")
input_layer1_shape: layer_id=17: (1, 10)
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 10), dtype=tf.float32, name=None), name='tf.math.add_2/Add:0', description="created by layer 'tf.math.add_2'")
====================================================================================
layer_type: Result
layer_id: 19
input_layer0: layer_id=18: KerasTensor(type_spec=TensorSpec(shape=(1, 10), dtype=tf.float32, name=None), name='tf.math.add_2/Add:0', description="created by layer 'tf.math.add_2'")
tf_layers_dict: KerasTensor(type_spec=TensorSpec(shape=(1, 10), dtype=tf.float32, name=None), name='tf.identity/Identity:0', description="created by layer 'tf.identity'")
====================================================================================
TensorFlow/Keras model building process complete!
saved_model output started ==========================================================
WARNING:absl:Function `_wrapped_model` contains input name(s) Input3 with unsupported characters which will be renamed to input3 in the SavedModel.
saved_model output complete!
.pb output started ==================================================================
.pb output complete! - saved_model/model_float32.pb
tflite Float32 convertion started ===================================================
WARNING:absl:Function `_wrapped_model` contains input name(s) Input3 with unsupported characters which will be renamed to input3 in the SavedModel.
Estimated count of arithmetic ops: 1.591 M  ops, equivalently 0.796 M  MACs
WARNING:absl:Buffer deduplication procedure will be skipped when flatbuffer library is not properly loaded
tflite Float32 convertion complete! - saved_model/model_float32.tflite
All the conversion process is finished! =============================================
hayoyo12 commented 2 years ago

no information on your environment and no way to investigat

I mean the environment is a kind of docker container. Now, I'm working on my compnay's docker environment, so I was prefer to install using pypi rather than docker. But, I will try it!

Any way, I was wondering why the model is not converter after I re-install all the packages... Thank you always. :)

PINTO0309 commented 2 years ago

This is only an expectation, but it is likely that there is just an inconsistency in the versions of packages that should be referenced because of the use of conda, etc. Please refer to the Dockerfile and faithfully maintain consistency between versions.

hamedgorji commented 1 year ago

@hayoyo12 @PINTO0309 I am facing exactly the same error. I use colab to convert openvino to tflite. Did you solve this problem?