MPolaris / onnx2tflite

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

Convert fail Cannot reshape a tensor #54

Open ZTMIDGO opened 1 year ago

ZTMIDGO commented 1 year ago

Checking 0/1... INFO:deformation_layers ::Reshape will process tensor after change back to NCHW format. Traceback (most recent call last): File "D:\python\onnx2tflite\converter.py", line 108, in run() File "D:\python\onnx2tflite\converter.py", line 92, in run onnx_converter( File "D:\python\onnx2tflite\converter.py", line 21, in onnx_converter keras_model = keras_builder(model_proto, native_groupconv) File "D:\python\onnx2tflite\utils\builder.py", line 82, in keras_builder tf_tensor[node_outputs[index]] = tf_operator(tf_tensor, onnx_weights, node_inputs, op_attr, index=index)(_inputs) File "D:\python\onnx2tflite\layers\deformation_layers.py", line 97, in call inputs = tf.reshape(inputs, shape=self.out_shape) File "D:\python\onnx2tflite\venv\lib\site-packages\tensorflow\python\util\traceback_utils.py", line 153, in error_handler raise e.with_traceback(filtered_tb) from None File "D:\python\onnx2tflite\venv\lib\site-packages\keras\src\layers\core\tf_op_layer.py", line 119, in handle return TFOpLambda(op)(*args, **kwargs) File "D:\python\onnx2tflite\venv\lib\site-packages\keras\src\utils\traceback_utils.py", line 70, in error_handler raise e.with_traceback(filtered_tb) from None ValueError: Exception encountered when calling layer "tf.reshape" (type TFOpLambda).

Cannot reshape a tensor with 8388608 elements to shape [0,1,?] (0 elements) for '{{node tf.reshape/Reshape}} = Reshape[T=DT_FLOAT, Tshape=DT_INT64](Placeholder, tf.reshape/Reshape/shape)' with input shapes: [1,32,512,512], [3] and with input tensors computed as partial shapes: input[1] = [0,1,?].

Call arguments received by layer "tf.reshape" (type TFOpLambda): • tensor=tf.Tensor(shape=(1, 32, 512, 512), dtype=float32) • shape=array([ 0, 1, -1], dtype=int64) • name=None

ZTMIDGO commented 1 year ago

ONNX MODEL: onnx.zip