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

Problems converting midasnet #74

Closed fricc33 closed 2 years ago

fricc33 commented 2 years ago

1. macOS

2. intel

3. openvino_2021.4.689

4. 1.6.0

5. NA

6. NA

7. NA

8. 1.10.1

9. Generated with make_onnx_model.py from the MiDaS GitHub distribution

10. python ~/intel/openvino_2021/deployment_tools/model_optimizer/mo.py --input_model midas_v21-f6b98070.onnx --output_dir openvino-onnx --data_type FP32

11. https://github.com/isl-org/MiDaS

12. See attached zip file

13. Issue Details

openvino2tensorflow crashes with a tensor size mismatch to the input of layer Add 24.

I could trace the issue to the convolution and group convolution pad management logic (lines 626 and 1687) Somehow the padding in the group convolution causes the output tensor to shrink by 2 pixels in both dimensions.

I don't have a fix, except that commenting out the code that introduces the padding allows the model to be generated, although the model will produce erroneous results.

I attach a zip file with the MiDaS distribution with all the ingredients to reproduce the issue: Run the openvino2tensorflow_crash.sh script in the unzipped directory. You will have to populate the weights directory with midas_v21-f6b98070.pt, and modify the script with the path to your OpenVINO distribution. Thank you very much for your great code and for your help :)

PINTO0309 commented 2 years ago

The URL for the ZIP reference is broken.

PINTO0309 commented 2 years ago
PINTO0309 commented 2 years ago

Before exporting to ONNX, PyTorch cannot infer correctly.

fricc33 commented 2 years ago

Works for me here, maybe the script is not set for your image size. There is an image provided in the input folder, the result is in output, I run it like this:

python run.py -t midas_v21

also in the tf folder there is a script called run_tflite.py, which also works with the same image.

python run_tflite.py

I'm using Tensorflow 1.6.0

Let me know is you have any luck this way, thanks,