I’m trying to load a previously trained model but it gives me this error. Is there any way I can convert this file format to the new format or how do I fix this? I’d rather not have to train a new model if possible.
#Model was previously saved with
tf.keras.models.save_model(file_path)
#Load back in (causes error)
model_a = tf.keras.models.load_model(file_path)
This is the error received:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-12-120117fe47ab> in <cell line: 3>()
1 #@title Load the checkpoint
2 checkpoint_path = '/drive/MyDrive/dummy/2' # @param {type:"string"}
----> 3 model_a = tf.keras.models.load_model(checkpoint_path)
4 tf.keras.utils.plot_model(ad._model, show_shapes = True)
/usr/local/lib/python3.10/dist-packages/keras/src/saving/saving_api.py in load_model(filepath, custom_objects, compile, safe_mode)
197 )
198 else:
--> 199 raise ValueError(
200 f"File format not supported: filepath={filepath}. "
201 "Keras 3 only supports V3 `.keras` files and "
ValueError: File format not supported: filepath=/drive/MyDrive/dummy/2. Keras 3 only supports V3 `.keras` files and legacy H5 format files (`.h5` extension). Note that the legacy SavedModel format is not supported by `load_model()` in Keras 3. In order to reload a TensorFlow SavedModel as an inference-only layer in Keras 3, use `keras.layers.TFSMLayer(/drive/MyDrive/dummy/2, call_endpoint='serving_default')` (note that your `call_endpoint` might have a different name).