For the lines of code below, the code rerun everytime I click to get the coordinates, what i want is that once I get an image, I should be able to click on it multiple times and get the coordinates without it re-runing. Should I use session_state for this?
import matplotlib.pyplot as plt import random import streamlit as st from streamlit_image_coordinates import streamlit_image_coordinates @st.cache_data() # radius of the circle def oo(): fig= plt.figure(figsize=(3,3)) plt.scatter(random.randint(1,9),random.randint(9,18)) plt.title('Customer Groups') plt.xlabel('Income') plt.ylabel('Spending Score') plt.savefig("squares.png") st.pyplot(fig) oo() value = streamlit_image_coordinates('squares.png') st.write(value)
Running the lines of code will show how it functions in a way that developer doesn’t want to.
Even the code is run, the user should be able to click and get different coordinates without getting new values and plots due to re running inspite of using caches.
The undesired behavior is that it re runs and gets new values.
Also, it shows two images, and it would be good if it displays only one on the cloud app.