Hello, I have a big issue when I try to upload a batch of images using file uploader for the first batch is upload but I need to clear the list of file uploader to classify the other batches because if I don’t the second, third,… just append How can I fix this issue???
First, welcome to the Streamlit community!!!
The only way to clear files from the uploader is to hit the ‘x’ button, there is no official programmatic way to clear them.
BUT with the introduction of
forms and the
clear_on_submit, you might be able to get the behaviour your looking for!
Take this example:
with st.form("my-form", clear_on_submit=True): file = st.file_uploader("FILE UPLOADER") submitted = st.form_submit_button("UPLOAD!") if submitted and file is not None: st.write("UPLOADED!") # do stuff with your uploaded file
This will allow you to upload a file and hit the
UPLOAD! button. When Streamlit re-runs, the file will be uploaded and run through any process you have in the
if submitted and file is not None statement, and the
file_uploader at the top will be cleared and ready for the next file or “batch”!