onnx / tensorflow-onnx

Convert TensorFlow, Keras, Tensorflow.js and Tflite models to ONNX
Apache License 2.0
2.33k stars 432 forks source link

Segmentation fault core dump when converting tflite model to onnx #1746

Open Jerryzhangzhao opened 3 years ago

Jerryzhangzhao commented 3 years ago

Describe the bug I am converting a tflite model to onnx with tf2onnx, but it causecore dump. The model is pose_detection.tflite, model link

System information

I've also tried on windows10, with anaconda env, the same error.

To Reproduce with the command line: python -m tf2onnx.convert --tflite ./pose_detection.tflite --output pose_detection.onnx

Screenshots If applicable, add screenshots to help explain your problem. image The chinese character in above image is "Segmentation fault (core dumped)"

Additional context The model is about human detection. model link

TomWildenhain-Microsoft commented 3 years ago

The model has the "densify" op which I haven't seen before. Seems to crash while trying to extract tensor data from tflite interpreter.

image

Jerryzhangzhao commented 3 years ago

@TomWildenhain-Microsoft Thanks. I've convert the tflite model to saved_model format with tflite2tensorflow which support Densify op, and then convert the .pb file to onnx format. Is there a plan to support the Densify op in near future?

hwangdeyu commented 3 years ago

Hi @TomWildenhain-Microsoft, based on the result of my debugging, this repro code is crashed by this line. https://github.com/onnx/tensorflow-onnx/blob/a1a9343cef193ef45b7f91d511e9c7bd1dffb3e3/tf2onnx/tflite_utils.py#L200 Cause the _get_tensor_details() function will catch the TensorSparsityParameters of tflite interpreter. While TensorSparsityParameters is missing in one of the tensor.

    tensor_sparsity_params = self._interpreter.TensorSparsityParameters(tensor_index)

However, we don't use the tensor_sparsity_params in details. If I remove the above line in _get_tensor_details() function. There will get the shape error.

cannot reshape array of size 96 into shape (16,1,1,24)

Do you have any idea about this case?

Som5ra commented 5 days ago

To those still looking for onnx format for mediapipe pose detection model: https://github.com/PINTO0309/PINTO_model_zoo/blob/main/053_BlazePose/download.sh

pls refer: https://github.com/PINTO0309/tflite2tensorflow/issues/18 https://github.com/PINTO0309/tflite2tensorflow/issues/11