From 2a078d56574d3cded410c05cc39355a332deb456 Mon Sep 17 00:00:00 2001 From: ZeroCool940711 Date: Sun, 2 Oct 2022 21:50:24 -0700 Subject: [PATCH] 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. --- scripts/sd_utils.py | 5 ++++- scripts/webui_streamlit.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/sd_utils.py b/scripts/sd_utils.py index 925d6f7..56b333f 100644 --- a/scripts/sd_utils.py +++ b/scripts/sd_utils.py @@ -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") diff --git a/scripts/webui_streamlit.py b/scripts/webui_streamlit.py index 0950a0a..3bf38e7 100644 --- a/scripts/webui_streamlit.py +++ b/scripts/webui_streamlit.py @@ -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",