Having trouble deploying to Streamlit cloud. Model not found

I am having trouble deploying my model into streamlit cloud. It works just fine on my local machine when run through command prompt but I get errors that it can’t find my model when trying to deploy the new app.

File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
    exec(code, module.__dict__)File "/mount/src/laptop-price-predict/streamlit_app.py", line 11, in <module>
    model = load_model()File "/mount/src/laptop-price-predict/streamlit_app.py", line 8, in load_model
    model = joblib.load(model_path)File "/home/adminuser/venv/lib/python3.9/site-packages/joblib/numpy_pickle.py", line 579, in load
    with open(filename, 'rb') as f:

Here is my github that has the streamlit_app.py and my requirements.txt
Am I supposed to have something else in github to be able to run the app?
I’m sure its something that has to do with a path but I’m just not figuring it out.

Any help is appreciated
Thank you.

You are supposed to have 'laptop_price_prediction_model.joblib'. Otherwise how could joblib load it?

This is where I show how new I am to all this. Where am I supposed to put it so it can find it?

Same place as the other files.

This is my first time using GitHub so I’m sorry if I’m not following. Are you able to give me a step by step of what I’m supposed to do with the file? How and where it’s supposed to be so it can load properly?

Just put the model files in the same folder as the other source files.

If you are using just the github web interface, click the “Add file” button to add files to your repository.

I added the file but Im still getting the same error. ile “/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 535, in _run_script
exec(code, module.dict)
File “/mount/src/laptop-price-predict/streamlit_app.py”, line 11, in
model = load_model()
File “/mount/src/laptop-price-predict/streamlit_app.py”, line 8, in load_model
model = joblib.load(model_path)
File “/home/adminuser/venv/lib/python3.9/site-packages/joblib/numpy_pickle.py”, line 587, in load
obj = _unpickle(fobj, filename, mmap_mode)
File “/home/adminuser/venv/lib/python3.9/site-packages/joblib/numpy_pickle.py”, line 506, in _unpickle
obj = unpickler.load()
File “/usr/local/lib/python3.9/pickle.py”, line 1212, in load

What else do I need to fix?

Which ML library was used to generate the model?

I just uploaded my notebook into github.

sorry wrong one

Now i loaded my notebook into github. laptop_interface.ipynb

  • use the file below :arrow_down:
  • if necessary, pin the versions of scikit-learn and joblib to the same versions you used on your local machine
  • do a reboot of the app



Do I take everything out of my requirments.txt and then put in what you mentioned? I only ask because the ones you mentioned are already in my file.

  • Yes, you don’t need the rest
  • Maybe you have to pin the versions
  • Do a reboot after every change in the requirements file

Thank you so much. It is working. I really appreciate you both.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.