From a45743f443cb9c9cc8bf2d40829041a01162efe0 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Thu, 27 Oct 2022 20:56:49 +0530 Subject: [PATCH 01/32] Update CONTRIBUTING.md --- CONTRIBUTING.md | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 64959f07..3872fb27 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,12 +13,11 @@ If you would like to contribute to this project, there is a discord for dicussio This is in-flux, but one way to get a development environment running for editing the UI of this project is: (swap `.sh` or `.bat` in instructions depending on your environment, and be sure to adjust any paths to match where you're working) -1) `git clone` the repository, e.g. to `/projects/stable-diffusion-ui-repo` -2) Download the pre-built end user archive from the link on github, and extract it, e.g. to `/projects/stable-diffusion-ui-archive` -3) `cd /projects/stable-diffusion-ui-archive` and run the script to set up and start the project, e.g. `start.sh` -4) Check you can view and generate images on `localhost:9000` -5) Close the server, and edit `/projects/stable-diffusion-ui-archive/scripts/on_env_start.sh` -6) Comment out the lines near the bottom that copies the `files/ui` folder, e.g: +1) Install the project to a new location using the [usual installation process](https://github.com/cmdr2/stable-diffusion-ui#installation), e.g. to `/projects/stable-diffusion-ui-archive` +2) Start the newly installed project, and check that you can view and generate images on `localhost:9000` +3) Next, please clone the project repository using `git clone` (e.g. to `/projects/stable-diffusion-ui-repo`) +4) Close the server (started in step 2), and edit `/projects/stable-diffusion-ui-archive/scripts/on_env_start.sh` (or `on_env_start.bat`) +5) Comment out the lines near the bottom that copies the `files/ui` folder, e.g: for `.sh` ``` @@ -33,13 +32,13 @@ REM @xcopy sd-ui-files\ui ui /s /i /Y REM @copy sd-ui-files\scripts\on_sd_start.bat scripts\ /Y REM @copy "sd-ui-files\scripts\Start Stable Diffusion UI.cmd" . /Y ``` -7) Comment out the line at the top of `/projects/stable-diffusion-ui-archive/scripts/on_sd_start.sh` that copies `on_env_start`. For e.g. `@copy sd-ui-files\scripts\on_env_start.bat scripts\ /Y` +6) Next, comment out the line at the top of `/projects/stable-diffusion-ui-archive/scripts/on_sd_start.sh` (or `on_sd_start.bat`) that copies `on_env_start`. For e.g. `@rem @copy sd-ui-files\scripts\on_env_start.bat scripts\ /Y` 8) Delete the current `ui` folder at `/projects/stable-diffusion-ui-archive/ui` 9) Now make a symlink between the repository clone (where you will be making changes) and this archive (where you will be running stable diffusion): `ln -s /projects/stable-diffusion-ui-repo/ui /projects/stable-diffusion-ui-archive/ui` or for Windows -`mklink /D \projects\stable-diffusion-ui-archive\ui \projects\stable-diffusion-ui-repo\ui` (link name first, source repo dir second) -9) Run the archive again `start.sh` and ensure you can still use the UI. +`mklink /J \projects\stable-diffusion-ui-archive\ui \projects\stable-diffusion-ui-repo\ui` (link name first, source repo dir second) +9) Run the project again (like in step 2) and ensure you can still use the UI. 10) Congrats, now any changes you make in your repo `ui` folder are linked to this running archive of the app and can be previewed in the browser. Check the `ui/frontend/build/README.md` for instructions on running and building the React code. @@ -47,9 +46,5 @@ Check the `ui/frontend/build/README.md` for instructions on running and building ## Development environment for Installer changes Build the Windows installer using Windows, and the Linux installer using Linux. Don't mix the two, and don't use WSL. An Ubuntu VM is fine for building the Linux installer on a Windows host. -1. Install Miniconda 3 or Anaconda. -2. Install `conda install -c conda-forge -y conda-pack` -3. Open the Anaconda Prompt. Do not use WSL if you're building for Windows. -4. Run `build.bat` or `./build.sh` depending on whether you're in Windows or Linux. -5. Compress the `stable-diffusion-ui` folder created inside the `dist` folder. Make a `zip` for Windows, and `tar.xz` for Linux (smaller files, and Linux users already have tar). -6. Make a new GitHub release and upload the Windows and Linux installer builds. +1. Run `build.bat` or `./build.sh` depending on whether you're in Windows or Linux. +2. Make a new GitHub release and upload the Windows and Linux installer builds created inside the `dist` folder. From 1257e344875023d266e200a6cb5118f5135801c5 Mon Sep 17 00:00:00 2001 From: JeLuF Date: Thu, 27 Oct 2022 17:39:54 +0200 Subject: [PATCH 02/32] Add disk space requirements --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ffc7dd4..47edb505 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ Useful for judging (and stopping) an image quickly, without waiting for it to fi # System Requirements 1. Windows 10/11, or Linux. Experimental support for Mac is coming soon. 2. An NVIDIA graphics card, preferably with 4GB or more of VRAM. If you don't have a compatible graphics card, it'll automatically run in the slower "CPU Mode". -3. Minimum 8 GB of RAM. +3. Minimum 8 GB of RAM and 25GB of disk space. You don't need to install or struggle with Python, Anaconda, Docker etc. The installer will take care of whatever is needed. From 79b5e85b15135ba2f2989cfc5653484786f5010f Mon Sep 17 00:00:00 2001 From: JeLuF Date: Fri, 28 Oct 2022 09:21:31 +0200 Subject: [PATCH 03/32] Change "Advanced Settings" to "Image settings" The menu has been renamed, so the welcome text should reflect this. --- ui/index.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/index.html b/ui/index.html index 111dad6f..ea9a088a 100644 --- a/ui/index.html +++ b/ui/index.html @@ -226,7 +226,10 @@
- Type a prompt and press the "Make Image" button.

You can set an "Initial Image" if you want to guide the AI.

You can also add modifiers like "Realistic", "Pencil Sketch", "ArtStation" etc by browsing through the "Image Modifiers" section and selecting the desired modifiers.

Click "Advanced Settings" for additional settings like seed, image size, number of images to generate etc.

Enjoy! :) + Type a prompt and press the "Make Image" button.

