Closed Fax3D closed 4 years ago
The converter is saying that it couldn't find any signatures on the model. A signature specifies the inputs/outputs that a model supports (https://www.tensorflow.org/guide/saved_model#specifying_signatures_during_export). If you still want to convert a function without any signatures, you can tell the converter to use a specific concrete function from the model using the --concrete_function flag. For example:
python -m tf2onnx.convert --saved-model path/to/model --output path/to/output --concrete_function 2
we assume the issue is gone.
the problem still exists, I get another error:
2023-03-11 11:56:44,493 - WARNING - '--tag' not specified for saved_model. Using --tag serve
2023-03-11 11:56:44,529 - INFO - Signatures found in model: [].
Traceback (most recent call last):
File "C:\Users\Seyed Amirreza\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Seyed Amirreza\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\Seyed Amirreza\AppData\Local\Programs\Python\Python310\lib\site-packages\tf2onnx-1.13.0-py3.10.egg\tf2onnx\convert.py", line 706, in <module>
main()
File "C:\Users\Seyed Amirreza\AppData\Local\Programs\Python\Python310\lib\site-packages\tf2onnx-1.13.0-py3.10.egg\tf2onnx\convert.py", line 238, in main
graph_def, inputs, outputs, initialized_tables, tensors_to_rename = tf_loader.from_saved_model(
File "C:\Users\Seyed Amirreza\AppData\Local\Programs\Python\Python310\lib\site-packages\tf2onnx-1.13.0-py3.10.egg\tf2onnx\tf_loader.py", line 611, in from_saved_model
_from_saved_model_v2(model_path, input_names, output_names,
File "C:\Users\Seyed Amirreza\AppData\Local\Programs\Python\Python310\lib\site-packages\tf2onnx-1.13.0-py3.10.egg\tf2onnx\tf_loader.py", line 557, in _from_saved_model_v2
utils.make_sure(hasattr(imported, "__call__"), err_no_call)
File "C:\Users\Seyed Amirreza\AppData\Local\Programs\Python\Python310\lib\site-packages\tf2onnx-1.13.0-py3.10.egg\tf2onnx\utils.py", line 264, in make_sure
raise ValueError("make_sure failure: " + error_msg % args)
ValueError: make_sure failure: Model doesn't contain usable concrete functions under __call__. Try --signature-def instead.
anybody has comments?
Hi, what's the solution so far?
there is no source code or reference on the whole internet for solving this problem... I don't know...
was able to solve the same problem whilst loading a model from tf.hub
. Here is the solution:
loading the model
model = hub.load('https://tfhub.dev/google/yamnet/1')
get the concrete function
concrete_func = model.signatures['serving_default']
save the model with the signature
tf.saved_model.save(model, 'yamnet_model', signatures=concrete_func)
export it to onnx
!python -m tf2onnx.convert --opset 14 --saved-model /content/yamnet_model --output model.onnx
Describe the bug I got an error trying to convert from a saved_model.pb builded with tensorflow 2.3.0:
Traceback (most recent call last): File "C:\Program Files\Python38\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Program Files\Python38\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\xxx\AppData\Roaming\Python\Python38\site-packages\tf2onnx\convert.py", line 171, in <module> main() File "C:\Users\xxx\AppData\Roaming\Python\Python38\site-packages\tf2onnx\convert.py", line 131, in main graph_def, inputs, outputs = tf_loader.from_saved_model( File "C:\Users\xxx\AppData\Roaming\Python\Python38\site-packages\tf2onnx\tf_loader.py", line 288, in from_saved_model _from_saved_model_v2(model_path, input_names, output_names, tag, signatures, concrete_function) File "C:\Users\xxx\AppData\Roaming\Python\Python38\site-packages\tf2onnx\tf_loader.py", line 264, in _from_saved_model_v2 utils.make_sure(len(valid_sigs) > 0, err_no_sig) File "C:\Users\xxx\AppData\Roaming\Python\Python38\site-packages\tf2onnx\utils.py", line 193, in make_sure raise ValueError("make_sure failure: " + error_msg % args) ValueError: make_sure failure: No signatures found in model. Try --concrete_function instead.
What's wrong?
Tensorflow version: 2.3.0 Python version: 3.8.5 OS: Windows 10
Attached there's my python script. test.py.txt
Thanks!