MPolaris / onnx2tflite

Tool for onnx->keras or onnx->tflite. Hope this tool can help you.
Apache License 2.0
519 stars 41 forks source link

onnx模型转换问题 #10

Closed FinallyKiKi closed 1 year ago

FinallyKiKi commented 2 years ago

输入模型转换失败,以下是错误提示

引入onnxsim.simplify失败 模型优化失败, 从./end2end.onnx加载 2022-10-05 15:49:45.947888: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE4.1 SSE4.2 AVX AVX2 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2022-10-05 15:49:45.949148: I tensorflow/core/common_runtime/process_util.cc:146] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance. Transpose 操作将会回到NCHW形式进行 Reshape 操作将会回到NCHW形式进行 Transpose 操作将会回到NCHW形式进行 Reshape 操作将会回到NCHW形式进行 Traceback (most recent call last): File "/data/jdx/code/onnx2tflite/converter.py", line 70, in run() File "/data/jdx/code/onnx2tflite/converter.py", line 55, in run onnx_converter( File "/data/jdx/code/onnx2tflite/converter.py", line 18, in onnx_converter keras_model = keras_builder(model_proto, input_node_names, output_node_names) File "/data/jdx/code/onnx2tflite/utils/builder.py", line 88, in keras_builder tf_tensor[node_outputs[index]] = tf_operator(tf_tensor, onnx_weights, node_inputs, op_attr, index=index)(_inputs) File "/data/jdx/code/onnx2tflite/layers/deformation_layers.py", line 61, in call indices = tf.keras.backend.arange(self.starts, self.ends, step=self.steps) File "/data/jdx/miniconda3/envs/onnx/lib/python3.9/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler raise e.with_traceback(filtered_tb) from None File "/data/jdx/miniconda3/envs/onnx/lib/python3.9/site-packages/keras/backend.py", line 3601, in arange result = tf.range(start, limit=stop, delta=step, name='arange') tensorflow.python.framework.errors_impl.InvalidArgumentError: Requires start <= limit when delta > 0: 0/-1 [Op:Range]

MPolaris commented 2 years ago
  1. 首先看看onnx-simplifier安装了没有, pip install onnx-simplifier, 并且need_simplify=True
  2. 如果还不行,可以把onnx模型贴出来