Ask or search…
K
Links
Comment on page
🗄

Keras models

You can save and load all kinds of ML models using the binary data storage db.storage.binary.
However, Keras does not support using io.BytesIO streams, so you will need to use a temporary file on disk to get the job done.
To save a Keras model:
model.save('mymodel.h5')
f = open('mymodel.h5', 'rb').read()
db.storage.binary.put('mymodel.h5', f)
And, to load it again:
obj = db.storage.binary.get('mymodel.h5')
with open('mymodel.h5', 'wb') as f:
f.write(obj)
model = load_model('mymodel.h5')