Page refreshes partially when slider value is updated

As part of an application, I am developing, I wrote the following code to display an image overlayed with a heatmap along with a slider to change the heatmap transparency.

heatmap_weightage = st.sidebar.slider(
                    'HeatMap Weightate', min_value=0.0,
                    max_value=1.0, value=0.5, step=0.1
                )
                overlayed_image = get_overlayed_image(
                    image_pil, gradcam_heatmap,
                    original_size, weightage=heatmap_weightage
                )

                st.image(overlayed_image)

The problem that I am facing is that whenever the slider value is changed on the interface, the page refreshes and resets itself. How can I prevent this from happening?

1 Like