''str' object has no attribute 'call' when converting .model to tflite file

I have been following this tutorial to perform voice command recognition for a couple words on my ESP32: https://github.com/atomic14/voice-controlled-robot

I was able to train my model and have the "fully_trained.model" file: "fully_trained.model"

Currently I am trying to convert the .model file into the tflite file, however I am getting the "'str' has no attribute 'call'" error: Code, Code, Errors

My tensorflow version is 2.6.2 and python version is 3.10.

Unfortunately, I do not have 10 reputation points yet, so I couldnt embed the images.



Solution 1:[1]

If you use tf.lite.TFLiteConverter.from_keras_model you need to pass the tf.keras.Model instance, not the path to the saved_model folder.

Use tf.lite.TFLiteConverter.from_saved_model() instead and pass the path to the "fully_trained.model" folder.

Solution 2:[2]

You've passed "fully_trained.model", with quotation marks, as an argument to TFLiteConverter. That's a string. Give the model a name and pass that name as an argument to the converter, without quotation marks.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 GPhilo
Solution 2 Schnitte