Hi,
This is my first post in this Streamlit forum. Streamlit has been great so far and I was able to quickly create a webapp in comparison to Flask which took a long time. I ran into a problem where I have created a Sidebox widget with a file browser that has the ability to display all the files in the current working directory where the app is running. However when I start the app, the first file (in this case the image) is being processed by default. Is there a way I can modify the below code such that the image gets processed only when I click on the sidebox and then select a particular image/file.
def file_selector(folder_path):
filenames = os.listdir(folder_path)
selected_filename = st.sidebar.selectbox('Or select an example image', filenames)
return os.path.join(folder_path, selected_filename)
image_selected = file_selector(folder_path = "./example_images")
if image_selected is not None:
image = np.array(Image.open(image_selected))
st.image(image)
processed_image = predict.preprocess_image(image_selected)
prediction = predict.model_predict(processed_image, model)
st.write("### Predictions:")
res = '%s : %s' % (prediction[0][0], prediction[0][1])
st.write(res)
st.write("### Description:")
descr = predict.description(prediction)
st.write(descr[0][1])