Problem with file_uploader

Hi everyone! I’m trying to make a simple Streamlit App to help me with a labeling task for a ML project that I have,
The proccess is roughly like this:

  • An image gets uploaded
  • It goes through an OCR and returns an array of lines
  • Each line should be labeled separately

I wrote this to show each line with a selecbox with the possible labels

uploaded_file = st.file_uploader(label='Resumen de cuenta')

file_uploaded = False

lineas = []
labels = []

if uploaded_file is not None:
  bytes_data =
  with open('/tmp/resumen', 'wb') as f:

lineas = toText('/tmp/resumen') 

for i in range(len(lineas)):


but the problem I’m having is that everytime I change a selectbox everything gets rerendered, and the image I uploaded give an error

The moment I upload the image my app looks like this:

But when I change a selectbox it gives the following error:

Is there a workaround for this?

Thanks in advance!