blackary/streamlit-image-coordinates

Support image data as a numpy array

Closed this issue · 3 comments

I have a use case where my data is in memory in a numpy array. It would be great to be able to support this use case.

My workaround is to save the NumPy array as a temporary image and use that. A bit ugly, but it works. But I support the request to the author to suggest a better way to handle this case

I'm not sure what exactly you mean by "a temporary image" but converting it to a PIL image and then passing that in should work well. I think I would prefer that over trying to support any numpy array, since it might not always be straightforward to support this generically (e.g. if the array needs reshaped from N to X*Y before it can be read as an image).

https://stackoverflow.com/questions/10965417/how-to-convert-a-numpy-array-to-pil-image-applying-matplotlib-colormap

If you have a case where this doesn't work well, please let me know.

i could only write the image file from PIL buffer and read it again in another page