From 0d9f3f49473d89d956273cd9422b2873a2b72ead Mon Sep 17 00:00:00 2001 From: ZeroCool940711 Date: Mon, 26 Sep 2022 02:36:10 -0700 Subject: [PATCH] Added support for running the webui on daisi.io --- configs/webui/webui_streamlit.yaml | 4 ++- scripts/Settings.py | 5 ++++ scripts/modeldownload.py | 39 ++++++++++++++++++++++++++++++ scripts/sd_utils.py | 4 +++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 scripts/modeldownload.py diff --git a/configs/webui/webui_streamlit.yaml b/configs/webui/webui_streamlit.yaml index e4f4891..c77973e 100644 --- a/configs/webui/webui_streamlit.yaml +++ b/configs/webui/webui_streamlit.yaml @@ -284,4 +284,6 @@ gfpgan: textual_inversion: value: 0 - \ No newline at end of file +daisi_app: + running_on_daisi_io: False + \ No newline at end of file diff --git a/scripts/Settings.py b/scripts/Settings.py index 3d9c826..31f6fdf 100644 --- a/scripts/Settings.py +++ b/scripts/Settings.py @@ -184,6 +184,11 @@ def layout(): st.session_state["defaults"].general.no_verify_input = st.checkbox("Do not Verify Input", value=st.session_state['defaults'].general.no_verify_input, help="Do not verify input to check if it's too long. Default: False") + st.session_state["defaults"].daisi_app.running_on_daisi_io = st.checkbox("Running on Daisi.io?", value=st.session_state['defaults'].daisi_app.running_on_daisi_io, + help="Specify if we are running on app.Daisi.io . Default: False") + + + with col4: st.title("Streamlit Config") diff --git a/scripts/modeldownload.py b/scripts/modeldownload.py new file mode 100644 index 0000000..01d4809 --- /dev/null +++ b/scripts/modeldownload.py @@ -0,0 +1,39 @@ +import os +import os.path as op + +def updateModels(): + if op.exists('models/ldm/stable-diffusion-v1/model.ckpt'): + pass + else: + os.system('wget https://www.googleapis.com/storage/v1/b/aai-blog-files/o/sd-v1-4.ckpt?alt=media -o models/ldm/stable-diffusion-v1/model.ckpt') + # os.rename('models/ldm/stable-diffusion-v1/sd-v1-4.ckpt?alt=media','models/ldm/stable-diffusion-v1/model.ckpt') + # os.system('wget https://cdn-lfs.huggingface.co/repos/ab/41/ab41ccb635cd5bd124c8eac1b5796b4f64049c9453c4e50d51819468ca69ceb8/14749efc0ae8ef0329391ad4436feb781b402f4fece4883c7ad8d10556d8a36a?response-content-disposition=attachment%3B%20filename%3D%22modelfull.ckpt%22 -o models/ldm/stable-diffusion-v1/model.ckpt') + # os.rename('models/ldm/stable-diffusion-v1/modelfull.ckpt','models/ldm/stable-diffusion-v1/model.ckpt') + + if op.exists('src/realesrgan/experiments/pretrained_models/RealESRGAN_x4plus.pth') and op.exists('src/realesrgan/experiments/pretrained_models/RealESRGAN_x4plus_anime_6B.pth'): + pass + else: + os.system('wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P src/realesrgan/experiments/pretrained_models') + os.system('wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth -P src/realesrgan/experiments/pretrained_models') + + if op.exists('src/gfpgan/experiments/pretrained_models/GFPGANv1.3.pth'): + pass + else: + os.system('wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P src/gfpgan/experiments/pretrained_models') + + if op.exists('src/latent-diffusion'): + pass + else: + os.system('git clone https://github.com/devilismyfriend/latent-diffusion.git') + os.system('mv latent-diffusion src/latent-diffusion') + + if op.exists('src/latent-diffusion/experiments/pretrained_models/model.ckpt'): + pass + else: + os.mkdir('src/latent-diffusion/experiments') + os.mkdir('src/latent-diffusion/experiments/pretrained_models') + os.system('wget https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1 -o src/latent-diffusion/experiments/pretrained_models/project.yaml') + # os.rename('src/latent-diffusion/experiments/pretrained_models/index.html?dl=1', 'src/latent-diffusion/experiments/pretrained_models/project.yaml') + os.system('wget https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1 -o src/latent-diffusion/experiments/pretrained_models/model.ckpt') + # os.rename('src/latent-diffusion/experiments/pretrained_models/index.html?dl=1', 'src/latent-diffusion/experiments/pretrained_models/model.ckpt') + \ No newline at end of file diff --git a/scripts/sd_utils.py b/scripts/sd_utils.py index fae58b9..2003036 100644 --- a/scripts/sd_utils.py +++ b/scripts/sd_utils.py @@ -85,6 +85,10 @@ else: if (os.path.exists(".streamlit/config.toml")): st.session_state["streamlit_config"] = toml.load(".streamlit/config.toml") +if st.session_state["defaults"].daisi_app.running_on_daisi_io: + if os.path.exists("scripts/modeldownload.py"): + import modeldownload + modeldownload.updateModels() # should and will be moved to a settings menu in the UI at some point grid_format = [s.lower() for s in st.session_state["defaults"].general.grid_format.split(':')]