Hello, I have a page on which I use a
select_box, which I want to redirect me towards different algorithms. For each
select_box, I create two
file_uploader and a
text_input, whose output is then used by a function. When I upload a file in one of the file_uploader, change the
select_box option, and come the
file_uploader is empty, and so is the
I would like my
file_uploader and my
txt_input to keep in “memory” (maybe by caching or by using the session_state) the last uploaded file and text input, so that it is still here when I switch
select_box option. Is that possible ?
What I’m doing right now is this:
import streamlit as st def display_labels(label): if label == 1: return "Image to Point Cloud" elif label == 2: return "Text to Point Cloud" elif label == 3: return "Point Cloud to Mesh" point_e_algo = st.selectbox("Choose which algorithm you want to use:", range(1, 4), format_func=display_labels) if point_e_algo == 1: help = "Upload the image you want to turn into a 3D Point Cloud." img = st.file_uploader(help, type=["png", "jpg", "jpeg"]) if img is not None: process_img(img) # customized function that I cached with st.cache elif point_e_algo == 2: help = "Please enter the prompt you want to turn in a 3D Point Cloud." prompt = st.text_input(help) if prompt is not None: process_txt(prompt) # customized function that I cached with st.cache elif point_e_algo == 3: help = "Upload a Point Cloud file to turn it into a mesh." npz = st.file_uploader(help, type=["npz"]) if npz is not None: process_npz(npz) # customized function that I cached with st.cache
And is there a way to let the processing functions run in the background when I switch the
select_box options ?
Thanks in advance for your help