From 826e44a57abfc3bc7eaeb195289c80ed58053449 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Thu, 20 Apr 2023 08:21:35 -0400 Subject: [PATCH] +stable-diffusion-webui --- .../stable-diffusion-webui/gui.sh | 37 ++++++++++ .../stable-diffusion-webui/launch.py.patch | 8 +++ .../stable-diffusion-webui/package.yml | 67 +++++++++++++++++++ .../stable-diffusion-webui | 44 ++++++++++++ .../stable-diffusion-webui/webui-user.sh | 3 + 5 files changed, 159 insertions(+) create mode 100755 projects/github.com/AUTOMATIC1111/stable-diffusion-webui/gui.sh create mode 100644 projects/github.com/AUTOMATIC1111/stable-diffusion-webui/launch.py.patch create mode 100644 projects/github.com/AUTOMATIC1111/stable-diffusion-webui/package.yml create mode 100755 projects/github.com/AUTOMATIC1111/stable-diffusion-webui/stable-diffusion-webui create mode 100644 projects/github.com/AUTOMATIC1111/stable-diffusion-webui/webui-user.sh diff --git a/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/gui.sh b/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/gui.sh new file mode 100755 index 00000000..7b1707c7 --- /dev/null +++ b/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/gui.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +set -emx + +d="$(cd "$(dirname $0)"/.. && pwd)" + +"$d"/bin/stable-diffusion-webui & + +# poll into a HEAD request succeeds +while ! curl -Is http://127.0.0.1:7860 | grep -q "HTTP/1.1 200 OK"; do + sleep 1 +done + +# open the URL once the HEAD request succeeds +open http://127.0.0.1:7860 + +# tell tea/gui about it +echo '{"viewer": "http://127.0.0.1:7860"}' + +tea gum format < *NOTE* we obey \`XDG_\` variables for all the above if they are set + +> bugs reports to our [tracker](https://github.com/teaxyz/pantry/issues). thanks! + +enjoy! +EoMD + +fg diff --git a/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/launch.py.patch b/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/launch.py.patch new file mode 100644 index 00000000..454ee4d8 --- /dev/null +++ b/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/launch.py.patch @@ -0,0 +1,8 @@ +diff --color -u a/launch.py b/launch.py +--- a/launch.py 2023-04-19 15:28:49 ++++ b/launch.py 2023-04-19 15:28:56 +@@ -353,4 +353,3 @@ + + if __name__ == "__main__": + prepare_environment() +- start() diff --git a/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/package.yml b/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/package.yml new file mode 100644 index 00000000..ee3f1f75 --- /dev/null +++ b/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/package.yml @@ -0,0 +1,67 @@ +distributable: + url: https://github.com/AUTOMATIC1111/stable-diffusion-webui/archive/22bcc7be.tar.gz + strip-components: 1 + +versions: + - 2023.03.29 + +dependencies: + python.org: ~3.10 + +build: + dependencies: + pip.pypa.io: '*' + gnu.org/wget: '*' + protobuf.dev: '>=21' + rust-lang.org: ^1 # docs say this is needed but I’m not convinced… + git-scm.org: ^2 + script: + # don’t download the models RN + # --exit just installs deps and exits rather than boots the web server + - echo 'export COMMANDLINE_ARGS=" + --no-download-sd-model + --exit + $COMMANDLINE_ARGS"' > webui-user.sh + + # or it clones HEAD and uses that + - mkdir -p .git + + # installs python virtual-env + - ./webui.sh + + # move this installation into its prefix + - run: | + mv $OLDWD lib + mkdir tbin bin + mkdir $OLDWD # or breaks brewkit + working-directory: ${{prefix}} + + - cd {{prefix}} # change CWD for remainder of our execution + + # install our scripts and shims + - | + cp lib/props/webui-user.sh lib + cp lib/props/gui.sh tbin + cp lib/props/stable-diffusion-webui bin + + # delete our crap + - rm -rf lib/props lib/xyz.tea.* + + # we set this as a symlink to ~/.local/share/models in our stub scripts + - rm -rf lib/models/Stable-diffusion lib/extensions lib/outputs + + # we prebuilt everything, but also we must remove this so we can trim + # the final package from 2.3GB to ~1GB which we will do in the next steps + - | + sed -i.bak '355s|prepare_environment()||' lib/launch.py + rm lib/launch.py.bak + #FIXME ^^ please make a .patch work, I could not :/ + + - find . -name .git\* | xargs rm -rf + +provides: + - bin/stable-diffusion-webui + - tbin/gui.sh + +test: + stable-diffusion-webui --help diff --git a/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/stable-diffusion-webui b/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/stable-diffusion-webui new file mode 100755 index 00000000..1dfb2892 --- /dev/null +++ b/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/stable-diffusion-webui @@ -0,0 +1,44 @@ +#!/bin/sh + +set -ex + +export install_dir="$(cd "$(dirname $0)"/.. && pwd)" +export clone_dir=lib + +cd "$install_dir"/"$clone_dir" + +source ./webui-macos-env.sh +source ./webui-user.sh + +XDG="${XDG_DATA_HOME:-$HOME/.local/share}" + +mkdir -p "$XDG"/models/stable-diffusion "$XDG"/stable-diffusion-webui "$HOME/Documents/Stable Diffusion WEBUI" + +# store models somewhere shared +if ! test -d "$install_dir"/lib/models/Stable-diffusion; then + ln -sf "$XDG"/models/stable-diffusion "$install_dir"/lib/models/Stable-diffusion +fi + +# make extensions easily available and shared +if ! test -d "$install_dir"/lib/extensions; then + ln -sf "$XDG"/stable-diffusion-webui "$install_dir"/lib/extensions +fi + +# output files somewhere public +if ! test -d "$install_dir"/lib/outputs; then + ln -sf "$HOME/Documents/Stable Diffusion WEBUI" "$install_dir"/lib/outputs +fi + +CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}"/stable-diffusion-webui/config.json + +if ! test -f "$CONFIG"; then + mkdir -p "$(dirname "$CONFIG")" + cat << EoJSON > "$CONFIG" +{ + "img2img/Output directory/visible": true, + "img2img/Output directory/value": "" +} +EoJSON +fi + +python ./launch.py "$@" --ui-config-file="$CONFIG" diff --git a/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/webui-user.sh b/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/webui-user.sh new file mode 100644 index 00000000..375130c7 --- /dev/null +++ b/projects/github.com/AUTOMATIC1111/stable-diffusion-webui/webui-user.sh @@ -0,0 +1,3 @@ +#!/bin/bash +export install_dir="$(cd "$(dirname $0)"/.. && pwd)" +export clone_dir="lib"