Load_model in background

Hello community! :smiling_face:

I have a question, I need to load a model in my application, however I would like to do it from the landing page, and this is done in the background without compromising navigation on the application (change page via multipage, login, etc.).

Is there a way to do this?

Here my loading function (basic one) :

@st.cache_resource
def load_model() -> PyFuncModel:
    dagshub.init(DAGSHUB_REPO, DAGSHUB_REPO_OWNER, mlflow=True)
    return mlflow.pyfunc.load_model(MODEL_URI)

Thanks in advance for your feedback :raised_hands:

Your model is cached, so the loading time delay is only felt in the first call. This does not even matter to everyone. A single user can trigger a cache and all the other users can benefit from it. The server can just use the cached model to all subsequent users.

How many minutes does your function take to load the model for the first time?

Oh! So it’s acceptable!
My model doesn’t take long to load, about 25s.

Thank you @ferdy for these clarifications.

1 Like

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