Streamlit Deployment: tensorflow.python.framework.errors_impl.OpError

I am trying to deploy a streamlit app that uses a tensorflow model. The webapp is working properly on my local host but when I try to deploy it on Streamlit cloud I get the following errror: tensorflow.python.framework.errors_impl.OpError: not an sstable (bad magic number)

Please see github repo link:

The files associated with my tensorflow model are in the “saved_model” folder in the above repo.

Below is the error I see on my app:

Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.8/site-packages/streamlit/scriptrunner/", line 443, in _run_script
    exec(code, module.__dict__)
  File "/app/resp_db/", line 159, in <module>
    model = tensorflow.keras.models.load_model('./saved_model')
  File "/home/appuser/venv/lib/python3.8/site-packages/keras/utils/", line 67, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/home/appuser/venv/lib/python3.8/site-packages/tensorflow/python/training/", line 45, in error_translator
    raise errors_impl.OpError(None, None, error_message, errors_impl.UNKNOWN)
tensorflow.python.framework.errors_impl.OpError: not an sstable (bad magic number)

Here is a screen shot of my error:

I’m at a loss for what to do. Please help! Thx

Hi @pinhead000 :wave:

The error stems from line 159 of

model = tensorflow.keras.models.load_model(path+'/saved_model')

Replace the above with the correct path:

model = tensorflow.keras.models.load_model('/saved_model') 

Best, :balloon:

Thank you for suggestion. I implemented it (see github repo) but did not work. I got the following error:

OSError: No file or directory found at /saved_model

Please advise …

Update: I figured it out! I saved the model as a .h5 file directly instead of using SavedModel; this allowed the cloud deployment to work!

Link 1:,‘h5’%20to%20save()%20.

Link 2: