The line "tflite_model = converter.convert()" gives the AttributeError: 'str' object has no attribute 'call'.
See screenshot of code ->1
CODE:
import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_keras_model('///Users/theunskuhn/Desktop/Savedfile/basic_malaria_pos_neg_v3.h5')
converter.experimental_new_converter = True
tflite_model = converter.convert()
open("basic_malaria_pos_neg_v3.tflite", "wb").write(tflite_model)
ERROR: AttributeError: 'str' object has no attribute 'call'
The Error points to the line 4: "tflite_model = converter.convert()"
If you're using the
TFLiteConverter
API in TensorFlow 2.0 or above, theTFLiteConverter.from_keras_model
takes in a KerasModel
object and not the path of the model which isstr
.First, load the model using
tf.keras.models.load_model()
and then pass this model to theTFLiteConverter
API.The method
TFLiteConverter.from_keras_model_file()
was replaced byTFLiteConverter.from_keras_model()
in TF 2.0. See the docs.