Hi - I coded up a cool streamlit app and am going to share it internally. It is an image viewer and has a sidebar with some slider bars. I have this hosted on an internal server with the “streamlit run myapp.py” command.
When multiple users are in the app, things get weird in the sidebar. The sidebar has a few slider bars, a selectbox, a checkbox and a button. I noticed that when someone else views the app in their browser when I have my browser open it seems to me like the sessions are cross talking. On my view I get repeated sliders, repeated buttons, that kind of thing. It seems I can also affect the other users browser by clicking buttons in mine.
Any ideas what could be causing it? When the other user closes their browser then all the weird behavior disappears and the app acts normally. What is the streamlit server model, are we using the same session cookie somehow? It seems like our sessions are sharing state between them.
Here is my code if you want to have a look:
def main():
file_dict = None
with open('file_data.json') as f:
file_dict = json.load(f)
st.title('Burrito Bounty')
obj = Image.open('bounty.jpg')
st.sidebar.image(obj)
with open('instructions.md', 'r') as file:
readme_txt = file.read()
st.markdown(readme_txt)
keys = list(file_dict.keys())
index = st.sidebar.slider('Image Index', 0, len(keys) - 1, 0)
show_fullres = st.sidebar.checkbox('Show Full Res Image')
load_option = st.sidebar.radio('Select Image To Load',
('Original RGB', 'Synthetic1', 'Synthetic2', 'Pop Green', 'NRG', 'NIR'))
adjust_contrast = st.sidebar.checkbox('Contrast Stretch')
use_column_width = not show_fullres
image_list = []
image_types = ['RGB', 'SYNTH', 'NRG', 'NIR', 'SYNTH2', 'POP_GREEN']
for i in image_types:
obj = Image.open(file_dict[keys[index]][i])
image_list.append(np.array(obj))
if adjust_contrast:
hi = st.sidebar.slider('Hi Cutoff %', 98.0, 100.0, 99.9, 0.1)
lo = st.sidebar.slider('Lo Cutoff %', 0.0, 2.0, 0.5, 0.1)
for idx, image in enumerate(image_list):
image = contrast_stretch(image, lo=lo, hi=hi)
image_list[idx] = image
button = st.sidebar.button('Release Balloons!')
if button:
st.balloons()
if load_option == 'Original RGB':
st.image(image_list[0], caption='Original Image, Image Index: {}'.format(index), use_column_width=use_column_width)
elif load_option == 'Synthetic1':
st.image(image_list[1], caption='Synthetic Image, Image Index: {}'.format(index),
use_column_width=use_column_width)
elif load_option == 'NRG':
st.image(image_list[2], caption='False Color Infrared Image, Image Index: {}'.format(index),
use_column_width=use_column_width)
elif load_option == 'NIR':
st.image(image_list[3], caption='NIR Image, Image Index: {}'.format(index),
use_column_width=use_column_width)
elif load_option == 'Synthetic2':
st.image(image_list[4], caption='Synthetic 2 Image, Image Index: {}'.format(index),
use_column_width=use_column_width)
elif load_option == 'Pop Green':
st.image(image_list[5], caption='Pop Green Image, Image Index: {}'.format(index),
use_column_width=use_column_width)
if __name__ == "__main__":
main()