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

bug in layer graph construction #133

Open Hyunseok-Kim0 opened 1 year ago

Hyunseok-Kim0 commented 1 year ago

Issue Type

Bug

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

OpenVINO, PyTorch, ONNX, TensorFlow

Download URL for ONNX / OpenVINO IR

any big enough openvino file can be target of this bug.

Convert Script

used same command from this repo.

Description

https://github.com/PINTO0309/openvino2tensorflow/blob/63fff406a2bd44258c91521add6efc8acf899808/openvino2tensorflow/openvino2tensorflow.py#L553-L584

I guess the codes in line number 559 and 579 is used to find connected layer with specific layer number and port number. The key and value from dictionary are compared in those lines. However, it looks to_layer in key is not proper way to compare the layer number since key is string. if to_layer is '23' and key is '236', it will return true. After that, some layers will not be recorded in tf_edges, so the conversion will fail. I am not sure if the key can be different shape or type, but that line caused problem in my case. After I changed that line to to_layer == key, the problem is gone.

maybe this is main cause of index list out of range error around line 586~593 like https://github.com/PINTO0309/openvino2tensorflow/issues/127#issue-1381940273 https://github.com/PINTO0309/openvino2tensorflow/blob/63fff406a2bd44258c91521add6efc8acf899808/openvino2tensorflow/openvino2tensorflow.py#L586-L593

Relevant Log Output

.

Source code for simple inference testing code

No response

PINTO0309 commented 1 year ago

This is the first time I have received such a detailed and thorough proposal. Thank you very much. I will try your suggested modifications in the next update. :)

Incidentally, openvino2tensorflow is a tool I dared to start making to compensate for the low conversion performance of onnx-tensorflow, but I made it blindly without much ML knowledge. Thus, the abundance of optimization features is proportional to the low quality of my program.

I myself recognize that the workload required of users is very high due to the abundance of features and error handling. Thus, I have recently started building a new tool that incorporates all of my 2-3 years of model conversion experience. https://github.com/PINTO0309/onnx2tf It is probably the most efficient optimization tool among the various tools I have created, and yet it has the lowest conversion error rate.

Instead of updating openvino2tensorflow a little less frequently using my private work time, I try to devote as much time as possible to updating onnx2tf. If you are interested, give it a try, I think it is easier than openvino2tensorflow.

Again, thanks.