keras-team / keras-io

Keras documentation, hosted live at keras.io
Apache License 2.0
2.78k stars 2.04k forks source link

Question regarding saving models [keras-cv] #1513

Open dwmar opened 1 year ago

dwmar commented 1 year ago

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:

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.

nkovela1 commented 1 year ago

Hi @dwmar, thanks for raising this issue! Do you mind providing a colab repro of your issue? I've tested saving and loading with the object detection guide and the models seem to work on my end.

dwmar commented 1 year ago

Hello @nkovela1!

Thanks for reaching out, I will provide a minimal reproduction of the issue, although the error output does not match, I am still unable to save the model and load them.

https://colab.research.google.com/drive/1WkB0GYU7vlnLrOnqk90gOWNlDR88aeil?usp=sharing

JAYANTHNITW commented 1 year ago

@dwmar I would like to help you with this issue, can you assign it to me, i will work on it, Thank you!!

dwmar commented 1 year ago

@JAYANTHNITW I am not a collaborator of this repo, I am not able to do that.

shikharRS commented 3 months ago

@dwmar i hope you got the way to deal with it ?. Please let me know if not