Yes, Streamlit accepts numpy arrays for video, audio, and image data. However, those arrays must contain the necessary headers and image information already (streamlit doesn’t construct them for you).
There is a “Todo” in the Streamlit code about making an API through which Streamlit might construct headers on the user’s behalf. Where that might fit on the product roadmap might be a ways off though.
I tried the first snippet and it worked. pip install tifffile and then (reposting here):
from tifffile import imsave
import numpy as np
# create data
d = np.ndarray(shape=(10,20), dtype=np.float32) # also supports 64bit but ImageJ does not
d[()] = np.arange(200).reshape(10, 20)
# save 32bit float (== single) tiff
imsave('test.tif', d) #, description="hohoho")
Both are writing to a file, then loading them on.
Is there a way to directly display the numpy data as image to save the i/o operations?
This will be especially useful if i want to display the image with a slider that adjusts the numpy data in real-time
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.