You can set an "Initial Image" if you want to guide the AI.

+ You can also add modifiers like "Realistic", "Pencil Sketch", "ArtStation" etc by browsing through the "Image Modifiers" section + and selecting the desired modifiers.

+ Click "Image Settings" for additional settings like seed, image size, number of images to generate etc.

Enjoy! :)
From 450fb2553cd0d8d1ce4383229643cb5face3e5d3 Mon Sep 17 00:00:00 2001 From: Michael Nahkies Date: Sat, 10 Sep 2022 16:34:06 +0100 Subject: [PATCH 04/32] fix: change to the correct working directory changes to the directory containing `start.sh` prior to activating the conda environment this allows you to run the program without first changing to the correct directory, eg: `$ ~/bin/stable-diffusion-ui/start.sh` --- scripts/start.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/start.sh b/scripts/start.sh index d46b7f20..14093681 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -1,5 +1,7 @@ #!/bin/bash +cd "$(dirname "${BASH_SOURCE[0]}")" + # set legacy installer's PATH, if it exists if [ -e "installer" ]; then export PATH="$(pwd)/installer/bin:$PATH"; fi From fc11018158cb177c6406a6bdce641e84eeda6b57 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Sat, 29 Oct 2022 19:41:52 +0530 Subject: [PATCH 05/32] Re-download micromamba if necessary --- scripts/bootstrap.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index c110b11f..e497f953 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -29,6 +29,7 @@ export MAMBA_ROOT_PREFIX="$(pwd)/installer_files/mamba" INSTALL_ENV_DIR="$(pwd)/installer_files/env" LEGACY_INSTALL_ENV_DIR="$(pwd)/installer" MICROMAMBA_DOWNLOAD_URL="https://micro.mamba.pm/api/micromamba/${OS_NAME}-${OS_ARCH}/latest" +umamba_exists="F" # figure out whether git and conda needs to be installed if [ -e "$INSTALL_ENV_DIR" ]; then export PATH="$INSTALL_ENV_DIR/bin:$PATH"; fi @@ -38,10 +39,12 @@ PACKAGES_TO_INSTALL="" if [ ! -e "$LEGACY_INSTALL_ENV_DIR/etc/profile.d/conda.sh" ] && [ ! -e "$INSTALL_ENV_DIR/etc/profile.d/conda.sh" ]; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL conda"; fi if ! hash "git" &>/dev/null; then PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL git"; fi +if "$MAMBA_ROOT_PREFIX/micromamba" --version &>/dev/null; then umamba_exists="T"; fi + # (if necessary) install git and conda into a contained environment if [ "$PACKAGES_TO_INSTALL" != "" ]; then # download micromamba - if [ ! -e "$MAMBA_ROOT_PREFIX/micromamba" ]; then + if [ "$umamba_exists" == "F" ]; then echo "Downloading micromamba from $MICROMAMBA_DOWNLOAD_URL to $MAMBA_ROOT_PREFIX/micromamba" mkdir -p "$MAMBA_ROOT_PREFIX" From 33e25d924183429e960efa5c13d230c2efc200a8 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Sat, 29 Oct 2022 20:25:11 +0530 Subject: [PATCH 06/32] Deduce the filename in developer_console.sh instead of hardcoding it --- scripts/developer_console.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/developer_console.sh b/scripts/developer_console.sh index 3b2208ff..58344678 100755 --- a/scripts/developer_console.sh +++ b/scripts/developer_console.sh @@ -1,5 +1,7 @@ #!/bin/bash +cd "$(dirname "${BASH_SOURCE[0]}")" + if [ "$0" == "bash" ]; then echo "Opening Stable Diffusion UI - Developer Console.." echo "" @@ -35,5 +37,6 @@ if [ "$0" == "bash" ]; then echo "" else - bash --init-file developer_console.sh + file_name=$(basename "${BASH_SOURCE[0]}") + bash --init-file "$file_name" fi From d492d3f7387ea5ca31b6f79c30a0c21b63f783da Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Sun, 30 Oct 2022 00:22:01 -0700 Subject: [PATCH 07/32] Update main.js Fixing the parsing of Set and Permute operators in custom tags. --- ui/media/js/main.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index 3c5f27dc..b6510f3f 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -886,15 +886,15 @@ function getPrompts() { prompts = prompts.map(prompt => prompt.trim()) prompts = prompts.filter(prompt => prompt !== '') + if (activeTags.length > 0) { + const promptTags = activeTags.map(x => x.name).join(", ") + prompts = prompts.map((prompt) => `${prompt}, ${promptTags}`) + } + let promptsToMake = applySetOperator(prompts) promptsToMake = applyPermuteOperator(promptsToMake) - if (activeTags.length <= 0) { - return promptsToMake - } - - const promptTags = activeTags.map(x => x.name).join(", ") - return promptsToMake.map((prompt) => `${prompt}, ${promptTags}`) + return promptsToMake } function applySetOperator(prompts) { From f08a875cd2f958a17592bbb157aafaae5e991c58 Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Sun, 30 Oct 2022 00:26:53 -0700 Subject: [PATCH 08/32] Update main.js Fix parsing of Set and Permute operators in custom tags. --- ui/media/js/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/media/js/main.js b/ui/media/js/main.js index b6510f3f..aa571c6b 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -887,8 +887,8 @@ function getPrompts() { prompts = prompts.filter(prompt => prompt !== '') if (activeTags.length > 0) { - const promptTags = activeTags.map(x => x.name).join(", ") - prompts = prompts.map((prompt) => `${prompt}, ${promptTags}`) + const promptTags = activeTags.map(x => x.name).join(", ") + prompts = prompts.map((prompt) => `${prompt}, ${promptTags}`) } let promptsToMake = applySetOperator(prompts) From 053bce7a8ee021650b71f4183c7a96e187cef4d1 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Mon, 31 Oct 2022 19:05:57 +0530 Subject: [PATCH 09/32] Set the correct mimetype in the base64 image --- ui/sd_internal/runtime.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/sd_internal/runtime.py b/ui/sd_internal/runtime.py index 493e2618..e11b9576 100644 --- a/ui/sd_internal/runtime.py +++ b/ui/sd_internal/runtime.py @@ -685,11 +685,13 @@ def img_to_base64_str(img, output_format="PNG"): img.save(buffered, format=output_format) buffered.seek(0) img_byte = buffered.getvalue() - img_str = "data:image/png;base64," + base64.b64encode(img_byte).decode() + mime_type = "image/png" if output_format.lower() == "png" else "image/jpeg" + img_str = f"data:{mime_type};base64," + base64.b64encode(img_byte).decode() return img_str def base64_str_to_img(img_str): - img_str = img_str[len("data:image/png;base64,"):] + mime_type = "image/png" if img_str.startswith("data:image/png;") else "image/jpeg" + img_str = img_str[len(f"data:{mime_type};base64,"):] data = base64.b64decode(img_str) buffered = BytesIO(data) img = Image.open(buffered) From ea7006eec40b966a5f804d39c9bd52dde17940e7 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 2 Nov 2022 19:45:49 +0530 Subject: [PATCH 10/32] Set the PYTHONPATH before installation to prevent conda from knowing about any system-wide python installations (and skipping package installs due to that) --- scripts/on_sd_start.bat | 8 ++++++++ scripts/on_sd_start.sh | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index 3b7ed0ca..3df11d40 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -71,6 +71,8 @@ if exist "Open Developer Console.cmd" del "Open Developer Console.cmd" set TMP=%cd%\tmp set TEMP=%cd%\tmp + set PYTHONPATH=%cd%;%cd%\env\lib\site-packages + @call conda env create --prefix env -f environment.yaml || ( @echo. & echo "Error installing the packages necessary 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 @@ -108,6 +110,8 @@ set PATH=C:\Windows\System32;%PATH% set TMP=%cd%\tmp set TEMP=%cd%\tmp + set PYTHONPATH=%cd%;%cd%\env\lib\site-packages + @call pip install -e git+https://github.com/TencentARC/GFPGAN#egg=GFPGAN || ( @echo. & echo "Error installing the packages necessary for GFPGAN (Face Correction). 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 @@ -141,6 +145,8 @@ set PATH=C:\Windows\System32;%PATH% set TMP=%cd%\tmp set TEMP=%cd%\tmp + set PYTHONPATH=%cd%;%cd%\env\lib\site-packages + @call pip install -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan || ( @echo. & echo "Error installing the packages necessary for ESRGAN (Resolution Upscaling). 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 @@ -168,6 +174,8 @@ set PATH=C:\Windows\System32;%PATH% set TMP=%cd%\tmp set TEMP=%cd%\tmp + set PYTHONPATH=%cd%;%cd%\env\lib\site-packages + @call conda install -c conda-forge -y --prefix env uvicorn fastapi || ( echo "Error installing the packages necessary for Stable Diffusion UI. 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!" pause diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index 4bf5d79a..11d0d2e1 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -64,6 +64,7 @@ else # prevent conda from using packages from the user's home directory, to avoid conflicts export PYTHONNOUSERSITE=1 + export PYTHONPATH="$(pwd):$(pwd)/env/lib/site-packages" if conda env create --prefix env --force -f environment.yaml ; then echo "Installed. Testing.." @@ -99,6 +100,7 @@ else printf "\n\nDownloading packages necessary for GFPGAN (Face Correction)..\n" export PYTHONNOUSERSITE=1 + export PYTHONPATH="$(pwd):$(pwd)/env/lib/site-packages" if pip install -e git+https://github.com/TencentARC/GFPGAN#egg=GFPGAN ; then echo "Installed. Testing.." @@ -124,6 +126,7 @@ else printf "\n\nDownloading packages necessary for ESRGAN (Resolution Upscaling)..\n" export PYTHONNOUSERSITE=1 + export PYTHONPATH="$(pwd):$(pwd)/env/lib/site-packages" if pip install -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan ; then echo "Installed. Testing.." @@ -149,6 +152,7 @@ else printf "\n\nDownloading packages necessary for Stable Diffusion UI..\n\n" export PYTHONNOUSERSITE=1 + export PYTHONPATH="$(pwd):$(pwd)/env/lib/site-packages" if conda install -c conda-forge --prefix ./env -y uvicorn fastapi ; then echo "Installed. Testing.." From 63dcb8cfe180f28b23c1f125f207e429d3f2ab30 Mon Sep 17 00:00:00 2001 From: JeLuF Date: Thu, 3 Nov 2022 20:39:08 +0100 Subject: [PATCH 11/32] Add a link to the wiki to the "Help & Community" dropdown. --- ui/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/index.html b/ui/index.html index ea9a088a..d827ef62 100644 --- a/ui/index.html +++ b/ui/index.html @@ -24,6 +24,7 @@