Fixed missing keys on first run, it seems related to server_state doing a rerun in the background on first run which changes the first session_state initialization, this causes it to be empty until the second run.

This commit is contained in:
ZeroCool940711 2022-10-02 21:50:24 -07:00
parent e975aac7a4
commit 2a078d5657
2 changed files with 8 additions and 2 deletions

View File

@ -99,7 +99,10 @@ st.session_state["defaults"] = OmegaConf.load("configs/webui/webui_streamlit.yam
if (os.path.exists("configs/webui/userconfig_streamlit.yaml")):
user_defaults = OmegaConf.load("configs/webui/userconfig_streamlit.yaml")
st.session_state["defaults"] = OmegaConf.merge(st.session_state["defaults"], user_defaults)
try:
st.session_state["defaults"] = OmegaConf.merge(st.session_state["defaults"], user_defaults)
except KeyError:
st.experimental_rerun()
else:
OmegaConf.save(config=st.session_state.defaults, f="configs/webui/userconfig_streamlit.yaml")
loaded = OmegaConf.load("configs/webui/userconfig_streamlit.yaml")

View File

@ -124,7 +124,10 @@ def layout():
if tabs =='Stable Diffusion':
# set the page url and title
st.experimental_set_query_params(page='stable-diffusion')
set_page_title("Stable Diffusion Playground")
try:
set_page_title("Stable Diffusion Playground")
except NameError:
st.experimental_rerun()
txt2img_tab, img2img_tab, txt2vid_tab, img2txt_tab, concept_library_tab = st.tabs(["Text-to-Image", "Image-to-Image",
"Text-to-Video", "Image-To-Text",