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
338 stars 39 forks source link

Gather got multiple indices #2

Closed khursani8 closed 4 years ago

khursani8 commented 4 years ago

Currently the conversion work fine so far until at Gather operation It received multiple indices based on the screenshot below which will trigger: *** TypeError: only size-1 arrays can be converted to Python scalars

Screenshot from 2020-10-24 11-12-36

I tried take a look at Netron but don't know what to do based on the graph Screenshot from 2020-10-24 11-06-45

Thanks

PINTO0309 commented 4 years ago

I'd like to use a sample model to debug it if possible. Can you provide an IR model (.bin/.xml)?

khursani8 commented 4 years ago

Sure

xml bin

PINTO0309 commented 4 years ago

I just fixed the Gather and ShapeOf conversion bug. 3b4a7a0690eb47d3a478091b17b24b51c261e308 The following link is tflite after conversion.

Model structure

model_unknown0001_float32 tflite

khursani8 commented 4 years ago

Wow, after using latest script I can convert without any error. I will take a look at the tflite model you share

If you are ok with it, can you share how your approach solving the bug? Thanks :)

PINTO0309 commented 4 years ago

I was remiss in transposing indices from NCHW to NHWC. I also changed ShapeOf from tf.keras.backend.shape to tf.shape and fixed the return dtype to int64. Also, ReduceProd and Subtract were added because they were unsupported layers.

khursani8 commented 4 years ago

Ohhh, now the code change make sense Thanks again