PNG --> Bytes IO --> numpy conversion using file_uploader?

Here you go, @conic :slightly_smiling_face:

import streamlit as st
import numpy as np
from PIL import Image

img_file_buffer = st.file_uploader('Upload a PNG image', type='png')
if img_file_buffer is not None:
    image = Image.open(img_file_buffer)
    img_array = np.array(image)

Please note that this requires that you have Pillow.

Cheers! :partying_face:

6 Likes