Tensorflow- How do I save a non sequential model that works on HF space?
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.
2022-04-16T13:45:45Z
This seems a question more appropriate to theTensorFlow 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 toImage captioning with visual attention  |  TensorFlow Core. For the part of pushing the files to the hub, you can try to use thepush_to_hub_kerasmethod from thehuggingface_hublibrary (Mixins &amp; 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 atkeras-io (Keras).
2022-04-18T20:25:33Z
To add on top of@osanseviero’s answer, you can load the models from both repos withmodel = from_pretrained_keras("user-name/model-id")inside the Space.
2022-04-18T21:39:03Z
Hey@merve, I was going throughkeras-io/image-captioning at mainand I wanted to know whether you did something similar to this -image1440×359 131 KBCause as you may notice there seems to be a warning when saving. Appreciate any insight.
2022-04-28T13:16:01Z
HelloSorry for the late reply.What I’d do isfrom 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 likepush_to_hub_keras(encoder, "your-username/my-awesome-encoder", log_dir = your-tensorboard-logdir)and you will get a hosted tensorboard on your repository.