Cached loading of Tensorflow/Keras models

Hi all,

I want to cache loading of a MaskRCNN model that is implemented in Keras/Tensorflow since loading weights takes too long for me. I decorated the function to load the model with @st.cache(allow_output_mutation=True)

When running the script for the first time, everything runs smoothly. When running the script for the second time I get an error about a node missing in the Tensorflow graph, probably because the graph is not maintained across invocations of my script.

What would be the best way to solve this problem?

Thank you and best regards,

1 Like

Hi @tobiasp,
thanks for posting? Can you share your script for a repro?