I am unable to load a keras model using the pickle.load method

13 Views Asked by At

I am attempting to build a web application of a keras model and am trying to load the model into vscode using pickle.

I tried loading the model using the pickle.load() method:

def load_model():
    with open("convlstm_pickle.pkl", 'rb') as file:
        model = pickle.load(file)
    return model

model = load_model()

but the following error keeps popping up:

2024-03-11 21:09:21.043 Uncaught app exception
Traceback (most recent call last):
  File "C:\Users\caleb\Anaconda3\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 542, in _run_script
    exec(code, module.__dict__)
  File "C:\Projects\MLSS\predict_page.py", line 18, in <module>
    model = load_model()
            ^^^^^^^^^^^^
  File "C:\Projects\MLSS\predict_page.py", line 15, in load_model
    model = pickle.load(file)
            ^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'keras.saving.pickle_utils'
0

There are 0 best solutions below