Home > Software design >  Can't convert a ASR model from Tensorflow's tutorial "Simple audio recognition"
Can't convert a ASR model from Tensorflow's tutorial "Simple audio recognition"

Time:11-28

I managed to successfully run the code from this tutorial.

Now I would like run the model on the Google Dev Board. AFAIK the Google Dev Board only supports Tensorflow Lite. So the model has to be converted before it can be used on the Dev Board.

I tried to convert the saved model with

tflite_convert --saved_model_dir saved/ --output_file out.tflite

However, it doesn't work:

Traceback (most recent call last):
  File "/home/pat/.local/bin/tflite_convert", line 8, in <module>
    sys.exit(main())
  File "/home/pat/.local/lib/python3.9/site-packages/tensorflow/lite/python/tflite_convert.py", line 689, in main
    app.run(main=run_main, argv=sys.argv[:1])
  File "/usr/local/lib/python3.9/dist-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "/usr/local/lib/python3.9/dist-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "/home/pat/.local/lib/python3.9/site-packages/tensorflow/lite/python/tflite_convert.py", line 672, in run_main
    _convert_tf2_model(tflite_flags)
  File "/home/pat/.local/lib/python3.9/site-packages/tensorflow/lite/python/tflite_convert.py", line 273, in _convert_tf2_model
    converter = lite.TFLiteConverterV2.from_saved_model(
  File "/home/pat/.local/lib/python3.9/site-packages/tensorflow/lite/python/lite.py", line 1797, in from_saved_model
    raise ValueError("Only support at least one signature key.")
ValueError: Only support at least one signature key.

The problem seems to be that there is no signature in the model. When I run this code

imported = tf.saved_model.load("saved")
print(imported.signatures)

I get

_SignatureMap({})

CodePudding user response:

After adding a signature as described here the converter doesn't complain about signatures any more.

  • Related