Create webui_setup.sh
Browse files- webui_setup.sh +54 -0
webui_setup.sh
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Set the directory for WEBUI
|
| 4 |
+
WEBUI_HOME_DIR="$HOME/webui"
|
| 5 |
+
|
| 6 |
+
# Clone the repository, the hard way (to allow existing linked folder of webui)
|
| 7 |
+
# Check if .git directory exists in WEBUI_HOME_DIR
|
| 8 |
+
if [ ! -d "${WEBUI_HOME_DIR}/.git" ]; then
|
| 9 |
+
# Clone the repository, the hard way (to allow existing linked folder of webui)
|
| 10 |
+
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui /tmp/webui_temp
|
| 11 |
+
mv /tmp/webui_temp/* /tmp/webui_temp/.git* "${WEBUI_HOME_DIR}"
|
| 12 |
+
rm -rf /tmp/webui_temp
|
| 13 |
+
fi
|
| 14 |
+
|
| 15 |
+
# Check if it's the first time setup
|
| 16 |
+
if [ ! -f "ui-config.json" ]; then
|
| 17 |
+
|
| 18 |
+
# Update and install perftools
|
| 19 |
+
sudo apt-get update
|
| 20 |
+
sudo apt-get install --no-install-recommends google-perftools -y
|
| 21 |
+
|
| 22 |
+
cd "${WEBUI_HOME_DIR}"
|
| 23 |
+
# If ui-config.json does not exist, it's the first time setup
|
| 24 |
+
# Adding flags
|
| 25 |
+
sed -i 's/#export COMMANDLINE_ARGS=""/export COMMANDLINE_ARGS="--share --no-half-vae --listen --api --xformers --no-download-sd-model --disable-nan-check"/' webui-user.sh
|
| 26 |
+
wget https://huggingface.co/kiriyamaX/webui-configs/resolve/main/config_sdxl_v2.json -O config.json
|
| 27 |
+
wget https://huggingface.co/kiriyamaX/webui-configs/resolve/main/ui-config_sdxl_v2.json -O ui-config.json
|
| 28 |
+
|
| 29 |
+
# Install extensions
|
| 30 |
+
cd extensions
|
| 31 |
+
git clone https://github.com/picobyte/stable-diffusion-webui-wd14-tagger
|
| 32 |
+
git clone https://github.com/AlUlkesh/stable-diffusion-webui-images-browser
|
| 33 |
+
git clone https://github.com/hako-mikan/sd-webui-supermerger
|
| 34 |
+
git clone https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111
|
| 35 |
+
git clone https://github.com/arenatemp/stable-diffusion-webui-model-toolkit
|
| 36 |
+
|
| 37 |
+
# ========== SECURITY: disallow gradio visiting models folder =============
|
| 38 |
+
WEBUI_PY_FILE="${WEBUI_HOME_DIR}/webui.py"
|
| 39 |
+
|
| 40 |
+
# Line to be added
|
| 41 |
+
# https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/cf2772fab0af5573da775e7437e6acdca424f26e/webui.py#L79C1-L96C10
|
| 42 |
+
NEW_LINE=" blocked_paths=[\"/home/ubuntu/webui/models\"],"
|
| 43 |
+
|
| 44 |
+
# Check if the line already exists to avoid duplicating it
|
| 45 |
+
if ! grep -q "blocked_paths" "$WEBUI_PY_FILE"; then
|
| 46 |
+
# Use sed to insert the line after the pattern
|
| 47 |
+
sed -i "/app_kwargs={/i $NEW_LINE" "$WEBUI_PY_FILE"
|
| 48 |
+
fi
|
| 49 |
+
fi
|
| 50 |
+
|
| 51 |
+
cd "${WEBUI_HOME_DIR}"
|
| 52 |
+
./webui.sh
|
| 53 |
+
|
| 54 |
+
|