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 in channel split #134

Closed reflelia closed 1 year ago

reflelia commented 1 year ago

Issue Type

Bug

OS

Ubuntu

OS architecture

x86_64

Programming Language

Python

Framework

OpenVINO

Download URL for ONNX / OpenVINO IR

https://drive.google.com/file/d/1O4yY7BOuOaUKxpYpcC1GptySI81rq5pC/view?usp=share_link

Convert Script

openvino2tensorflow --model_path output-sim.xml --output_saved_model --output_pb --output_float16_quant_tflite --output_no_quant_float32_tflite --non_verbose

Description

I am trying to create a lightweight model for soft gated skip connection and convert it to tflite. reference -> https://github.com/dkurzend/Soft_Gated_Pose_Estimation_Pytorch In this process, shufflenetv2 that uses channel split was introduced, and the code for splitting channels is as follows. split = x.split(x.shape[1]//2, dim=1) split1 = split[0] split2 = split[1] Assuming that the first dimension of tensor is a channel, a separation operation was performed, but a KeyError occurred in the process of converting to tensorflow. I tried various methods of 6-7, such as transpose in the previous step of the VariadicSplit layer, but I couldn't solve it, so I leave a question.

Relevant Log Output

ERROR: '1764'
ERROR: model_path  : output-sim.xml
ERROR: weights_path: output-sim.bin
ERROR: layer_id    : 765
ERROR: The trace log is below.
Traceback (most recent call last):
  File ".../openvino2tensorflow", line 5397, in convert
    axis = int(tf_layers_dict[get_tf_edges_from(tf_edges, layer_id, 1)])
  File ".../openvino2tensorflow", line 288, in get_tf_edges_from
    before_layer_type = get_bere_layer_type(tf_edges[key][edge_index])
  File ".../openvino2tensorflow", line 257, in get_bere_layer_type
    t = type(tf_layers_dict[before_layer])
KeyError: '1764'
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

I am making a tool that is easier to handle than openvino2tensorflow. Please read the README and the issue carefully and use this tool to convert it. It appears that your model contains several 5D Transpose, so you will need to adjust the behavior of the tool slightly.

PINTO0309 commented 1 year ago

https://github.com/PINTO0309/onnx2tf/releases/tag/1.1.30

model_float32.tflite.zip

reflelia commented 1 year ago

Thank you!