I wrote an app to display images from a 2D detector. I use the st.experimental_rerun() function to this continuously. When using longer exposure times (seconds) the image displayed from the previous run fades as do some of the other components (I added for setting up acquisition parameters).
Is there a way to avoid this, i.e. at least the image remains displayed with the original contrasts until being replaced by the new one?
Thanks a lot in advance and for the great streamlit!
Digging further through the discussions here, I found that above topic can help me, by making components of my streamlit app be run as co-routines controlled(?) by asyncio.
Still, I shall appreciate any comment on my initial post.
I donāt think it is possible to control the fading out for now. Maybe youāll have better luck by putting the image in a placeholder and emptying it before running the rerun?
# beware, not tested code :)
image_placeholder = st.empty()
image_placeholder.image(t)
...
if st.button("Rerun"):
image_placeholder.empty()
st.experimental_rerun()
Hello @andfanilo!
Thanks a lot, but unfortunately this does not work, as wished.
The image disappears and other components shift into the emptied space. During the time to get the next image, things (e.g. some st.write() output) fade and than the image reappears.
what I did in my script was, that I separated calculation/data acquisition tasks, work(), from the stuff that does the displaying via streamlit, ui(). The script first runs įŗork() followed by ui(). What I observed, was that work() blocked part of streamlit activity which resulted in grayed-out widgets.
However, I now simply reversed the sequence, i.e. first ui() and than work(), which leads to better displaying performance. It might be necessary to do a st.experimental_rerun(), though, to update things in the UI.
Another solution is the use of asynchronous routines via asyncio as describe in this discussion:
I am still wondering, whatās the speediest way to display 2D/image data using streamlit.
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.