launch multiple auto's webui instances
Last active
November 18, 2022 14:08
-
-
Save toriato/ff0956309bf9819c468f7286629fbe98 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
shopt -s globstar | |
shopt -s nullglob | |
[[ "${TRACE-0}" == "1" ]] && set -o xtrace | |
REPO_DIR="repos/public" | |
PATCHE_DIR="patches/public" | |
LAUNCH_ARGS=( | |
--theme dark | |
# features | |
--gradio-img2img-tool color-sketch | |
--deepdanbooru | |
# foolproof | |
--freeze-settings | |
--hide-ui-dir-config | |
--disable-console-progressbars | |
# optimize memory usage on attention | |
--xformers | |
# mixed precision? | |
# https://tutorials.pytorch.kr/recipes/recipes/amp_recipe.html#automatic-mixed-precision | |
--precision autocast | |
) | |
pwd=$(pwd) | |
# venv 적용하기 | |
source .venv/bin/activate | |
# 종속 프로그램 설치 | |
apt -qq update | |
which ffmpeg || apt -qq install -y ffmpeg | |
# 허깅페이스 모델 캐시 디렉터리 심볼릭 링크 만들기 | |
mkdir -p cache/huggingface ~/.cache | |
ln -sf "$(pwd)/cache/huggingface" ~/.cache/huggingface | |
# 레포지토리 없다면 클론하기 | |
if [[ ! -d "$REPO_DIR/.git" ]]; then | |
echo "Missing main repository, cloning..." | |
rm -rf "$REPO_DIR" | |
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git "$REPO_DIR" | |
fi | |
# 종속 패키지 설치 | |
(cd "$REPO_DIR" && python launch.py --exit) | |
# 프로세스 실행 | |
(trap 'kill 0' SIGINT;\ | |
# | |
# reverse ssh tunneling | |
(ssh -NT \ | |
-R48400:127.0.0.1:48400 \ | |
-R48401:127.0.0.1:48401 \ | |
-R48402:127.0.0.1:48402 \ | |
-R48500:127.0.0.1:48500 \ | |
-R48600:127.0.0.1:48600 \ | |
-R48601:127.0.0.1:48601 \ | |
-o ExitOnForwardFailure=yes \ | |
-o StrictHostKeyChecking=accept-new \ | |
-i ./tools/ssh/key_ed25519 \ | |
-p 22491 \ | |
[email protected] \ | |
) & \ | |
# | |
# full-1 | |
(cd "$REPO_DIR" && \ | |
python -c 'import webui; webui.webui()' \ | |
--port 48400 \ | |
--ui-settings-file "$pwd/configs/public/full-1.json" \ | |
--ui-config-file "$pwd/configs/public/ui/full-1.json" \ | |
--ckpt "/storage/models/Stable-diffusion/nai/animefull-final-pruned.ckpt" \ | |
--vae-path "/storage/models/VAE/nai/animevae.pt" \ | |
${LAUNCH_ARGS[@]} \ | |
) & \ | |
# # | |
# # full-2 | |
# (cd "$REPO_DIR" && \ | |
# python -c 'import webui; webui.webui()' \ | |
# --port 48401 \ | |
# --ui-settings-file "$pwd/configs/public/full-2.json" \ | |
# --ui-config-file "$pwd/configs/public/ui/full-2.json" \ | |
# --ckpt "/storage/models/Stable-diffusion/nai/animefull-final-pruned.ckpt" \ | |
# --vae-path "/storage/models/VAE/nai/animevae.pt" \ | |
# ${LAUNCH_ARGS[@]} \ | |
# ) & \ | |
# # | |
# # full-3 | |
# (cd "$REPO_DIR" && \ | |
# python -c 'import webui; webui.webui()' \ | |
# --port 48402 \ | |
# --ui-settings-file "$pwd/configs/public/full-3.json" \ | |
# --ui-config-file "$pwd/configs/public/ui/full-3.json" \ | |
# --ckpt "/storage/models/Stable-diffusion/nai/animefull-final-pruned.ckpt" \ | |
# --vae-path "/storage/models/VAE/nai/animevae.pt" \ | |
# ${LAUNCH_ARGS[@]} \ | |
# ) & \ | |
# | |
# sfw-1 | |
(cd "$REPO_DIR" && \ | |
python -c 'import webui; webui.webui()' \ | |
--port 48500 \ | |
--ui-settings-file "$pwd/configs/public/sfw-1.json" \ | |
--ui-config-file "$pwd/configs/public/ui/sfw-1.json" \ | |
--ckpt "/storage/models/Stable-diffusion/nai/animesfw-final-pruned.ckpt" \ | |
--vae-path "/storage/models/VAE/nai/animevae.pt" \ | |
${LAUNCH_ARGS[@]} \ | |
) & \ | |
# | |
# anything-1 | |
(cd "$REPO_DIR" && \ | |
python -c 'import webui; webui.webui()' \ | |
--port 48600 \ | |
--ui-settings-file "$pwd/configs/public/anything-1.json" \ | |
--ui-config-file "$pwd/configs/public/ui/anything-1.json" \ | |
--ckpt "/storage/models/Stable-diffusion/Anything-3-0-ema-pruned.ckpt" \ | |
--vae-path "/storage/models/VAE/nai/animevae.pt" \ | |
${LAUNCH_ARGS[@]} \ | |
) & \ | |
# | |
# anything-2 | |
(cd "$REPO_DIR" && \ | |
python -c 'import webui; webui.webui()' \ | |
--port 48601 \ | |
--ui-settings-file "$pwd/configs/public/anything-2.json" \ | |
--ui-config-file "$pwd/configs/public/ui/anything-2.json" \ | |
--ckpt "/storage/models/Stable-diffusion/Anything-3-0-ema-pruned.ckpt" \ | |
--vae-path "/storage/models/VAE/nai/animevae.pt" \ | |
${LAUNCH_ARGS[@]} \ | |
) & \ | |
wait) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
shopt -s globstar | |
shopt -s nullglob | |
[[ "${TRACE-0}" == "1" ]] && set -o xtrace | |
pwd=$(pwd) | |
target=${1-public} | |
# venv 적용하기 | |
source .venv/bin/activate | |
# 레포지토리 없다면 클론하기 | |
if [[ ! -d "$REPO_DIR/.git" ]]; then | |
echo "Missing main repository, cloning..." | |
rm -rf "$REPO_DIR" | |
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git "$REPO_DIR" | |
fi | |
# 레포지토리 업데이트 | |
echo "Updating main repository..." | |
(cd "repos/$target" && git reset --hard && git pull) | |
# 확장 기능 업데이트 | |
echo "Updating extension repositories..." | |
find "repos/$target/extensions" -name .git -type d -prune | while read path; do | |
path=$(realpath "$path/../") | |
echo "$path" | |
(cd "$path" && git reset --hard && git pull) | |
done | |
# 파일 패치 | |
if [[ -d "patches/$target" ]]; then | |
echo "Patching..." | |
pushd patches/$target | |
for path in **/*; do | |
source_path="$pwd/repos/$target/$path" | |
[[ -d "$path" ]] && continue # 디렉터리라면 무시하기 | |
[[ "$path" == *.patch ]] && continue # 패치 파일이라면 무시하기 | |
# 패치 파일이 비어 있다면 원본 파일 제거하기 | |
if [[ ! -s "$path" ]]; then | |
echo "remove: $path" | |
rm "$source_path" | |
continue | |
fi | |
# 파일에 차이가 존재하면 종료 | |
if ! diff "$source_path" "$path"; then | |
echo "copy: $path" | |
cp $path $source_path | |
fi | |
done | |
popd | |
fi | |
# 자바스크립트 통합 | |
echo "Merging multiple javascript files into one..." | |
merged_js_file=$(mktemp) | |
# order matter? | |
cat repos/$target/script.js >> $merged_js_file | |
for p in repos/$target/javascript/**/*.js; do cat $p >> $merged_js_file; rm $p; done | |
for p in repos/$target/extensions/**/*.js; do cat $p >> $merged_js_file; rm $p; done | |
echo "Minifying merged javascript..." | |
python -m rjsmin < $merged_js_file > repos/$target/script.js | |
rm $merged_js_file | |
rm -rf "repos/$target/models" | |
ln -sf /storage/models "repos/$target/models" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment