keras-onnx
keras-onnx copied to clipboard
TypeError: must be str, not NoneType
I am trying to convert a Keras model developed with Tensorflow 2.3.1.
When converting the model using onnx_model = keras2onnx.convert_keras(model, 'fasttext-onnx', debug_mode=1)
I get the error in the title.
Following the entire error track:
TypeError Traceback (most recent call last)
<ipython-input-14-2989974affce> in <module>
1 output_model_path = "fasttext.onnx"
----> 2 onnx_model = keras2onnx.convert_keras(model, 'fasttext-onnx', debug_mode=1)
/opt/conda/lib/python3.7/site-packages/keras2onnx/main.py in convert_keras(model, name, doc_string, target_opset, channel_first_inputs, debug_mode, custom_op_conversions)
78 input_names = []
79 output_names = []
---> 80 output_dict = {}
81 if is_tf2 and is_tf_keras:
82 tf_graph = build_layer_output_from_model(model, output_dict, input_names,
/opt/conda/lib/python3.7/site-packages/keras2onnx/parser.py in parse_graph(topo, graph, target_opset, output_names, keras_node_dict)
839 def parse_graph(topo, graph, target_opset, output_names, keras_node_dict):
840 # type: (Topology, tf.Graph, int, [], []) -> Topology
--> 841 """
842 Build the node-layer mapper and parse the whole TF graph of Keras Model.
843 """
/opt/conda/lib/python3.7/site-packages/keras2onnx/parser.py in _parse_graph_core_v2(graph, keras_node_dict, topology, top_scope, output_names)
716 layer_info = LayerInfo.create(graph, node, layer_key, keras_node_dict,
717 current_layer_inputs, current_layer_outputs, inference_nodeset)
--> 718
719 nodelist = []
720 layer_inputs = _visit_nodelist(layer_info.nodelist, graph_inputs, None, keras_node_dict, node, nodelist,
/opt/conda/lib/python3.7/site-packages/keras2onnx/parser.py in _parse_nodes_v2(graph, inference_nodeset, graph_inputs, keras_node_dict, node, varset, visited, q_overall)
666 output_mask_list = kenode.outbound_layer.output_mask if \
667 isinstance(kenode.outbound_layer.output_mask, list) else [kenode.outbound_layer.output_mask]
--> 668 for ts_ in output_mask_list:
669 if ts_ is not None:
670 mask_ts.append(ts_)
/opt/conda/lib/python3.7/site-packages/keras2onnx/_parser_tf.py in create(node, layer, outputs_map, inference_nodeset)
128 while next_itr:
129 visited |= next_itr
--> 130 next_itr.clear()
131 for n_ in visited:
132 for i_ in n_.inputs:
TypeError: must be str, not NoneType
It is not clear to me what it is None and I hope you can help me.
Thanks!
Same issue here
Also experiencing this same issue! A Keras.applications ResNet50 model that is first saved to disk and reloaded seems to break keras2onnx.
Any help would be appreciated. The same model converts properly in tf2onnx.
I had a similar problem.
I was trying to copy weights from model1 to model2 and convert the model2 to ONNX, then it raised the error must be str, not NoneType
.
Strangely, I was able to avoid the error by creating model2 before model1.