testing different pipeline
Browse files
app.py
CHANGED
|
@@ -4,32 +4,30 @@ from subprocess import getoutput
|
|
| 4 |
# Welcome to the world of python madness!
|
| 5 |
|
| 6 |
# Debugging with Verbose mode on...
|
| 7 |
-
|
| 8 |
os.system(f'echo "Checking Python Version"')
|
| 9 |
os.system(f"python --version")
|
| 10 |
|
| 11 |
-
os.system(f'echo "Installing xformers 0.0.15.dev"')
|
| 12 |
-
os.system(f"pip install -q https://huggingface.co/vorstcavry/xformers/resolve/main/xformers-0.0.15.dev0%2B1515f77.d20221130-cp38-cp38-linux_x86_64.whl")
|
| 13 |
-
|
| 14 |
os.system(f'echo "Starting verbose diagnostic setup for stable-diffusion-webui..."')
|
| 15 |
|
|
|
|
| 16 |
os.system(f'echo "Cloning Stable Diffusion WebUI repository from darkstorm2150..."')
|
| 17 |
os.system(f"git clone https://github.com/darkstorm2150/stable-diffusion-webui /home/user/app/stable-diffusion-webui")
|
| 18 |
|
|
|
|
| 19 |
os.system(f'echo "Setting working directory to stable-diffusion-webui root folder..."')
|
| 20 |
os.chdir("/home/user/app/stable-diffusion-webui")
|
| 21 |
|
| 22 |
-
#
|
| 23 |
os.system(f'echo "Removing numpy and torch from requirements.txt to prevent version conflicts..."')
|
| 24 |
os.system(f"sed -i '/numpy/d' /home/user/app/stable-diffusion-webui/requirements.txt")
|
| 25 |
os.system(f"sed -i '/torch/d' /home/user/app/stable-diffusion-webui/requirements.txt")
|
| 26 |
|
| 27 |
-
|
|
|
|
| 28 |
os.system(f"wget https://github.com/camenduru/webui/raw/main/env_patch.py -O /home/user/app/env_patch.py")
|
| 29 |
-
|
| 30 |
-
os.system(f'echo "Patching modules/ui.py to import image_from_url_text from env_patch.py..."')
|
| 31 |
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")
|
| 32 |
|
|
|
|
| 33 |
os.system(f'echo "Removing Checkpoint Merger tab from UI..."')
|
| 34 |
os.system(f"sed -i -e '/(modelmerger_interface, \"Checkpoint Merger\", \"modelmerger\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 35 |
|
|
@@ -42,12 +40,15 @@ os.system(f"sed -i -e '/extensions_interface, \"Extensions\", \"extensions\"/d'
|
|
| 42 |
os.system(f'echo "Removing Settings tab from UI..."')
|
| 43 |
os.system(f"sed -i -e '/settings_interface, \"Settings\", \"settings\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 44 |
|
|
|
|
| 45 |
os.system(f'echo "Fixing Gradio shadowRoot access in script.js for Hugging Face compatibility..."')
|
| 46 |
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''')
|
| 47 |
|
|
|
|
| 48 |
os.system(f'echo "Enabling progress bars in UI for better user feedback..."')
|
| 49 |
os.system(f"sed -i -e 's/ show_progress=False,/ show_progress=True,/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 50 |
|
|
|
|
| 51 |
os.system(f'echo "Modifying webui.py to enable queuing for async processing..."')
|
| 52 |
os.system(f"sed -i -e 's/shared.demo.launch/shared.demo.queue().launch/g' /home/user/app/stable-diffusion-webui/webui.py")
|
| 53 |
|
|
@@ -101,27 +102,22 @@ else:
|
|
| 101 |
os.system(f'echo "Downloading Protogen X3.4 Stable Diffusion model..."')
|
| 102 |
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")
|
| 103 |
|
| 104 |
-
#
|
| 105 |
-
os.system(f'echo "
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
os.system(f"pip install --no-cache-dir numpy==1.26.4")
|
| 107 |
|
| 108 |
-
# Install
|
| 109 |
-
os.system(f'echo "Installing PyTorch
|
| 110 |
os.system(f"pip install torch==2.1.2+cu121 torchvision==0.16.2+cu121 --extra-index-url https://download.pytorch.org/whl/cu121 ")
|
| 111 |
|
| 112 |
-
|
| 113 |
-
os.system(f
|
| 114 |
-
os.system(f"pip install xformers==0.0.25")
|
| 115 |
-
|
| 116 |
-
# Remove NumPy 2.x (if pulled in by other packages)
|
| 117 |
-
os.system(f'echo "Removing NumPy 2.x (if present)..."')
|
| 118 |
-
os.system(f"pip uninstall -y numpy && pip install --no-cache-dir numpy==1.26.4")
|
| 119 |
-
|
| 120 |
-
# Reinstall xformers to ensure compatibility
|
| 121 |
-
os.system(f'echo "Reinstalling xformers to ensure NumPy 1.26.4 compatibility..."')
|
| 122 |
-
os.system(f"pip uninstall -y xformers && pip install --no-cache-dir xformers==0.0.25")
|
| 123 |
|
| 124 |
-
#
|
| 125 |
os.system(f'echo "Verifying NumPy, PyTorch, and xformers versions..."')
|
| 126 |
os.system(f"python -c 'import numpy; print(numpy.__version__)'")
|
| 127 |
os.system(f"python -c 'import torch; print(torch.__version__)'")
|
|
|
|
| 4 |
# Welcome to the world of python madness!
|
| 5 |
|
| 6 |
# Debugging with Verbose mode on...
|
|
|
|
| 7 |
os.system(f'echo "Checking Python Version"')
|
| 8 |
os.system(f"python --version")
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
os.system(f'echo "Starting verbose diagnostic setup for stable-diffusion-webui..."')
|
| 11 |
|
| 12 |
+
# Clone repository
|
| 13 |
os.system(f'echo "Cloning Stable Diffusion WebUI repository from darkstorm2150..."')
|
| 14 |
os.system(f"git clone https://github.com/darkstorm2150/stable-diffusion-webui /home/user/app/stable-diffusion-webui")
|
| 15 |
|
| 16 |
+
# Set working directory
|
| 17 |
os.system(f'echo "Setting working directory to stable-diffusion-webui root folder..."')
|
| 18 |
os.chdir("/home/user/app/stable-diffusion-webui")
|
| 19 |
|
| 20 |
+
# clean requirements.txt
|
| 21 |
os.system(f'echo "Removing numpy and torch from requirements.txt to prevent version conflicts..."')
|
| 22 |
os.system(f"sed -i '/numpy/d' /home/user/app/stable-diffusion-webui/requirements.txt")
|
| 23 |
os.system(f"sed -i '/torch/d' /home/user/app/stable-diffusion-webui/requirements.txt")
|
| 24 |
|
| 25 |
+
# Patch environment
|
| 26 |
+
os.system(f'echo "Downloading environment patch script..."')
|
| 27 |
os.system(f"wget https://github.com/camenduru/webui/raw/main/env_patch.py -O /home/user/app/env_patch.py")
|
|
|
|
|
|
|
| 28 |
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")
|
| 29 |
|
| 30 |
+
# UI customization
|
| 31 |
os.system(f'echo "Removing Checkpoint Merger tab from UI..."')
|
| 32 |
os.system(f"sed -i -e '/(modelmerger_interface, \"Checkpoint Merger\", \"modelmerger\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 33 |
|
|
|
|
| 40 |
os.system(f'echo "Removing Settings tab from UI..."')
|
| 41 |
os.system(f"sed -i -e '/settings_interface, \"Settings\", \"settings\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 42 |
|
| 43 |
+
# Gradio shadowRoot fix
|
| 44 |
os.system(f'echo "Fixing Gradio shadowRoot access in script.js for Hugging Face compatibility..."')
|
| 45 |
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''')
|
| 46 |
|
| 47 |
+
# Progress bar settings
|
| 48 |
os.system(f'echo "Enabling progress bars in UI for better user feedback..."')
|
| 49 |
os.system(f"sed -i -e 's/ show_progress=False,/ show_progress=True,/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
|
| 50 |
|
| 51 |
+
# Queue settings
|
| 52 |
os.system(f'echo "Modifying webui.py to enable queuing for async processing..."')
|
| 53 |
os.system(f"sed -i -e 's/shared.demo.launch/shared.demo.queue().launch/g' /home/user/app/stable-diffusion-webui/webui.py")
|
| 54 |
|
|
|
|
| 102 |
os.system(f'echo "Downloading Protogen X3.4 Stable Diffusion model..."')
|
| 103 |
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")
|
| 104 |
|
| 105 |
+
# Critical dependency installation sequence
|
| 106 |
+
os.system(f'echo "starting dependency cleanup..."')
|
| 107 |
+
os.system(f'pip cache purge')
|
| 108 |
+
|
| 109 |
+
# Force NumPy 1.26.4 first
|
| 110 |
+
os.system(f'echo "Installing NumPy 1.26.4..."')
|
| 111 |
os.system(f"pip install --no-cache-dir numpy==1.26.4")
|
| 112 |
|
| 113 |
+
# Install PyTorch + xformers with CUDA compatibility
|
| 114 |
+
os.system(f'echo "Installing PyTorch..."')
|
| 115 |
os.system(f"pip install torch==2.1.2+cu121 torchvision==0.16.2+cu121 --extra-index-url https://download.pytorch.org/whl/cu121 ")
|
| 116 |
|
| 117 |
+
os.system(f'echo "Installing xformers..."')
|
| 118 |
+
os.system(f"pip install --no-cache-dir xformers==0.0.25 --extra-index-url https://download.pytorch.org/whl/cu118")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
+
# Final verification
|
| 121 |
os.system(f'echo "Verifying NumPy, PyTorch, and xformers versions..."')
|
| 122 |
os.system(f"python -c 'import numpy; print(numpy.__version__)'")
|
| 123 |
os.system(f"python -c 'import torch; print(torch.__version__)'")
|