How to download a file during the deployment

Hello,

I’m building a demo version of a machine learning tool I’m developping for my PhD using Streamlit. I’m trying to deploy it to Streamlit cloud. The deployment work but I need help with something.
Is it possible during deployment to download a file ? I need to have my machine-learning model model.h5 to be downloaded at the root of the application (next to my Home.py. It is possible to run a simple wget to my download URL during deployement ? If not what would be the alternative ? I could add it to the git repo, but it seem’s not ideal giving the model size.

My demo code is here: GitHub - lambda-science/HistoQuant-Streamlit: Streamlit application code for my histology quantification project
I’m simply trying to run model_sdh = keras.models.load_model("model.h5")

Thanks,

Have a nice day

Fixed it with this code

from os import path
import urllib.request

if path.exists("model.h5"):
    st.success("SDH Model ready to use !")
    pass
else:
    with st.spinner("Please wait we are downloading the SDH Model."):
        urllib.request.urlretrieve(
            "<<MY_URL>>", "model.h5"
        )
    st.success("SDH Model have been downloaded !")```
1 Like