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