python
def file_uploader():
# Allow users to upload multiple image files of specified types
uploaded_files = st.file_uploader("Please upload conversation images!", accept_multiple_files=True, type=["png", "jpg", "jpeg"])
if uploaded_files is not None:
# Save uploaded files in session state
st.session_state.uploaded_files = uploaded_files
# Set the number of images to display in one row
num_columns = 3
cols = st.columns(num_columns)
for i, uploaded_file in enumerate(uploaded_files):
image = Image.open(uploaded_file)
ocr_prompting(image) # Call the OCR function
# Select the column to display the image
col = cols[i % num_columns]
col.image(image, caption=uploaded_file.name)
else:
st.session_state.uploaded_files = []
st.session_state.ocr_result = []
I’m trying to extract text from images using GPT API’s OCR function, and I’m currently configuring the UI with dummy data.
However, when I upload a file through st.file_uploader, it shows a list of files like below and if I press X, it will be deleted, right?
I want to manage session_state with this button, is there any way?