Closed neso613 closed 3 years ago
Can you upload the model you are trying to convert?
Can you upload the model you are trying to convert?
Please accept my apologies. I can not share the model. However, I am sharing some details of model- Thanks!
Hmm, the signature names isn't going to help much. Can you provide the full stack trace/full console output?
Hmm, the signature names isn't going to help much. Can you provide the full stack trace/full console output? signature_def['__saved_model_init_op']: The given SavedModel SignatureDef contains the following input(s): The given SavedModel SignatureDef contains the following output(s): outputs['__saved_model_init_op'] tensor_info: dtype: DT_INVALID shape: unknown_rank name: NoOp Method name is:
signature_def['serving_default']: The given SavedModel SignatureDef contains the following input(s): inputs['input_2'] tensor_info: dtype: DT_FLOAT shape: (-1, 256, 121, 1) name: serving_default_input_2:0 The given SavedModel SignatureDef contains the following output(s): outputs['conv1d_151'] tensor_info: dtype: DT_FLOAT shape: (-1, 256, 121) name: StatefulPartitionedCall:0 Method name is: tensorflow/serving/predict
Defined Functions: Function Name: 'call' Option #1 Callable with: Argument #1 inputs: TensorSpec(shape=(None, 256, 121, 1), dtype=tf.float32, name='inputs') Argument #2 DType: bool Value: False Argument #3 DType: NoneType Value: None Option #2 Callable with: Argument #1 input_2: TensorSpec(shape=(None, 256, 121, 1), dtype=tf.float32, name='input_2') Argument #2 DType: bool Value: False Argument #3 DType: NoneType Value: None Option #3 Callable with: Argument #1 input_2: TensorSpec(shape=(None, 256, 121, 1), dtype=tf.float32, name='input_2') Argument #2 DType: bool Value: True Argument #3 DType: NoneType Value: None Option #4 Callable with: Argument #1 inputs: TensorSpec(shape=(None, 256, 121, 1), dtype=tf.float32, name='inputs') Argument #2 DType: bool Value: True Argument #3 DType: NoneType Value: None
Function Name: '_default_save_signature' Option #1 Callable with: Argument #1 input_2: TensorSpec(shape=(None, 256, 121, 1), dtype=tf.float32, name='input_2')
Function Name: 'call_and_return_all_conditional_losses' Option #1 Callable with: Argument #1 input_2: TensorSpec(shape=(None, 256, 121, 1), dtype=tf.float32, name='input_2') Argument #2 DType: bool Value: False Argument #3 DType: NoneType Value: None Option #2 Callable with: Argument #1 input_2: TensorSpec(shape=(None, 256, 121, 1), dtype=tf.float32, name='input_2') Argument #2 DType: bool Value: True Argument #3 DType: NoneType Value: None Option #3 Callable with: Argument #1 inputs: TensorSpec(shape=(None, 256, 121, 1), dtype=tf.float32, name='inputs') Argument #2 DType: bool Value: True Argument #3 DType: NoneType Value: None Option #4 Callable with: Argument #1 inputs: TensorSpec(shape=(None, 256, 121, 1), dtype=tf.float32, name='inputs') Argument #2 DType: bool Value: False Argument #3 DType: NoneType Value: None
It looks like tf2onnx is calling 'len' on some object that is None. Does the stack trace tell you what line of code this error occurred on? I think you gave me the console output but not the stack trace.
2021-05-17 14:52:23,241 - INFO - Using tensorflow=2.5.0, onnx=1.9.0, tf2onnx=1.8.5/50049d
2021-05-17 14:52:23,242 - INFO - Using opset <onnx, 11>
2021-05-17 14:52:25,201 - INFO - Computed 0 values for constant folding
2021-05-17 14:52:32,675 - ERROR - Failed to convert node 'StatefulPartitionedCall/model_2/model_1/conv2d_4/BiasAdd_1' (fct=<bound method ConvOp.version_11 of <class 'tf2onnx.onnx_opset.nn.ConvOp'>>)
'OP=Conv\nName=StatefulPartitionedCall/model_2/model_1/conv2d_4/BiasAdd_1\nInputs:\n\tStatefulPartitionedCall/model_2/lambda_1/Slice:0=Slice, None, 1\n\tStatefulPartitionedCall/model_2/model_1/conv2d_4/Conv2D_1/ReadVariableOp:0=Const, [5, 5, 1, 16], 1\n\tStatefulPartitionedCall/model_2/model_1/conv2d_4/BiasAdd_1/ReadVariableOp:0=Const, [16], 1\nOutpus:\n\tStatefulPartitionedCall/model_2/model_1/conv2d_4/BiasAdd_1:0=[-1, 256, 121, 16], 1'
Traceback (most recent call last):
File "/home/geek/anaconda3/envs/tf2onnx/lib/python3.7/site-packages/tf2onnx/tfonnx.py", line 294, in tensorflow_onnx_mapping
func(g, node, kwargs, initialized_tables=initialized_tables, dequantize=dequantize)
File "/home/geek/anaconda3/envs/tf2onnx/lib/python3.7/site-packages/tf2onnx/onnx_opset/nn.py", line 386, in version_11
cls.any_version(11, ctx, node, kwargs)
File "/home/geek/anaconda3/envs/tf2onnx/lib/python3.7/site-packages/tf2onnx/onnx_opset/nn.py", line 356, in any_version
if len(input_shape) == spatial + 1:
TypeError: object of type 'NoneType' has no len()
2021-05-17 14:52:32,924 - ERROR - Failed to convert node 'StatefulPartitionedCall/model_2/model_1/conv2d_4/BiasAdd' (fct=<bound method ConvOp.version_11 of <class 'tf2onnx.onnx_opset.nn.ConvOp'>>)
'OP=Conv\nName=StatefulPartitionedCall/model_2/model_1/conv2d_4/BiasAdd\nInputs:\n\tStatefulPartitionedCall/model_2/lambda/Slice:0=Slice, None, 1\n\tStatefulPartitionedCall/model_2/model_1/conv2d_4/Conv2D/ReadVariableOp:0=Const, [5, 5, 1, 16], 1\n\tStatefulPartitionedCall/model_2/model_1/conv2d_4/BiasAdd/ReadVariableOp:0=Const, [16], 1\nOutpus:\n\tStatefulPartitionedCall/model_2/model_1/conv2d_4/BiasAdd:0=[-1, 256, 121, 16], 1'
Traceback (most recent call last):
File "/home/geek/anaconda3/envs/tf2onnx/lib/python3.7/site-packages/tf2onnx/tfonnx.py", line 294, in tensorflow_onnx_mapping
func(g, node, kwargs, initialized_tables=initialized_tables, dequantize=dequantize)
File "/home/geek/anaconda3/envs/tf2onnx/lib/python3.7/site-packages/tf2onnx/onnx_opset/nn.py", line 386, in version_11
cls.any_version(11, ctx, node, kwargs)
File "/home/geek/anaconda3/envs/tf2onnx/lib/python3.7/site-packages/tf2onnx/onnx_opset/nn.py", line 356, in any_version
if len(input_shape) == spatial + 1:
TypeError: object of type 'NoneType' has no len()
Traceback (most recent call last):
File "/home/geek/anaconda3/envs/tf2onnx/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/geek/anaconda3/envs/tf2onnx/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/geek/anaconda3/envs/tf2onnx/lib/python3.7/site-packages/tf2onnx/convert.py", line 488, in
Let's try #1524 and see if it fixes it.
The change has merged. @neso613 try the latest tf2onnx from GitHub and let me know if it works.
The change has merged. @neso613 try the latest tf2onnx from GitHub and let me know if it works.
still have same issue. I have installed latest versions. 2021-05-21 12:20:41,129 - INFO - Using tensorflow=2.5.0, onnx=1.9.0, tf2onnx=1.8.5/50049d
The issue is caused because the input rank to the conv is unknown. This should be very rare. Do you have any idea why the input rank would be unknown for this model? You can try passing in a shape to the inputs --inputs someinp:0[1,2,3,4]
I would be very surprised if the line number is the same. Do you have a new stack trace?
The issue is caused because the input rank to the conv is unknown. This should be very rare. Do you have any idea why the input rank would be unknown for this model? You can try passing in a shape to the inputs
--inputs someinp:0[1,2,3,4]
I would be very surprised if the line number is the same. Do you have a new stack trace? Getting this error when --inputs someinp:0[1,2,3,4] used .
WARNING:tensorflow:From /home/nehasoni/anaconda3/envs/tf2onnx/lib/python3.7/site-packages/tf2onnx/tf_loader.py:603: extract_sub_graph (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.compat.v1.graph_util.extract_sub_graph
2021-05-24 15:08:18,173 - WARNING - From /home/nehasoni/anaconda3/envs/tf2onnx/lib/python3.7/site-packages/tf2onnx/tf_loader.py:603: extract_sub_graph (from tensorflow.python.framework.graph_util_impl) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.compat.v1.graph_util.extract_sub_graph
Traceback (most recent call last):
File "/home/nehasoni/anaconda3/envs/tf2onnx/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/nehasoni/anaconda3/envs/tf2onnx/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/nehasoni/anaconda3/envs/tf2onnx/lib/python3.7/site-packages/tf2onnx/convert.py", line 488, in
someinp:0[1,2,3,4]
was an example. You will need to replace it with the actual model input name and shape.
I assume this is resolved.
TypeError: object of type 'NoneType' has no len()
python3 -m tf2onnx.convert --saved-model my_saved_models/ --signature_def 'serving_default' --tag 'serve' --opset 10 --output my.onnx
tried different opset also