keras-io icon indicating copy to clipboard operation
keras-io copied to clipboard

Question regarding saving models [keras-cv]

Open dwmar opened this issue 2 years ago • 5 comments
trafficstars

Hello,

I have been looking for information but I still am unclear about how to save and load the models obtained through the object detection guide . I am running my experiment using colab.

I would like to deploy the model on other computers, or even to load it on my own, but i run into custom object issues while trying to load models with the prediction layer as it appears to not be defined:

ValueError: Unknown layer: 'PredictionHead'. Please ensure you are using a keras.utils.custom_object_scope and that this object is included in the scope. See https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object for details.

Furthermore, I have tried saving used the SavedModel format as it appears to be able to load custom layers but i guess they are not compatible as they give the following error when running the load model function:

  • new_model = tf.keras.models.load_model(model_path)

ValueError: RetinaNet does not accept a loss to compile(). Instead, please pass box_loss and classification_loss. loss will be ignored during training.

I am guessing I would need to load the custom object, but as I have not defined the layer, I am feeling quite confused about how to proceed. Would really appreciate some advice,

Thank you.

dwmar avatar Sep 06 '23 14:09 dwmar