|
import os |
|
from subprocess import getoutput |
|
|
|
|
|
|
|
|
|
os.system(f'echo "Checking Python Version"') |
|
os.system(f"python --version") |
|
|
|
os.system(f'echo "Starting verbose diagnostic setup for stable-diffusion-webui..."') |
|
|
|
|
|
os.system(f'echo "Cloning Stable Diffusion WebUI repository from darkstorm2150..."') |
|
os.system(f"git clone https://github.com/darkstorm2150/stable-diffusion-webui /home/user/app/stable-diffusion-webui") |
|
|
|
|
|
os.system(f'echo "Setting working directory to stable-diffusion-webui root folder..."') |
|
os.chdir("/home/user/app/stable-diffusion-webui") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
os.system(f'echo "Downloading environment patch script..."') |
|
os.system(f"wget https://raw.githubusercontent.com/darkstorm2150/webui/refs/heads/main/env_patch.py -O /home/user/app/env_patch.py") |
|
os.system(f"sed -i -e '/import image_from_url_text/r /home/user/app/env_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
os.system(f'echo "Fixing Gradio shadowRoot access in script.js for Hugging Face compatibility..."') |
|
os.system(f'''sed -i -e "s/document.getElementsByTagName('gradio-app')\\[0\\].shadowRoot/!!document.getElementsByTagName('gradio-app')[0].shadowRoot ? document.getElementsByTagName('gradio-app')[0].shadowRoot : document/g" /home/user/app/stable-diffusion-webui/script.js''') |
|
|
|
|
|
os.system(f'echo "Enabling progress bars in UI for better user feedback..."') |
|
os.system(f"sed -i -e 's/ show_progress=False,/ show_progress=True,/g' /home/user/app/stable-diffusion-webui/modules/ui.py") |
|
|
|
|
|
os.system(f'echo "Modifying webui.py to enable queuing for async processing..."') |
|
os.system(f"sed -i -e 's/shared.demo.launch/shared.demo.queue().launch/g' /home/user/app/stable-diffusion-webui/webui.py") |
|
|
|
os.system(f'echo "Disabling queuing for input components to reduce latency..."') |
|
os.system(f"sed -i -e 's/inputs=\\[component\\],/&\\n queue=False,/g' /home/user/app/stable-diffusion-webui/modules/ui.py") |
|
|
|
os.system(f'echo "Disabling queuing for token counter outputs..."') |
|
os.system(f"sed -i -e 's/outputs=\\[token_counter\\]/outputs=[token_counter], queue=False/g' /home/user/app/stable-diffusion-webui/modules/ui.py") |
|
|
|
|
|
|
|
|
|
os.system(f'echo "Downloading header_patch.py to customize UI header banners..."') |
|
os.system(f"wget https://raw.githubusercontent.com/darkstorm2150/webui/refs/heads/main/header_patch.py -O /home/user/app/header_patch.py") |
|
|
|
os.system(f'echo "Injecting header_patch.py content into modules/ui.py under the demo section..."') |
|
os.system(f"sed -i -e '/demo:/r /home/user/app/header_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py") |
|
|
|
|
|
|
|
|
|
|
|
if "IS_SHARED_UI" in os.environ: |
|
os.system(f'echo "IS_SHARED_UI IS ENABLED: Loading shared configurations..."') |
|
|
|
|
|
os.system(f"echo 'Downloading shared-config.json for UI settings...'") |
|
os.system(f"wget https://raw.githubusercontent.com/darkstorm2150/webui/refs/heads/main/shared-config.json -O /home/user/app/shared-config.json") |
|
|
|
os.system(f"echo 'Downloading shared-ui-config.json for layout preferences...'") |
|
os.system(f"wget https://raw.githubusercontent.com/darkstorm2150/webui/refs/heads/main/shared-ui-config.json -O /home/user/app/shared-ui-config.json") |
|
|
|
|
|
os.system(f'echo "Starting WebUI with shared configurations..."') |
|
os.system(f"python launch.py --disable-console-progressbars --enable-console-prompts --ui-config-file /home/user/app/shared-ui-config.json --ui-settings-file /home/user/app/shared-config.json --cors-allow-origins huggingface.co,hf.space --no-progressbar-hiding") |
|
else: |
|
os.system(f'echo "IS_SHARED_UI IS DISABLED: Setting up custom environment..."') |
|
|
|
|
|
os.system(f'echo "Installing run_n_times.py script for batch processing..."') |
|
os.system(f"wget https://raw.githubusercontent.com/darkstorm2150/webui/refs/heads/main/run_n_times.py -O /home/user/app/stable-diffusion-webui/scripts/run_n_times.py") |
|
|
|
|
|
os.system(f'echo "Installing image browser extension for managing outputs..."') |
|
os.system(f"git clone https://github.com/yfszzx/stable-diffusion-webui-images-browser /home/user/app/stable-diffusion-webui/extensions/stable-diffusion-webui-images-browser") |
|
|
|
os.system(f'echo "Installing Deforum animation extension..."') |
|
os.system(f"git clone https://github.com/deforum-art/deforum-for-automatic1111-webui /home/user/app/stable-diffusion-webui/extensions/deforum-for-automatic1111-webui") |
|
|
|
|
|
os.system(f'echo "Downloading Protogen X3.4 Stable Diffusion model..."') |
|
os.system(f"wget -q https://huggingface.co/darkstorm2150/Protogen_x3.4_Official_Release/resolve/main/ProtoGen_X3.4.safetensors -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/ProtoGen_X3.4.safetensors") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
os.system(f'echo "Installing build dependencies..."') |
|
os.system(f'pip install ninja packaging wheel') |
|
os.system(f'apt-get update && apt-get install -y build-essential cmake git') |
|
|
|
|
|
os.system(f'echo "Cloning xformers repo..."') |
|
os.system(f'git clone https://github.com/facebookresearch/xformers.git /home/user/app/xformers') |
|
os.system("cd /home/user/app/xformers && git submodule update --init --recursive") |
|
|
|
|
|
os.chdir('/home/user/app/xformers') |
|
os.system('pip install --no-cache-dir -e .') |
|
|
|
|
|
os.system(f'echo "Verifying NumPy and PyTorch..."') |
|
|
|
os.system("python -c 'import numpy; print(\"NumPy:\", numpy.__version__)'") |
|
os.system("python -c 'import torch; print(\"PyTorch:\", torch.__version__)'") |
|
|
|
|
|
os.system("python -c 'import xformers; print(\"xformers version:\", xformers.__version__)'") |
|
|
|
|
|
os.system(f'echo "Starting WebUI..."') |
|
|
|
|
|
os.system(f'pip uninstall -y torch torchvision xformers') |
|
os.system(f'pip install torch==2.7.1+cu126 torchvision==0.18.1+cu126 --extra-index-url https://download.pytorch.org/whl/cu126') |
|
os.system(f'pip install xformers==0.0.32+0f0bb9d9.d20250720 --extra-index-url https://download.pytorch.org/whl/cu126') |
|
|
|
os.system(f'pip install -U ninja cmake pybind11') |
|
|
|
|
|
os.chdir('/home/user/app/stable-diffusion-webui') |
|
os.system("python launch.py --ui-config-file /home/user/app/shared-ui-config.json --ui-settings-file /home/user/app/shared-config.json --disable-console-progressbars --enable-console-prompts --cors-allow-origins huggingface.co,hf.space --no-progressbar-hiding --api --skip-torch-cuda-test") |