From 201a053025492ae21a0f21d3ab1ad87aff6c5db6 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 6 Oct 2022 14:28:02 +0530 Subject: [PATCH] Support an arbitrary number of custom models, placed in the models/stable-diffusion folder. Shows an option in the UI to select which model to use --- scripts/on_sd_start.bat | 2 + scripts/on_sd_start.sh | 2 + ui/index.html | 10 +++- ui/media/main.js | 31 ++++++++++- ui/sd_internal/__init__.py | 3 + ui/sd_internal/runtime.py | 21 ++++++- ui/server.py | 111 ++++++++++++++++++++++++++++++++++--- 7 files changed, 165 insertions(+), 15 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index 4481c384..d0b2eeb4 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -165,6 +165,8 @@ call WHERE uvicorn > .tmp +if not exist "..\models\stable-diffusion" mkdir "..\models\stable-diffusion" + @if exist "sd-v1-4.ckpt" ( for %%I in ("sd-v1-4.ckpt") do if "%%~zI" EQU "4265380512" ( echo "Data files (weights) necessary for Stable Diffusion were already downloaded. Using the HuggingFace 4 GB Model." diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index f035141f..d8374998 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -159,6 +159,8 @@ fi +mkdir -p "../models/stable-diffusion" + if [ -f "sd-v1-4.ckpt" ]; then model_size=`find "sd-v1-4.ckpt" -printf "%s"` diff --git a/ui/index.html b/ui/index.html index ca806b10..f824efed 100644 --- a/ui/index.html +++ b/ui/index.html @@ -15,7 +15,7 @@
  • Image Settings
  • (images at once)
  • +
  • + +