darkstorm2150 commited on
Commit
ad5dde8
·
verified ·
1 Parent(s): 1eaf324

switched the entire code to verbose

Browse files

switching to complete verbose will isolate the issue.

Files changed (1) hide show
  1. app.py +76 -21
app.py CHANGED
@@ -3,48 +3,103 @@ from subprocess import getoutput
3
 
4
  # Welcome to the world of python madness!
5
 
6
- os.system(f"git clone https://github.com/darkstorm2150/stable-diffusion-webui /home/user/app/stable-diffusion-webui")
 
 
 
 
 
 
 
7
  os.chdir("/home/user/app/stable-diffusion-webui")
8
 
9
- os.system(f"wget -q https://github.com/camenduru/webui/raw/main/env_patch.py -O /home/user/app/env_patch.py")
 
 
 
10
  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")
 
 
11
  os.system(f"sed -i -e '/(modelmerger_interface, \"Checkpoint Merger\", \"modelmerger\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
 
 
12
  os.system(f"sed -i -e '/(train_interface, \"Train\", \"ti\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
 
 
13
  os.system(f"sed -i -e '/extensions_interface, \"Extensions\", \"extensions\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
 
 
14
  os.system(f"sed -i -e '/settings_interface, \"Settings\", \"settings\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
15
- 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''')
 
 
 
 
16
  os.system(f"sed -i -e 's/ show_progress=False,/ show_progress=True,/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
 
 
17
  os.system(f"sed -i -e 's/shared.demo.launch/shared.demo.queue().launch/g' /home/user/app/stable-diffusion-webui/webui.py")
18
- os.system(f"sed -i -e 's/inputs=\[component\],/&\\n queue=False,/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
19
- 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")
20
 
21
- # ----------------------------Please duplicate this space and delete this block if you don't want to see the extra header----------------------------
22
- os.system(f"wget -q https://github.com/camenduru/webui/raw/main/header_patch.py -O /home/user/app/header_patch.py")
23
- os.system(f"sed -i -e '/demo:/r /home/user/app/header_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py")
24
- # ---------------------------------------------------------------------------------------------------------------------------------------------------
 
25
 
26
 
27
 
 
 
 
28
 
 
 
 
 
 
 
 
29
  if "IS_SHARED_UI" in os.environ:
30
- os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-config.json -O /home/user/app/shared-config.json")
31
- os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-ui-config.json -O /home/user/app/shared-ui-config.json")
 
 
 
 
 
 
32
 
 
 
33
  os.system(f"wget -q {os.getenv('MODEL_LINK')} -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/{os.getenv('MODEL_NAME')}")
 
 
34
  os.system(f"wget -q {os.getenv('VAE_LINK')} -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/{os.getenv('VAE_NAME')}")
35
- os.system(f"wget -q {os.getenv('YAML_LINK')} -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/{os.getenv('YAML_NAME')}")
36
 
 
 
 
 
 
37
  os.system(f"python launch.py --force-enable-xformers --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")
38
  else:
39
- # Please duplicate this space and delete # character in front of the custom script you want to use or add here more custom scripts with same structure os.system(f"wget -q https://CUSTOM_SCRIPT_URL -O /home/user/app/stable-diffusion-webui/scripts/CUSTOM_SCRIPT_NAME.py")
40
- os.system(f"wget -q https://gist.github.com/camenduru/9ec5f8141db9902e375967e93250860f/raw/d0bcf01786f20107c329c03f8968584ee67be12a/run_n_times.py -O /home/user/app/stable-diffusion-webui/scripts/run_n_times.py")
 
 
 
 
 
 
 
41
 
42
- # Please duplicate this space and delete # character in front of the extension you want to use or add here more extensions with same structure os.system(f"git clone https://EXTENSION_GIT_URL /home/user/app/stable-diffusion-webui/extensions/EXTENSION_NAME")
43
- #os.system(f"git clone https://github.com/camenduru/stable-diffusion-webui-artists-to-study /home/user/app/stable-diffusion-webui/extensions/stable-diffusion-webui-artists-to-study")
44
- 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")
45
- 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")
46
 
47
- # ----------------------------Loading Protogen Model----------------------------
48
- 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")
 
49
 
50
- os.system(f"python launch.py --force-enable-xformers --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")
 
 
 
3
 
4
  # Welcome to the world of python madness!
5
 
6
+ # Debugging with Verbose mode on...
7
+
8
+ os.system(f'echo "Starting verbose diagnostic setup for stable-diffusion-webui..."')
9
+
10
+ os.system(f'echo "Cloning Stable Diffusion WebUI repository from darkstorm2150..."')
11
+ os.system(f"git clone https://github.com/darkstorm2150/stable-diffusion-webui /home/user/app/stable-diffusion-webui")
12
+
13
+ os.system(f'echo "Setting working directory to stable-diffusion-webui root folder..."')
14
  os.chdir("/home/user/app/stable-diffusion-webui")
15
 
16
+ os.system(f'echo "Downloading environment patch script from camenduru/webui..."')
17
+ os.system(f"wget -q https://github.com/camenduru/webui/raw/main/env_patch.py -O /home/user/app/env_patch.py")
18
+
19
+ os.system(f'echo "Patching modules/ui.py to import image_from_url_text from env_patch.py..."')
20
  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")
21
+
22
+ os.system(f'echo "Removing Checkpoint Merger tab from UI..."')
23
  os.system(f"sed -i -e '/(modelmerger_interface, \"Checkpoint Merger\", \"modelmerger\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
24
+
25
+ os.system(f'echo "Removing Training tab from UI..."')
26
  os.system(f"sed -i -e '/(train_interface, \"Train\", \"ti\"),/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
27
+
28
+ os.system(f'echo "Removing Extensions tab from UI..."')
29
  os.system(f"sed -i -e '/extensions_interface, \"Extensions\", \"extensions\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
30
+
31
+ os.system(f'echo "Removing Settings tab from UI..."')
32
  os.system(f"sed -i -e '/settings_interface, \"Settings\", \"settings\"/d' /home/user/app/stable-diffusion-webui/modules/ui.py")
33
+
34
+ os.system(f'echo "Fixing Gradio shadowRoot access in script.js for Hugging Face compatibility..."')
35
+ 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''')
36
+
37
+ os.system(f'echo "Enabling progress bars in UI for better user feedback..."')
38
  os.system(f"sed -i -e 's/ show_progress=False,/ show_progress=True,/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
39
+
40
+ os.system(f'echo "Modifying webui.py to enable queuing for async processing..."')
41
  os.system(f"sed -i -e 's/shared.demo.launch/shared.demo.queue().launch/g' /home/user/app/stable-diffusion-webui/webui.py")
 
 
42
 
43
+ os.system(f'echo "Disabling queuing for input components to reduce latency..."')
44
+ os.system(f"sed -i -e 's/inputs=\\[component\\],/&\\n queue=False,/g' /home/user/app/stable-diffusion-webui/modules/ui.py")
45
+
46
+ os.system(f'echo "Disabling queuing for token counter outputs..."')
47
+ 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")
48
 
49
 
50
 
51
+ # ----------------------------Patch UI Header for Hugging Face Spaces----------------------------
52
+ os.system(f'echo "Downloading header_patch.py to customize UI header banners..."')
53
+ os.system(f"wget -q https://github.com/camenduru/webui/raw/main/header_patch.py -O /home/user/app/header_patch.py")
54
 
55
+ os.system(f'echo "Injecting header_patch.py content into modules/ui.py under the demo section..."')
56
+ os.system(f"sed -i -e '/demo:/r /home/user/app/header_patch.py' /home/user/app/stable-diffusion-webui/modules/ui.py")
57
+ # ---------------------------------------------------------------------------------------------
58
+
59
+
60
+
61
+ # Handle shared vs. non-shared UI setup with verbose logging
62
  if "IS_SHARED_UI" in os.environ:
63
+ os.system(f'echo "IS_SHARED_UI IS ENABLED: Loading shared configurations..."')
64
+
65
+ # Download shared UI configuration files
66
+ os.system(f"echo 'Downloading shared-config.json for UI settings...'")
67
+ os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-config.json -O /home/user/app/shared-config.json")
68
+
69
+ os.system(f"echo 'Downloading shared-ui-config.json for layout preferences...'")
70
+ os.system(f"wget -q https://github.com/camenduru/webui/raw/main/shared-ui-config.json -O /home/user/app/shared-ui-config.json")
71
 
72
+ # Download models/configs from environment variables
73
+ os.system(f"echo 'Downloading Stable Diffusion model: {os.getenv(\"MODEL_NAME\")}...'")
74
  os.system(f"wget -q {os.getenv('MODEL_LINK')} -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/{os.getenv('MODEL_NAME')}")
75
+
76
+ os.system(f"echo 'Downloading VAE: {os.getenv(\"VAE_NAME\")}...'")
77
  os.system(f"wget -q {os.getenv('VAE_LINK')} -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/{os.getenv('VAE_NAME')}")
 
78
 
79
+ os.system(f"echo 'Downloading YAML config: {os.getenv(\"YAML_NAME\")}...'")
80
+ os.system(f"wget -q {os.getenv('YAML_LINK')} -O /home/user/app/stable-diffusion-webui/models/Stable-diffusion/{os.getenv('YAML_NAME')}")
81
+
82
+ # Launch WebUI with shared settings
83
+ os.system(f'echo "Starting WebUI with shared configurations..."')
84
  os.system(f"python launch.py --force-enable-xformers --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")
85
  else:
86
+ os.system(f'echo "IS_SHARED_UI IS DISABLED: Setting up custom environment..."')
87
+
88
+ # Download custom scripts
89
+ os.system(f'echo "Installing run_n_times.py script for batch processing..."')
90
+ os.system(f"wget -q https://gist.github.com/camenduru/9ec5f8141db9902e375967e93250860f/raw/d0bcf01786f20107c329c03f8968584ee67be12a/run_n_times.py -O /home/user/app/stable-diffusion-webui/scripts/run_n_times.py")
91
+
92
+ # Install extensions (commented lines can be activated by removing #)
93
+ os.system(f'echo "Installing image browser extension for managing outputs..."')
94
+ 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")
95
 
96
+ os.system(f'echo "Installing Deforum animation extension..."')
97
+ 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")
 
 
98
 
99
+ # Load Protogen model (example custom model)
100
+ os.system(f'echo "Downloading Protogen X3.4 Stable Diffusion model..."')
101
+ 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")
102
 
103
+ # Launch WebUI with custom settings
104
+ os.system(f'echo "Starting WebUI with custom configurations..."')
105
+ os.system(f"python launch.py --force-enable-xformers --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")