Call a function with change of sidebar slider

Hi all
I have sidebar slider. I want to call one function with the change in value of slider. How can i do that ?

confidence_threshold = st.sidebar.slider(“Confidence Threshold”, 0.35, 0.95, 0.35, 0.05,key=“confidence_slider”)
if st.button(‘Detect Arthropods’):

if my_upload is not None:
    if my_upload.size > MAX_FILE_SIZE:
         st.error("The uploaded file is too large. Please upload an image smaller than 5MB.")
    else:
        with st.spinner(text='In progress'):
          process_image(image_file=my_upload,confidence_threshold=confidence_threshold)
        with st.spinner(text='In progress'):
            time.sleep(3)
            st.success('Done')

            bar = st.progress(50)
            time.sleep(3)
            bar.progress(100)
            st.success('Success message')
else:
    st.error('Please upload an image')

if confidence_threshold > 0.35 and confidence_threshold < 1.00:

if my_upload is not None:
      if my_upload.size > MAX_FILE_SIZE:
          st.error("The uploaded file is too large. Please upload an image smaller than 5MB.")
      else:
          with st.spinner(text='In progress'):
            process_image(image_file=my_upload,confidence_threshold=confidence_threshold)
          with st.spinner(text='In progress'):
              time.sleep(3)
              st.success('Done')

              bar = st.progress(50)
              time.sleep(3)
              bar.progress(100)
              st.success('Success message')
# else:
#   st.write("In else")
#   st.error('Please upload an image')

solved Thanks