From 44824fb5f938ff93cd2c507ba3c89ca0f3d4f7f8 Mon Sep 17 00:00:00 2001 From: JeLuF Date: Mon, 17 Apr 2023 23:22:44 +0200 Subject: [PATCH 1/2] Don't download 1.4 if other models are available --- scripts/on_sd_start.bat | 24 +++++++++++++----------- scripts/on_sd_start.sh | 7 +++++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index 7efd4577..728e0f82 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -186,22 +186,24 @@ call WHERE uvicorn > .tmp ) ) -@if not exist "..\models\stable-diffusion\sd-v1-4.ckpt" ( - @echo. & echo "Downloading data files (weights) for Stable Diffusion.." & echo. +@if not exist "..\models\stable-diffusion\*.ckpt" ( + @if not exist "..\models\stable-diffusion\*.safetensors" ( + @echo. & echo "Downloading data files (weights) for Stable Diffusion.." & echo. - @call curl -L -k https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt > ..\models\stable-diffusion\sd-v1-4.ckpt + @call curl -L -k https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt > ..\models\stable-diffusion\sd-v1-4.ckpt - @if exist "..\models\stable-diffusion\sd-v1-4.ckpt" ( - for %%I in ("..\models\stable-diffusion\sd-v1-4.ckpt") do if "%%~zI" NEQ "4265380512" ( - echo. & echo "Error: The downloaded model file was invalid! Bytes downloaded: %%~zI" & echo. - echo. & echo "Error downloading the data files (weights) for Stable Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. + @if exist "..\models\stable-diffusion\sd-v1-4.ckpt" ( + for %%I in ("..\models\stable-diffusion\sd-v1-4.ckpt") do if "%%~zI" NEQ "4265380512" ( + echo. & echo "Error: The downloaded model file was invalid! Bytes downloaded: %%~zI" & echo. + echo. & echo "Error downloading the data files (weights) for Stable Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. + pause + exit /b + ) + ) else ( + @echo. & echo "Error downloading the data files (weights) for Stable Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. pause exit /b ) - ) else ( - @echo. & echo "Error downloading the data files (weights) for Stable Diffusion. Sorry about that, please try to:" & echo " 1. Run this installer again." & echo " 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting" & echo " 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB" & echo " 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues" & echo "Thanks!" & echo. - pause - exit /b ) ) diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index fcf7dc53..7582547b 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -170,8 +170,11 @@ if [ -f "../models/stable-diffusion/sd-v1-4.ckpt" ]; then fi fi -if [ ! -f "../models/stable-diffusion/sd-v1-4.ckpt" ]; then - echo "Downloading data files (weights) for Stable Diffusion.." + +if find "../models/stable-diffusion/" -name "*.ckpt" -or -name "*.safetensors" > /dev/null; then + echo "Found existing model file(s)." +else + echo "Downloading data files (weights) for Stable Diffusion..." curl -L -k https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt > ../models/stable-diffusion/sd-v1-4.ckpt From 893b6d985cf5d00da06ff4f6805c4c175857d667 Mon Sep 17 00:00:00 2001 From: JeLuF Date: Tue, 18 Apr 2023 09:12:26 +0200 Subject: [PATCH 2/2] Add "Start scanning..." to getModels() Provide a hint to users what ED is currently using. Use case: User has built an infinite loop using symlinks, ED model scan will never finish. https://discord.com/channels/1014774730907209781/1097764777553580092 --- ui/easydiffusion/model_manager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/easydiffusion/model_manager.py b/ui/easydiffusion/model_manager.py index 296c4192..f32cfd9b 100644 --- a/ui/easydiffusion/model_manager.py +++ b/ui/easydiffusion/model_manager.py @@ -245,6 +245,7 @@ def getModels(): except MaliciousModelException as e: models["scan-error"] = e + log.info(f"[green]Scanning all model folders for models...[/]") # custom models listModels(model_type="stable-diffusion") listModels(model_type="vae")