I am trying to store a trained Keras model within a Django model FileField. Since Keras is not pickleable, I used the .h5 file format (https://www.tensorflow.org/guide/keras/save_and_serialize) to store the keras model. So basically just:
kerasmodel.save('temp.h5')
dat = open('temp.h5', mode='r')
myFile = File(dat)
mymodel.content.save('test', myFile)
mymodel.content is the Django model FileField
This causes the error:
UnicodeDecodeError at /model/ 'charmap' codec can't decode byte 0x90 in position 1928: character maps to "undefined"
I really don't care if Django can read this file or not, I just want to save it for later purposes. Since I can easily upload the file manually via the Django admin page to the model, it should be feasible.
Thanks in advance