Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save keras model to database

I created a keras model (tensorflow) and want to store it in my MS SQL Server database. What is the best way to do that? pyodbc.Binary(model) throws an error. I would prefer a way without storing the model in the file system first.

Thanks for any help

like image 431
MikeHuber Avatar asked May 26 '26 00:05

MikeHuber


2 Answers

It seems that there is no clean solution to directly store a model incl. weights into the database. I decided to store the model as h5 file in the filesystem and upload it from there into the database as a backup. For predictions I load anyway the model from the filesystem as it is much faster than getting it from the database for each prediction.

like image 156
MikeHuber Avatar answered May 27 '26 17:05

MikeHuber


The best approach would be to save it as a file in the system and just save the path in the database. This technique is usually used to store large files like images since databases usually struggle with them.

like image 27
Adrian Martinez Avatar answered May 27 '26 17:05

Adrian Martinez