Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Deploy AI in google cloud

I want to deploy an AI model in google cloud but I am getting the following error:

 

Error loading Day 3 model: File format not supported: filepath=/tmp/tmpmt2bwnrg. 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(/tmp/tmpmt2bwnrg, call_endpoint='serving_default')` (note that your `call_endpoint` might have a different name).
 
 
0 3 265
3 REPLIES 3

Hi, @sani20.

Could you please let me know which file format you're using to save the model? Based on the logs, it appears you're using Keras 3 and the model format is not compatible with this version. Specifically, Keras 3 only supports the following formats:

  • .keras files (the newer Keras format)
  • Legacy .h5 format (from older versions of Keras)



Regards,
Mokit

Hi Mokit,
Thank you for your response. I saved the model with the following format and uploaded it in bucke:

model_day2.save(model_day2_path, save_format="keras")
 
Regards,
Sanaz

Instead of this:

model_day2.save(model_day2_path, save_format="keras")

Can you're saving the model as a .keras file:

model_day2.save(model_day2_path + '.keras')


When loading the model, you can follow the format below:

from tensorflow.keras.models import load_model

model = load_model(model_day2_path + '.keras')


Regards,
Mokit