Problem uploading personal model


I am having trouble with uploading a model. I am using st.file_uploader as such.

uploaded_model = st.file_uploader('And/Or upload your classification model (.sav)', type='sav')

I would then call my function load_model:

def load_model(model):
    f =
    loaded_model = pickle.load(f)
    return loaded_model

I would get this error:
TypeError: expected str, bytes or os.PathLike object, not _io.BytesIO


  File "/anaconda3/lib/python3.7/site-packages/streamlit/", line 324, in _run_script
    exec(code, module.__dict__)
  File "/Users/vinhnguyen/Documents/Amruta/ML-Explainability-Front-End/", line 289, in <module>
  File "/Users/vinhnguyen/Documents/Amruta/ML-Explainability-Front-End/", line 95, in main
    model = load_model(uploaded_model)
  File "/Users/vinhnguyen/Documents/Amruta/ML-Explainability-Front-End/", line 198, in load_model
    f =


Bumping this post.

BytesIO is already a stream-like object. Have you tried just passing it directly to pickel.load?

def load_model(model):
    loaded_model = pickle.load(model)
    return loaded_model