Iām a new user to Streamlit and have been playing around from past couple of weeks. Iām trying to create a application for Word embedding. Part of my models use libraries/code base that is dependent on Tensorflow 1.X and part of them use Tensorflow 2.X and also multiple pytorch dependencies. I have two separate anaconda environments for either of them to avoid dependency issues.
I want to have just one application file which will show/run all models and results irrespective of the environments (or hiding all environment details from user). Is there a simple/dynamic way to switch conda environments while the Streamlit app is running.
Was hoping advanced users might have some good insights on this ?
In general, no, you canāt switch conda environments from the same Python session (this is a Python limitation, not a Streamlit one). Once you load a module one time, trying to reload it again wonāt do anything:
So once Tensorflow 1.x is loaded, thatās what you have. Additionally, with conda, the Python interpreter is part of the environmentā¦trying to āswitchā the interpreter is essentially stopping the code and starting a different executable, which means Streamlit would no longer be running.
In industry, when people want to serve the results of a model, they wrap it up in their own process as an API, then call the API. You could do this in your caseā¦depending on a drop-down or radio button in streamlit, you could call the different API endpoints for your model results.
Thanks @randyzwitch . That makes sense and right now looks like the best option.
I might convert it to SavedModel format and serve it using Tensorflow Serving API.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking āAccept allā, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.