đź”§ _pickle.UnpicklingError When Loading YOLO Model in Streamlit App on Streamlit Cloud

Hey everyone,

I’m running into an issue while deploying a Streamlit app on Streamlit Cloud. The app tries to load a YOLO model (model.pt) using the Ultralytics YOLO library, but it crashes during the model loading step with a _pickle.UnpicklingError.

Here’s a snippet of the traceback:

_pickle.UnpicklingError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you're on Streamlit Cloud, click on 'Manage app' in the lower right of your app).

Traceback:
  File "/mount/src/vechile-sos-app/app.py", line 17, in <module>
    model = load_model()
  ...
  File "/home/adminuser/venv/lib/python3.12/site-packages/torch/serialization.py", line 1470, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None

Here’s how I’m loading the model:

from ultralytics import YOLO

def load_model():
    return YOLO("model.pt")