Hey, How do I save this model - दृश्य ध्यान के साथ चित्र कैप्शनिंग | TensorFlow Core ? it has multiple classes and is not sequential or functional. I want to save it in a way that I can upload it on HuggingFace Hub and make a HF space as well.
This seems a question more appropriate to the TensorFlow Forum.
What you can do is save the encoder in a model repo and the decoder in another model repo. In the Space, you can load the encoder and decoder and then run the code similar to Image captioning with visual attention | TensorFlow Core. For the part of pushing the files to the hub, you can try to use the
push_to_hub_keras method from the
huggingface_hub library (Mixins & serialization methods), or you could also try to simply save the model yourself, and then upload them to the Hub.
You can find many examples of the above at keras-io (Keras).
To add on top of @osanseviero’s answer, you can load the models from both repos with
model = from_pretrained_keras("user-name/model-id") inside the Space.
Cause as you may notice there seems to be a warning when saving. Appreciate any insight.
Sorry for the late reply.
What I’d do is
from huggingface_hub import push_to_hub_keras push_to_hub_keras(decoder, "your-username/my-awesome-decoder") push_to_hub_keras(encoder, "your-username/my-awesome-encoder")
this way your model has a model card with metrics, hyperparameters and model architecture too!
You can also call like
push_to_hub_keras(encoder, "your-username/my-awesome-encoder", log_dir = your-tensorboard-logdir)
and you will get a hosted tensorboard on your repository.