hz
Browse files- files_cells/notebooks/en/auto_cleaner_en.ipynb +4 -5
- files_cells/notebooks/en/downloading_en.ipynb +38 -36
- files_cells/notebooks/en/widgets_en.ipynb +1 -2
- files_cells/notebooks/ru/auto_cleaner_ru.ipynb +4 -5
- files_cells/notebooks/ru/downloading_ru.ipynb +38 -36
- files_cells/notebooks/ru/widgets_ru.ipynb +1 -2
- files_cells/python/en/auto_cleaner_en.py +4 -5
- files_cells/python/en/downloading_en.py +38 -36
- files_cells/python/en/widgets_en.py +1 -2
- files_cells/python/ru/auto_cleaner_ru.py +4 -5
- files_cells/python/ru/downloading_ru.py +38 -36
- files_cells/python/ru/widgets_ru.py +1 -2
files_cells/notebooks/en/auto_cleaner_en.ipynb
CHANGED
@@ -23,8 +23,7 @@
|
|
23 |
"\n",
|
24 |
"import os\n",
|
25 |
"import time\n",
|
26 |
-
"
|
27 |
-
"from ipywidgets import Label, Button, VBox, HBox\n",
|
28 |
"from IPython.display import display, HTML, Javascript\n",
|
29 |
"\n",
|
30 |
"\n",
|
@@ -53,7 +52,7 @@
|
|
53 |
"}\n",
|
54 |
"\n",
|
55 |
"\"\"\" functions \"\"\"\n",
|
56 |
-
"def clean_directory(directory):\n",
|
57 |
" deleted_files = 0\n",
|
58 |
"\n",
|
59 |
" for root, dirs, files in os.walk(directory):\n",
|
@@ -62,7 +61,7 @@
|
|
62 |
"\n",
|
63 |
" if file.endswith(\".txt\"):\n",
|
64 |
" continue\n",
|
65 |
-
" if file.endswith((\".safetensors\", \".pt\"
|
66 |
" deleted_files += 1\n",
|
67 |
"\n",
|
68 |
" os.remove(file_path)\n",
|
@@ -84,7 +83,7 @@
|
|
84 |
"\n",
|
85 |
" for option in selected_cleaners:\n",
|
86 |
" if option in directories:\n",
|
87 |
-
" deleted_files_dict[option] = clean_directory(directories[option])\n",
|
88 |
"\n",
|
89 |
" output.clear_output()\n",
|
90 |
"\n",
|
|
|
23 |
"\n",
|
24 |
"import os\n",
|
25 |
"import time\n",
|
26 |
+
"from ipywidgets import widgets\n",
|
|
|
27 |
"from IPython.display import display, HTML, Javascript\n",
|
28 |
"\n",
|
29 |
"\n",
|
|
|
52 |
"}\n",
|
53 |
"\n",
|
54 |
"\"\"\" functions \"\"\"\n",
|
55 |
+
"def clean_directory(directory, directory_type):\n",
|
56 |
" deleted_files = 0\n",
|
57 |
"\n",
|
58 |
" for root, dirs, files in os.walk(directory):\n",
|
|
|
61 |
"\n",
|
62 |
" if file.endswith(\".txt\"):\n",
|
63 |
" continue\n",
|
64 |
+
" if file.endswith((\".safetensors\", \".pt\")) or directory_type == \"Images\":\n",
|
65 |
" deleted_files += 1\n",
|
66 |
"\n",
|
67 |
" os.remove(file_path)\n",
|
|
|
83 |
"\n",
|
84 |
" for option in selected_cleaners:\n",
|
85 |
" if option in directories:\n",
|
86 |
+
" deleted_files_dict[option] = clean_directory(directories[option], option)\n",
|
87 |
"\n",
|
88 |
" output.clear_output()\n",
|
89 |
"\n",
|
files_cells/notebooks/en/downloading_en.ipynb
CHANGED
@@ -39,6 +39,7 @@
|
|
39 |
"\n",
|
40 |
"os.chdir(root_path)\n",
|
41 |
"\n",
|
|
|
42 |
"# ============ loading settings V4 =============\n",
|
43 |
"def load_settings(path):\n",
|
44 |
" if os.path.exists(path):\n",
|
@@ -94,11 +95,10 @@
|
|
94 |
" subprocess.run(install_cmd, shell=True, capture_output=True)\n",
|
95 |
"\n",
|
96 |
" # Additional specific packages\n",
|
97 |
-
" with capture.capture_output()
|
98 |
" !curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}\n",
|
99 |
" !curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl\n",
|
100 |
" !curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.32/zrok_0.4.32_linux_amd64.tar.gz && tar -xzf zrok_0.4.32_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.32_linux_amd64.tar.gz\n",
|
101 |
-
" del cap\n",
|
102 |
"\n",
|
103 |
" clear_output()\n",
|
104 |
"\n",
|
@@ -113,23 +113,33 @@
|
|
113 |
"\n",
|
114 |
"# =================== OTHER ====================\n",
|
115 |
"# Setup Timer\n",
|
116 |
-
"
|
117 |
-
"
|
118 |
-
"
|
119 |
-
"
|
120 |
-
"
|
121 |
-
"
|
122 |
-
"
|
123 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
" if directory_path and os.path.exists(directory_path):\n",
|
125 |
" try:\n",
|
126 |
" shutil.rmtree(directory_path)\n",
|
127 |
" except Exception:\n",
|
128 |
" !rm -rf {directory_path}\n",
|
129 |
"\n",
|
130 |
-
"
|
131 |
-
"temporarily_dir = f'{root_path}/temp_dir'\n",
|
132 |
-
"\n",
|
133 |
"def copy_items_with_replace(src_base, dst_base):\n",
|
134 |
" items_to_copy = [\n",
|
135 |
" 'embeddings',\n",
|
@@ -140,14 +150,13 @@
|
|
140 |
" ]\n",
|
141 |
"\n",
|
142 |
" print(\"⌚ Moving files...\", end='')\n",
|
143 |
-
" time.sleep(1)\n",
|
144 |
" for item in items_to_copy:\n",
|
145 |
" src = os.path.join(src_base, item)\n",
|
146 |
" dst = os.path.join(dst_base, item)\n",
|
147 |
"\n",
|
148 |
" if os.path.exists(src):\n",
|
149 |
" if os.path.exists(dst):\n",
|
150 |
-
"
|
151 |
" os.makedirs(os.path.dirname(dst), exist_ok=True)\n",
|
152 |
" shutil.move(src, dst)\n",
|
153 |
" print(\"\\r🔥 Files moved!\" + \" \"*15)\n",
|
@@ -166,40 +175,39 @@
|
|
166 |
" start_install = time.time()\n",
|
167 |
" print(f\"⌚ Unpacking Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...\", end='')\n",
|
168 |
"\n",
|
169 |
-
" with capture.capture_output()
|
170 |
" download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip\"\n",
|
171 |
" if UI == 'Forge':\n",
|
172 |
" download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip\"\n",
|
173 |
"\n",
|
174 |
-
" aria2_args = \"--console-log-level=error -c -x 16 -s 16 -k 1M\"\n",
|
175 |
" zip_path = f\"{root_path}/repo.zip\"\n",
|
176 |
-
" !aria2c
|
177 |
" !unzip -q -o {zip_path} -d {webui_path}\n",
|
178 |
" !rm -rf {zip_path}\n",
|
179 |
"\n",
|
180 |
-
"
|
181 |
-
" del cap\n",
|
182 |
"\n",
|
183 |
" install_time = time.time() - start_install\n",
|
184 |
" minutes, seconds = divmod(int(install_time), 60)\n",
|
185 |
" print(f\"\\r🚀 Unpacking complete! For {minutes:02}:{seconds:02} ⚡\" + \" \"*15)\n",
|
186 |
"\n",
|
187 |
-
" if os.path.exists(
|
188 |
-
" copy_items_with_replace(
|
189 |
-
"
|
190 |
"\n",
|
191 |
"# ================= MAIN CODE ==================\n",
|
192 |
"if os.path.exists(webui_path):\n",
|
193 |
" if UI != OLD_UI:\n",
|
194 |
" print(f'Switching the WebUI from \\033[33m{OLD_UI}\\033[0m to \\033[33m{UI}\\033[0m:')\n",
|
195 |
-
" copy_items_with_replace(webui_path,
|
196 |
-
"
|
197 |
" os.environ['SDW_OLD_UI'] = UI\n",
|
198 |
" time.sleep(2)\n",
|
199 |
" clear_output()\n",
|
200 |
"\n",
|
201 |
"if not os.path.exists(webui_path):\n",
|
202 |
" unpack_webui()\n",
|
|
|
203 |
"else:\n",
|
204 |
" print(\"🚀 All unpacked... Skip. ⚡\")\n",
|
205 |
" timer_colab = handle_colab_timer(webui_path, start_colab)\n",
|
@@ -211,7 +219,7 @@
|
|
211 |
"if latest_webui or latest_exstensions:\n",
|
212 |
" action = \"WebUI and Extensions\" if latest_webui and latest_exstensions else (\"WebUI\" if latest_webui else \"Extensions\")\n",
|
213 |
" print(f\"⌚️ Updating {action}...\", end='')\n",
|
214 |
-
" with capture.capture_output()
|
215 |
" !git config --global user.email \"[email protected]\"\n",
|
216 |
" !git config --global user.name \"Your Name\"\n",
|
217 |
"\n",
|
@@ -224,30 +232,26 @@
|
|
224 |
" ## Update extensions\n",
|
225 |
" if latest_exstensions:\n",
|
226 |
" !{'for dir in ' + webui_path + '/extensions/*/; do cd \\\"$dir\\\" && git reset --hard && git pull; done'}\n",
|
227 |
-
" del cap\n",
|
228 |
" print(f\"\\r✨ Updating {action} Completed!\")\n",
|
229 |
"\n",
|
230 |
"\n",
|
231 |
"# === FIXING EXTENSIONS ===\n",
|
232 |
"anxety_repos = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main\"\n",
|
233 |
-
"
|
234 |
-
"with capture.capture_output() as cap:\n",
|
235 |
" # --- Umi-Wildcard ---\n",
|
236 |
" !sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default\n",
|
237 |
" # --- Encrypt-Image ---\n",
|
238 |
" !sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui\n",
|
239 |
-
"del cap\n",
|
240 |
"\n",
|
241 |
"\n",
|
242 |
"## Version switching\n",
|
243 |
"if commit_hash:\n",
|
244 |
" print('⏳ Time machine activation...', end=\"\")\n",
|
245 |
-
" with capture.capture_output()
|
246 |
" %cd {webui_path}\n",
|
247 |
" !git config --global user.email \"[email protected]\"\n",
|
248 |
" !git config --global user.name \"Your Name\"\n",
|
249 |
" !git reset --hard {commit_hash}\n",
|
250 |
-
" del cap\n",
|
251 |
" print(f\"\\r⌛️ The time machine has been activated! Current commit: \\033[34m{commit_hash}\\033[0m\")\n",
|
252 |
"\n",
|
253 |
"\n",
|
@@ -575,9 +579,8 @@
|
|
575 |
" download(url)\n",
|
576 |
" print(\"\\n\\033[33m# =============================== #\\n\\033[0m\")\n",
|
577 |
"else:\n",
|
578 |
-
" with capture.capture_output()
|
579 |
" download(url)\n",
|
580 |
-
" del cap\n",
|
581 |
"\n",
|
582 |
"print(\"\\r🏁 Download Complete!\" + \" \"*15)\n",
|
583 |
"\n",
|
@@ -589,7 +592,7 @@
|
|
589 |
"## Install of Custom extensions\n",
|
590 |
"if len(extension_repo) > 0:\n",
|
591 |
" print(\"✨ Installing custom extensions...\", end='')\n",
|
592 |
-
" with capture.capture_output()
|
593 |
" for repo, repo_name in extension_repo:\n",
|
594 |
" if not repo_name:\n",
|
595 |
" repo_name = repo.split('/')[-1]\n",
|
@@ -597,7 +600,6 @@
|
|
597 |
" && git clone {repo} {repo_name} \\\n",
|
598 |
" && cd {repo_name} \\\n",
|
599 |
" && git fetch\n",
|
600 |
-
" del cap\n",
|
601 |
" print(f\"\\r📦 Installed '{len(extension_repo)}', Custom extensions!\")\n",
|
602 |
"\n",
|
603 |
"\n",
|
|
|
39 |
"\n",
|
40 |
"os.chdir(root_path)\n",
|
41 |
"\n",
|
42 |
+
"\n",
|
43 |
"# ============ loading settings V4 =============\n",
|
44 |
"def load_settings(path):\n",
|
45 |
" if os.path.exists(path):\n",
|
|
|
95 |
" subprocess.run(install_cmd, shell=True, capture_output=True)\n",
|
96 |
"\n",
|
97 |
" # Additional specific packages\n",
|
98 |
+
" with capture.capture_output():\n",
|
99 |
" !curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}\n",
|
100 |
" !curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl\n",
|
101 |
" !curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.32/zrok_0.4.32_linux_amd64.tar.gz && tar -xzf zrok_0.4.32_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.32_linux_amd64.tar.gz\n",
|
|
|
102 |
"\n",
|
103 |
" clear_output()\n",
|
104 |
"\n",
|
|
|
113 |
"\n",
|
114 |
"# =================== OTHER ====================\n",
|
115 |
"# Setup Timer\n",
|
116 |
+
"start_colab = int(os.environ.get(\"START_COLAB\", time.time() - 5))\n",
|
117 |
+
"os.environ[\"START_COLAB\"] = str(start_colab)\n",
|
118 |
+
"\n",
|
119 |
+
"def download_cfg_files(file_paths, destination_path):\n",
|
120 |
+
" base_url = \"https://huggingface.co/NagisaNao/SD-CONFIGS/resolve/main\"\n",
|
121 |
+
" for filename in file_paths:\n",
|
122 |
+
" file_name = filename.split('/')[-1]\n",
|
123 |
+
" !wget -O {destination_path}/{file_name} {base_url}/{filename}\n",
|
124 |
+
"\n",
|
125 |
+
"def cfg_download():\n",
|
126 |
+
" common_files = [\"styles.csv\"]\n",
|
127 |
+
" a1111_files = [\"A1111/config.json\", \"A1111/ui-config.json\"]\n",
|
128 |
+
" forge_files = [\"reForge/config.json\", \"reForge/ui-config.json\"]\n",
|
129 |
+
"\n",
|
130 |
+
" with capture.capture_output():\n",
|
131 |
+
" download_cfg_files(common_files, webui_path)\n",
|
132 |
+
" ui_files = a1111_files if UI == 'A1111' else forge_files\n",
|
133 |
+
" download_cfg_files(ui_files, webui_path)\n",
|
134 |
+
"\n",
|
135 |
+
"def remove_dir(directory_path):\n",
|
136 |
" if directory_path and os.path.exists(directory_path):\n",
|
137 |
" try:\n",
|
138 |
" shutil.rmtree(directory_path)\n",
|
139 |
" except Exception:\n",
|
140 |
" !rm -rf {directory_path}\n",
|
141 |
"\n",
|
142 |
+
"TEMPORARY_DIR = f'{root_path}/temp_dir'\n",
|
|
|
|
|
143 |
"def copy_items_with_replace(src_base, dst_base):\n",
|
144 |
" items_to_copy = [\n",
|
145 |
" 'embeddings',\n",
|
|
|
150 |
" ]\n",
|
151 |
"\n",
|
152 |
" print(\"⌚ Moving files...\", end='')\n",
|
|
|
153 |
" for item in items_to_copy:\n",
|
154 |
" src = os.path.join(src_base, item)\n",
|
155 |
" dst = os.path.join(dst_base, item)\n",
|
156 |
"\n",
|
157 |
" if os.path.exists(src):\n",
|
158 |
" if os.path.exists(dst):\n",
|
159 |
+
" remove_dir(dst)\n",
|
160 |
" os.makedirs(os.path.dirname(dst), exist_ok=True)\n",
|
161 |
" shutil.move(src, dst)\n",
|
162 |
" print(\"\\r🔥 Files moved!\" + \" \"*15)\n",
|
|
|
175 |
" start_install = time.time()\n",
|
176 |
" print(f\"⌚ Unpacking Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...\", end='')\n",
|
177 |
"\n",
|
178 |
+
" with capture.capture_output():\n",
|
179 |
" download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip\"\n",
|
180 |
" if UI == 'Forge':\n",
|
181 |
" download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip\"\n",
|
182 |
"\n",
|
|
|
183 |
" zip_path = f\"{root_path}/repo.zip\"\n",
|
184 |
+
" !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M {download_url} -d {root_path} -o repo.zip\n",
|
185 |
" !unzip -q -o {zip_path} -d {webui_path}\n",
|
186 |
" !rm -rf {zip_path}\n",
|
187 |
"\n",
|
188 |
+
" !echo -n {start_colab} > {webui_path}/static/colabTimer.txt\n",
|
|
|
189 |
"\n",
|
190 |
" install_time = time.time() - start_install\n",
|
191 |
" minutes, seconds = divmod(int(install_time), 60)\n",
|
192 |
" print(f\"\\r🚀 Unpacking complete! For {minutes:02}:{seconds:02} ⚡\" + \" \"*15)\n",
|
193 |
"\n",
|
194 |
+
" if os.path.exists(TEMPORARY_DIR):\n",
|
195 |
+
" copy_items_with_replace(TEMPORARY_DIR, webui_path)\n",
|
196 |
+
" remove_dir(TEMPORARY_DIR)\n",
|
197 |
"\n",
|
198 |
"# ================= MAIN CODE ==================\n",
|
199 |
"if os.path.exists(webui_path):\n",
|
200 |
" if UI != OLD_UI:\n",
|
201 |
" print(f'Switching the WebUI from \\033[33m{OLD_UI}\\033[0m to \\033[33m{UI}\\033[0m:')\n",
|
202 |
+
" copy_items_with_replace(webui_path, TEMPORARY_DIR)\n",
|
203 |
+
" remove_dir(webui_path)\n",
|
204 |
" os.environ['SDW_OLD_UI'] = UI\n",
|
205 |
" time.sleep(2)\n",
|
206 |
" clear_output()\n",
|
207 |
"\n",
|
208 |
"if not os.path.exists(webui_path):\n",
|
209 |
" unpack_webui()\n",
|
210 |
+
" cfg_download()\n",
|
211 |
"else:\n",
|
212 |
" print(\"🚀 All unpacked... Skip. ⚡\")\n",
|
213 |
" timer_colab = handle_colab_timer(webui_path, start_colab)\n",
|
|
|
219 |
"if latest_webui or latest_exstensions:\n",
|
220 |
" action = \"WebUI and Extensions\" if latest_webui and latest_exstensions else (\"WebUI\" if latest_webui else \"Extensions\")\n",
|
221 |
" print(f\"⌚️ Updating {action}...\", end='')\n",
|
222 |
+
" with capture.capture_output():\n",
|
223 |
" !git config --global user.email \"[email protected]\"\n",
|
224 |
" !git config --global user.name \"Your Name\"\n",
|
225 |
"\n",
|
|
|
232 |
" ## Update extensions\n",
|
233 |
" if latest_exstensions:\n",
|
234 |
" !{'for dir in ' + webui_path + '/extensions/*/; do cd \\\"$dir\\\" && git reset --hard && git pull; done'}\n",
|
|
|
235 |
" print(f\"\\r✨ Updating {action} Completed!\")\n",
|
236 |
"\n",
|
237 |
"\n",
|
238 |
"# === FIXING EXTENSIONS ===\n",
|
239 |
"anxety_repos = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main\"\n",
|
240 |
+
"with capture.capture_output():\n",
|
|
|
241 |
" # --- Umi-Wildcard ---\n",
|
242 |
" !sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default\n",
|
243 |
" # --- Encrypt-Image ---\n",
|
244 |
" !sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui\n",
|
|
|
245 |
"\n",
|
246 |
"\n",
|
247 |
"## Version switching\n",
|
248 |
"if commit_hash:\n",
|
249 |
" print('⏳ Time machine activation...', end=\"\")\n",
|
250 |
+
" with capture.capture_output():\n",
|
251 |
" %cd {webui_path}\n",
|
252 |
" !git config --global user.email \"[email protected]\"\n",
|
253 |
" !git config --global user.name \"Your Name\"\n",
|
254 |
" !git reset --hard {commit_hash}\n",
|
|
|
255 |
" print(f\"\\r⌛️ The time machine has been activated! Current commit: \\033[34m{commit_hash}\\033[0m\")\n",
|
256 |
"\n",
|
257 |
"\n",
|
|
|
579 |
" download(url)\n",
|
580 |
" print(\"\\n\\033[33m# =============================== #\\n\\033[0m\")\n",
|
581 |
"else:\n",
|
582 |
+
" with capture.capture_output():\n",
|
583 |
" download(url)\n",
|
|
|
584 |
"\n",
|
585 |
"print(\"\\r🏁 Download Complete!\" + \" \"*15)\n",
|
586 |
"\n",
|
|
|
592 |
"## Install of Custom extensions\n",
|
593 |
"if len(extension_repo) > 0:\n",
|
594 |
" print(\"✨ Installing custom extensions...\", end='')\n",
|
595 |
+
" with capture.capture_output():\n",
|
596 |
" for repo, repo_name in extension_repo:\n",
|
597 |
" if not repo_name:\n",
|
598 |
" repo_name = repo.split('/')[-1]\n",
|
|
|
600 |
" && git clone {repo} {repo_name} \\\n",
|
601 |
" && cd {repo_name} \\\n",
|
602 |
" && git fetch\n",
|
|
|
603 |
" print(f\"\\r📦 Installed '{len(extension_repo)}', Custom extensions!\")\n",
|
604 |
"\n",
|
605 |
"\n",
|
files_cells/notebooks/en/widgets_en.ipynb
CHANGED
@@ -27,8 +27,7 @@
|
|
27 |
"import os\n",
|
28 |
"import json\n",
|
29 |
"import time\n",
|
30 |
-
"
|
31 |
-
"from ipywidgets import widgets, Layout, Label, Button, VBox, HBox\n",
|
32 |
"from IPython.display import display, HTML, Javascript, clear_output\n",
|
33 |
"\n",
|
34 |
"\n",
|
|
|
27 |
"import os\n",
|
28 |
"import json\n",
|
29 |
"import time\n",
|
30 |
+
"from ipywidgets import widgets\n",
|
|
|
31 |
"from IPython.display import display, HTML, Javascript, clear_output\n",
|
32 |
"\n",
|
33 |
"\n",
|
files_cells/notebooks/ru/auto_cleaner_ru.ipynb
CHANGED
@@ -28,8 +28,7 @@
|
|
28 |
"\n",
|
29 |
"import os\n",
|
30 |
"import time\n",
|
31 |
-
"
|
32 |
-
"from ipywidgets import Label, Button, VBox, HBox\n",
|
33 |
"from IPython.display import display, HTML\n",
|
34 |
"\n",
|
35 |
"\n",
|
@@ -58,7 +57,7 @@
|
|
58 |
"}\n",
|
59 |
"\n",
|
60 |
"\"\"\" functions \"\"\"\n",
|
61 |
-
"def clean_directory(directory):\n",
|
62 |
" deleted_files = 0\n",
|
63 |
"\n",
|
64 |
" for root, dirs, files in os.walk(directory):\n",
|
@@ -67,7 +66,7 @@
|
|
67 |
"\n",
|
68 |
" if file.endswith(\".txt\"):\n",
|
69 |
" continue\n",
|
70 |
-
" if file.endswith((\".safetensors\", \".pt\"
|
71 |
" deleted_files += 1\n",
|
72 |
"\n",
|
73 |
" os.remove(file_path)\n",
|
@@ -89,7 +88,7 @@
|
|
89 |
"\n",
|
90 |
" for option in selected_cleaners:\n",
|
91 |
" if option in directories:\n",
|
92 |
-
" deleted_files_dict[option] = clean_directory(directories[option])\n",
|
93 |
"\n",
|
94 |
" output.clear_output()\n",
|
95 |
"\n",
|
|
|
28 |
"\n",
|
29 |
"import os\n",
|
30 |
"import time\n",
|
31 |
+
"from ipywidgets import widgets\n",
|
|
|
32 |
"from IPython.display import display, HTML\n",
|
33 |
"\n",
|
34 |
"\n",
|
|
|
57 |
"}\n",
|
58 |
"\n",
|
59 |
"\"\"\" functions \"\"\"\n",
|
60 |
+
"def clean_directory(directory, directory_type):\n",
|
61 |
" deleted_files = 0\n",
|
62 |
"\n",
|
63 |
" for root, dirs, files in os.walk(directory):\n",
|
|
|
66 |
"\n",
|
67 |
" if file.endswith(\".txt\"):\n",
|
68 |
" continue\n",
|
69 |
+
" if file.endswith((\".safetensors\", \".pt\")) or directory_type == \"Images\":\n",
|
70 |
" deleted_files += 1\n",
|
71 |
"\n",
|
72 |
" os.remove(file_path)\n",
|
|
|
88 |
"\n",
|
89 |
" for option in selected_cleaners:\n",
|
90 |
" if option in directories:\n",
|
91 |
+
" deleted_files_dict[option] = clean_directory(directories[option], option)\n",
|
92 |
"\n",
|
93 |
" output.clear_output()\n",
|
94 |
"\n",
|
files_cells/notebooks/ru/downloading_ru.ipynb
CHANGED
@@ -39,6 +39,7 @@
|
|
39 |
"\n",
|
40 |
"os.chdir(root_path)\n",
|
41 |
"\n",
|
|
|
42 |
"# ============ loading settings V4 =============\n",
|
43 |
"def load_settings(path):\n",
|
44 |
" if os.path.exists(path):\n",
|
@@ -94,11 +95,10 @@
|
|
94 |
" subprocess.run(install_cmd, shell=True, capture_output=True)\n",
|
95 |
"\n",
|
96 |
" # Additional specific packages\n",
|
97 |
-
" with capture.capture_output()
|
98 |
" !curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}\n",
|
99 |
" !curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl\n",
|
100 |
" !curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.32/zrok_0.4.32_linux_amd64.tar.gz && tar -xzf zrok_0.4.32_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.32_linux_amd64.tar.gz\n",
|
101 |
-
" del cap\n",
|
102 |
"\n",
|
103 |
" clear_output()\n",
|
104 |
"\n",
|
@@ -113,23 +113,33 @@
|
|
113 |
"\n",
|
114 |
"# =================== OTHER ====================\n",
|
115 |
"# Setup Timer\n",
|
116 |
-
"
|
117 |
-
"
|
118 |
-
"
|
119 |
-
"
|
120 |
-
"
|
121 |
-
"
|
122 |
-
"
|
123 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
" if directory_path and os.path.exists(directory_path):\n",
|
125 |
" try:\n",
|
126 |
" shutil.rmtree(directory_path)\n",
|
127 |
" except Exception:\n",
|
128 |
" !rm -rf {directory_path}\n",
|
129 |
"\n",
|
130 |
-
"
|
131 |
-
"temporarily_dir = f'{root_path}/temp_dir'\n",
|
132 |
-
"\n",
|
133 |
"def copy_items_with_replace(src_base, dst_base):\n",
|
134 |
" items_to_copy = [\n",
|
135 |
" 'embeddings',\n",
|
@@ -140,14 +150,13 @@
|
|
140 |
" ]\n",
|
141 |
"\n",
|
142 |
" print(\"⌚ Перемещение файлов...\", end='')\n",
|
143 |
-
" time.sleep(1)\n",
|
144 |
" for item in items_to_copy:\n",
|
145 |
" src = os.path.join(src_base, item)\n",
|
146 |
" dst = os.path.join(dst_base, item)\n",
|
147 |
"\n",
|
148 |
" if os.path.exists(src):\n",
|
149 |
" if os.path.exists(dst):\n",
|
150 |
-
"
|
151 |
" os.makedirs(os.path.dirname(dst), exist_ok=True)\n",
|
152 |
" shutil.move(src, dst)\n",
|
153 |
" print(\"\\r🔥 Файлы перемещены!\" + \" \"*15)\n",
|
@@ -166,40 +175,39 @@
|
|
166 |
" start_install = time.time()\n",
|
167 |
" print(f\"⌚ Распаковка Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...\", end='')\n",
|
168 |
"\n",
|
169 |
-
" with capture.capture_output()
|
170 |
" download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip\"\n",
|
171 |
" if UI == 'Forge':\n",
|
172 |
" download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip\"\n",
|
173 |
"\n",
|
174 |
-
" aria2_args = \"--console-log-level=error -c -x 16 -s 16 -k 1M\"\n",
|
175 |
" zip_path = f\"{root_path}/repo.zip\"\n",
|
176 |
-
" !aria2c
|
177 |
" !unzip -q -o {zip_path} -d {webui_path}\n",
|
178 |
" !rm -rf {zip_path}\n",
|
179 |
"\n",
|
180 |
-
"
|
181 |
-
" del cap\n",
|
182 |
"\n",
|
183 |
" install_time = time.time() - start_install\n",
|
184 |
" minutes, seconds = divmod(int(install_time), 60)\n",
|
185 |
" print(f\"\\r🚀 Распаковка Завершена! За {minutes:02}:{seconds:02} ⚡\" + \" \"*15)\n",
|
186 |
"\n",
|
187 |
-
" if os.path.exists(
|
188 |
-
" copy_items_with_replace(
|
189 |
-
"
|
190 |
"\n",
|
191 |
"# ================= MAIN CODE ==================\n",
|
192 |
"if os.path.exists(webui_path):\n",
|
193 |
" if UI != OLD_UI:\n",
|
194 |
" print(f'Переключение веб-интерфейса с \\033[33m{OLD_UI}\\033[0m на \\033[33m{UI}\\033[0m:')\n",
|
195 |
-
" copy_items_with_replace(webui_path,
|
196 |
-
"
|
197 |
" os.environ['SDW_OLD_UI'] = UI\n",
|
198 |
" time.sleep(2)\n",
|
199 |
" clear_output()\n",
|
200 |
"\n",
|
201 |
"if not os.path.exists(webui_path):\n",
|
202 |
" unpack_webui()\n",
|
|
|
203 |
"else:\n",
|
204 |
" print(\"🚀 Все распакованно... Пропуск. ⚡\")\n",
|
205 |
" timer_colab = handle_colab_timer(webui_path, start_colab)\n",
|
@@ -211,7 +219,7 @@
|
|
211 |
"if latest_webui or latest_exstensions:\n",
|
212 |
" action = \"WebUI и Расширений\" if latest_webui and latest_exstensions else (\"WebUI\" if latest_webui else \"Расширений\")\n",
|
213 |
" print(f\"⌚️ Обновление {action}...\", end='')\n",
|
214 |
-
" with capture.capture_output()
|
215 |
" !git config --global user.email \"[email protected]\"\n",
|
216 |
" !git config --global user.name \"Your Name\"\n",
|
217 |
"\n",
|
@@ -224,30 +232,26 @@
|
|
224 |
" ## Update extensions\n",
|
225 |
" if latest_exstensions:\n",
|
226 |
" !{'for dir in ' + webui_path + '/extensions/*/; do cd \\\"$dir\\\" && git reset --hard && git pull; done'}\n",
|
227 |
-
" del cap\n",
|
228 |
" print(f\"\\r✨ Обновление {action} Завершено!\")\n",
|
229 |
"\n",
|
230 |
"\n",
|
231 |
"# === FIXING EXTENSIONS ===\n",
|
232 |
"anxety_repos = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main\"\n",
|
233 |
-
"
|
234 |
-
"with capture.capture_output() as cap:\n",
|
235 |
" # --- Umi-Wildcard ---\n",
|
236 |
" !sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default\n",
|
237 |
" # --- Encrypt-Image ---\n",
|
238 |
" !sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui\n",
|
239 |
-
"del cap\n",
|
240 |
"\n",
|
241 |
"\n",
|
242 |
"## Version switching\n",
|
243 |
"if commit_hash:\n",
|
244 |
" print('⏳ Активация машины времени...', end=\"\")\n",
|
245 |
-
" with capture.capture_output()
|
246 |
" %cd {webui_path}\n",
|
247 |
" !git config --global user.email \"[email protected]\"\n",
|
248 |
" !git config --global user.name \"Your Name\"\n",
|
249 |
" !git reset --hard {commit_hash}\n",
|
250 |
-
" del cap\n",
|
251 |
" print(f\"\\r⌛️ Машина времени активированна! Текущий коммит: \\033[34m{commit_hash}\\033[0m\")\n",
|
252 |
"\n",
|
253 |
"\n",
|
@@ -575,9 +579,8 @@
|
|
575 |
" download(url)\n",
|
576 |
" print(\"\\n\\033[33m# =============================== #\\n\\033[0m\")\n",
|
577 |
"else:\n",
|
578 |
-
" with capture.capture_output()
|
579 |
" download(url)\n",
|
580 |
-
" del cap\n",
|
581 |
"\n",
|
582 |
"print(\"\\r🏁 Скачивание Завершено!\" + \" \"*15)\n",
|
583 |
"\n",
|
@@ -589,7 +592,7 @@
|
|
589 |
"## Install of Custom extensions\n",
|
590 |
"if len(extension_repo) > 0:\n",
|
591 |
" print(\"✨ Установка кастомных расширений...\", end='')\n",
|
592 |
-
" with capture.capture_output()
|
593 |
" for repo, repo_name in extension_repo:\n",
|
594 |
" if not repo_name:\n",
|
595 |
" repo_name = repo.split('/')[-1]\n",
|
@@ -597,7 +600,6 @@
|
|
597 |
" && git clone {repo} {repo_name} \\\n",
|
598 |
" && cd {repo_name} \\\n",
|
599 |
" && git fetch\n",
|
600 |
-
" del cap\n",
|
601 |
" print(f\"\\r📦 Установлено '{len(extension_repo)}', Кастомных расширений!\")\n",
|
602 |
"\n",
|
603 |
"\n",
|
|
|
39 |
"\n",
|
40 |
"os.chdir(root_path)\n",
|
41 |
"\n",
|
42 |
+
"\n",
|
43 |
"# ============ loading settings V4 =============\n",
|
44 |
"def load_settings(path):\n",
|
45 |
" if os.path.exists(path):\n",
|
|
|
95 |
" subprocess.run(install_cmd, shell=True, capture_output=True)\n",
|
96 |
"\n",
|
97 |
" # Additional specific packages\n",
|
98 |
+
" with capture.capture_output()\n",
|
99 |
" !curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}\n",
|
100 |
" !curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl\n",
|
101 |
" !curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.32/zrok_0.4.32_linux_amd64.tar.gz && tar -xzf zrok_0.4.32_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.32_linux_amd64.tar.gz\n",
|
|
|
102 |
"\n",
|
103 |
" clear_output()\n",
|
104 |
"\n",
|
|
|
113 |
"\n",
|
114 |
"# =================== OTHER ====================\n",
|
115 |
"# Setup Timer\n",
|
116 |
+
"start_colab = int(os.environ.get(\"START_COLAB\", time.time() - 5))\n",
|
117 |
+
"os.environ[\"START_COLAB\"] = str(start_colab)\n",
|
118 |
+
"\n",
|
119 |
+
"def download_cfg_files(file_paths, destination_path):\n",
|
120 |
+
" base_url = \"https://huggingface.co/NagisaNao/SD-CONFIGS/resolve/main\"\n",
|
121 |
+
" for filename in file_paths:\n",
|
122 |
+
" file_name = filename.split('/')[-1]\n",
|
123 |
+
" !wget -O {destination_path}/{file_name} {base_url}/{filename}\n",
|
124 |
+
"\n",
|
125 |
+
"def cfg_download():\n",
|
126 |
+
" common_files = [\"styles.csv\"]\n",
|
127 |
+
" a1111_files = [\"A1111/config.json\", \"A1111/ui-config.json\"]\n",
|
128 |
+
" forge_files = [\"reForge/config.json\", \"reForge/ui-config.json\"]\n",
|
129 |
+
"\n",
|
130 |
+
" with capture.capture_output():\n",
|
131 |
+
" download_cfg_files(common_files, webui_path)\n",
|
132 |
+
" ui_files = a1111_files if UI == 'A1111' else forge_files\n",
|
133 |
+
" download_cfg_files(ui_files, webui_path)\n",
|
134 |
+
"\n",
|
135 |
+
"def remove_dir(directory_path):\n",
|
136 |
" if directory_path and os.path.exists(directory_path):\n",
|
137 |
" try:\n",
|
138 |
" shutil.rmtree(directory_path)\n",
|
139 |
" except Exception:\n",
|
140 |
" !rm -rf {directory_path}\n",
|
141 |
"\n",
|
142 |
+
"TEMPORARY_DIR = f'{root_path}/temp_dir'\n",
|
|
|
|
|
143 |
"def copy_items_with_replace(src_base, dst_base):\n",
|
144 |
" items_to_copy = [\n",
|
145 |
" 'embeddings',\n",
|
|
|
150 |
" ]\n",
|
151 |
"\n",
|
152 |
" print(\"⌚ Перемещение файлов...\", end='')\n",
|
|
|
153 |
" for item in items_to_copy:\n",
|
154 |
" src = os.path.join(src_base, item)\n",
|
155 |
" dst = os.path.join(dst_base, item)\n",
|
156 |
"\n",
|
157 |
" if os.path.exists(src):\n",
|
158 |
" if os.path.exists(dst):\n",
|
159 |
+
" remove_dir(dst)\n",
|
160 |
" os.makedirs(os.path.dirname(dst), exist_ok=True)\n",
|
161 |
" shutil.move(src, dst)\n",
|
162 |
" print(\"\\r🔥 Файлы перемещены!\" + \" \"*15)\n",
|
|
|
175 |
" start_install = time.time()\n",
|
176 |
" print(f\"⌚ Распаковка Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...\", end='')\n",
|
177 |
"\n",
|
178 |
+
" with capture.capture_output():\n",
|
179 |
" download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip\"\n",
|
180 |
" if UI == 'Forge':\n",
|
181 |
" download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip\"\n",
|
182 |
"\n",
|
|
|
183 |
" zip_path = f\"{root_path}/repo.zip\"\n",
|
184 |
+
" !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M {download_url} -d {root_path} -o repo.zip\n",
|
185 |
" !unzip -q -o {zip_path} -d {webui_path}\n",
|
186 |
" !rm -rf {zip_path}\n",
|
187 |
"\n",
|
188 |
+
" !echo -n {start_colab} > {webui_path}/static/colabTimer.txt\n",
|
|
|
189 |
"\n",
|
190 |
" install_time = time.time() - start_install\n",
|
191 |
" minutes, seconds = divmod(int(install_time), 60)\n",
|
192 |
" print(f\"\\r🚀 Распаковка Завершена! За {minutes:02}:{seconds:02} ⚡\" + \" \"*15)\n",
|
193 |
"\n",
|
194 |
+
" if os.path.exists(TEMPORARY_DIR):\n",
|
195 |
+
" copy_items_with_replace(TEMPORARY_DIR, webui_path)\n",
|
196 |
+
" remove_dir(TEMPORARY_DIR)\n",
|
197 |
"\n",
|
198 |
"# ================= MAIN CODE ==================\n",
|
199 |
"if os.path.exists(webui_path):\n",
|
200 |
" if UI != OLD_UI:\n",
|
201 |
" print(f'Переключение веб-интерфейса с \\033[33m{OLD_UI}\\033[0m на \\033[33m{UI}\\033[0m:')\n",
|
202 |
+
" copy_items_with_replace(webui_path, TEMPORARY_DIR)\n",
|
203 |
+
" remove_dir(webui_path)\n",
|
204 |
" os.environ['SDW_OLD_UI'] = UI\n",
|
205 |
" time.sleep(2)\n",
|
206 |
" clear_output()\n",
|
207 |
"\n",
|
208 |
"if not os.path.exists(webui_path):\n",
|
209 |
" unpack_webui()\n",
|
210 |
+
" cfg_download()\n",
|
211 |
"else:\n",
|
212 |
" print(\"🚀 Все распакованно... Пропуск. ⚡\")\n",
|
213 |
" timer_colab = handle_colab_timer(webui_path, start_colab)\n",
|
|
|
219 |
"if latest_webui or latest_exstensions:\n",
|
220 |
" action = \"WebUI и Расширений\" if latest_webui and latest_exstensions else (\"WebUI\" if latest_webui else \"Расширений\")\n",
|
221 |
" print(f\"⌚️ Обновление {action}...\", end='')\n",
|
222 |
+
" with capture.capture_output():\n",
|
223 |
" !git config --global user.email \"[email protected]\"\n",
|
224 |
" !git config --global user.name \"Your Name\"\n",
|
225 |
"\n",
|
|
|
232 |
" ## Update extensions\n",
|
233 |
" if latest_exstensions:\n",
|
234 |
" !{'for dir in ' + webui_path + '/extensions/*/; do cd \\\"$dir\\\" && git reset --hard && git pull; done'}\n",
|
|
|
235 |
" print(f\"\\r✨ Обновление {action} Завершено!\")\n",
|
236 |
"\n",
|
237 |
"\n",
|
238 |
"# === FIXING EXTENSIONS ===\n",
|
239 |
"anxety_repos = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main\"\n",
|
240 |
+
"with capture.capture_output():\n",
|
|
|
241 |
" # --- Umi-Wildcard ---\n",
|
242 |
" !sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default\n",
|
243 |
" # --- Encrypt-Image ---\n",
|
244 |
" !sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui\n",
|
|
|
245 |
"\n",
|
246 |
"\n",
|
247 |
"## Version switching\n",
|
248 |
"if commit_hash:\n",
|
249 |
" print('⏳ Активация машины времени...', end=\"\")\n",
|
250 |
+
" with capture.capture_output():\n",
|
251 |
" %cd {webui_path}\n",
|
252 |
" !git config --global user.email \"[email protected]\"\n",
|
253 |
" !git config --global user.name \"Your Name\"\n",
|
254 |
" !git reset --hard {commit_hash}\n",
|
|
|
255 |
" print(f\"\\r⌛️ Машина времени активированна! Текущий коммит: \\033[34m{commit_hash}\\033[0m\")\n",
|
256 |
"\n",
|
257 |
"\n",
|
|
|
579 |
" download(url)\n",
|
580 |
" print(\"\\n\\033[33m# =============================== #\\n\\033[0m\")\n",
|
581 |
"else:\n",
|
582 |
+
" with capture.capture_output():\n",
|
583 |
" download(url)\n",
|
|
|
584 |
"\n",
|
585 |
"print(\"\\r🏁 Скачивание Завершено!\" + \" \"*15)\n",
|
586 |
"\n",
|
|
|
592 |
"## Install of Custom extensions\n",
|
593 |
"if len(extension_repo) > 0:\n",
|
594 |
" print(\"✨ Установка кастомных расширений...\", end='')\n",
|
595 |
+
" with capture.capture_output():\n",
|
596 |
" for repo, repo_name in extension_repo:\n",
|
597 |
" if not repo_name:\n",
|
598 |
" repo_name = repo.split('/')[-1]\n",
|
|
|
600 |
" && git clone {repo} {repo_name} \\\n",
|
601 |
" && cd {repo_name} \\\n",
|
602 |
" && git fetch\n",
|
|
|
603 |
" print(f\"\\r📦 Установлено '{len(extension_repo)}', Кастомных расширений!\")\n",
|
604 |
"\n",
|
605 |
"\n",
|
files_cells/notebooks/ru/widgets_ru.ipynb
CHANGED
@@ -27,8 +27,7 @@
|
|
27 |
"import os\n",
|
28 |
"import json\n",
|
29 |
"import time\n",
|
30 |
-
"
|
31 |
-
"from ipywidgets import widgets, Layout, Label, Button, VBox, HBox\n",
|
32 |
"from IPython.display import display, HTML, Javascript, clear_output\n",
|
33 |
"\n",
|
34 |
"\n",
|
|
|
27 |
"import os\n",
|
28 |
"import json\n",
|
29 |
"import time\n",
|
30 |
+
"from ipywidgets import widgets\n",
|
|
|
31 |
"from IPython.display import display, HTML, Javascript, clear_output\n",
|
32 |
"\n",
|
33 |
"\n",
|
files_cells/python/en/auto_cleaner_en.py
CHANGED
@@ -4,8 +4,7 @@ from directory_setup import models_dir, vaes_dir, control_dir, loras_dir, output
|
|
4 |
|
5 |
import os
|
6 |
import time
|
7 |
-
|
8 |
-
from ipywidgets import Label, Button, VBox, HBox
|
9 |
from IPython.display import display, HTML, Javascript
|
10 |
|
11 |
|
@@ -34,7 +33,7 @@ directories = {
|
|
34 |
}
|
35 |
|
36 |
""" functions """
|
37 |
-
def clean_directory(directory):
|
38 |
deleted_files = 0
|
39 |
|
40 |
for root, dirs, files in os.walk(directory):
|
@@ -43,7 +42,7 @@ def clean_directory(directory):
|
|
43 |
|
44 |
if file.endswith(".txt"):
|
45 |
continue
|
46 |
-
if file.endswith((".safetensors", ".pt"
|
47 |
deleted_files += 1
|
48 |
|
49 |
os.remove(file_path)
|
@@ -65,7 +64,7 @@ def on_execute_button_press(button):
|
|
65 |
|
66 |
for option in selected_cleaners:
|
67 |
if option in directories:
|
68 |
-
deleted_files_dict[option] = clean_directory(directories[option])
|
69 |
|
70 |
output.clear_output()
|
71 |
|
|
|
4 |
|
5 |
import os
|
6 |
import time
|
7 |
+
from ipywidgets import widgets
|
|
|
8 |
from IPython.display import display, HTML, Javascript
|
9 |
|
10 |
|
|
|
33 |
}
|
34 |
|
35 |
""" functions """
|
36 |
+
def clean_directory(directory, directory_type):
|
37 |
deleted_files = 0
|
38 |
|
39 |
for root, dirs, files in os.walk(directory):
|
|
|
42 |
|
43 |
if file.endswith(".txt"):
|
44 |
continue
|
45 |
+
if file.endswith((".safetensors", ".pt")) or directory_type == "Images":
|
46 |
deleted_files += 1
|
47 |
|
48 |
os.remove(file_path)
|
|
|
64 |
|
65 |
for option in selected_cleaners:
|
66 |
if option in directories:
|
67 |
+
deleted_files_dict[option] = clean_directory(directories[option], option)
|
68 |
|
69 |
output.clear_output()
|
70 |
|
files_cells/python/en/downloading_en.py
CHANGED
@@ -29,6 +29,7 @@ OLD_UI = os.getenv('SDW_OLD_UI')
|
|
29 |
|
30 |
os.chdir(root_path)
|
31 |
|
|
|
32 |
# ============ loading settings V4 =============
|
33 |
def load_settings(path):
|
34 |
if os.path.exists(path):
|
@@ -84,11 +85,10 @@ if not os.path.exists(flag_file):
|
|
84 |
subprocess.run(install_cmd, shell=True, capture_output=True)
|
85 |
|
86 |
# Additional specific packages
|
87 |
-
with capture.capture_output()
|
88 |
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
89 |
get_ipython().system('curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl')
|
90 |
get_ipython().system('curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.32/zrok_0.4.32_linux_amd64.tar.gz && tar -xzf zrok_0.4.32_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.32_linux_amd64.tar.gz')
|
91 |
-
del cap
|
92 |
|
93 |
clear_output()
|
94 |
|
@@ -103,23 +103,33 @@ if not os.path.exists(flag_file):
|
|
103 |
|
104 |
# =================== OTHER ====================
|
105 |
# Setup Timer
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
if directory_path and os.path.exists(directory_path):
|
115 |
try:
|
116 |
shutil.rmtree(directory_path)
|
117 |
except Exception:
|
118 |
get_ipython().system('rm -rf {directory_path}')
|
119 |
|
120 |
-
|
121 |
-
temporarily_dir = f'{root_path}/temp_dir'
|
122 |
-
|
123 |
def copy_items_with_replace(src_base, dst_base):
|
124 |
items_to_copy = [
|
125 |
'embeddings',
|
@@ -130,14 +140,13 @@ def copy_items_with_replace(src_base, dst_base):
|
|
130 |
]
|
131 |
|
132 |
print("⌚ Moving files...", end='')
|
133 |
-
time.sleep(1)
|
134 |
for item in items_to_copy:
|
135 |
src = os.path.join(src_base, item)
|
136 |
dst = os.path.join(dst_base, item)
|
137 |
|
138 |
if os.path.exists(src):
|
139 |
if os.path.exists(dst):
|
140 |
-
|
141 |
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
142 |
shutil.move(src, dst)
|
143 |
print("\r🔥 Files moved!" + " "*15)
|
@@ -156,40 +165,39 @@ def unpack_webui():
|
|
156 |
start_install = time.time()
|
157 |
print(f"⌚ Unpacking Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...", end='')
|
158 |
|
159 |
-
with capture.capture_output()
|
160 |
download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip"
|
161 |
if UI == 'Forge':
|
162 |
download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip"
|
163 |
|
164 |
-
aria2_args = "--console-log-level=error -c -x 16 -s 16 -k 1M"
|
165 |
zip_path = f"{root_path}/repo.zip"
|
166 |
-
get_ipython().system('aria2c
|
167 |
get_ipython().system('unzip -q -o {zip_path} -d {webui_path}')
|
168 |
get_ipython().system('rm -rf {zip_path}')
|
169 |
|
170 |
-
get_ipython().system(
|
171 |
-
del cap
|
172 |
|
173 |
install_time = time.time() - start_install
|
174 |
minutes, seconds = divmod(int(install_time), 60)
|
175 |
print(f"\r🚀 Unpacking complete! For {minutes:02}:{seconds:02} ⚡" + " "*15)
|
176 |
|
177 |
-
if os.path.exists(
|
178 |
-
copy_items_with_replace(
|
179 |
-
|
180 |
|
181 |
# ================= MAIN CODE ==================
|
182 |
if os.path.exists(webui_path):
|
183 |
if UI != OLD_UI:
|
184 |
print(f'Switching the WebUI from \033[33m{OLD_UI}\033[0m to \033[33m{UI}\033[0m:')
|
185 |
-
copy_items_with_replace(webui_path,
|
186 |
-
|
187 |
os.environ['SDW_OLD_UI'] = UI
|
188 |
time.sleep(2)
|
189 |
clear_output()
|
190 |
|
191 |
if not os.path.exists(webui_path):
|
192 |
unpack_webui()
|
|
|
193 |
else:
|
194 |
print("🚀 All unpacked... Skip. ⚡")
|
195 |
timer_colab = handle_colab_timer(webui_path, start_colab)
|
@@ -201,7 +209,7 @@ else:
|
|
201 |
if latest_webui or latest_exstensions:
|
202 |
action = "WebUI and Extensions" if latest_webui and latest_exstensions else ("WebUI" if latest_webui else "Extensions")
|
203 |
print(f"⌚️ Updating {action}...", end='')
|
204 |
-
with capture.capture_output()
|
205 |
get_ipython().system('git config --global user.email "[email protected]"')
|
206 |
get_ipython().system('git config --global user.name "Your Name"')
|
207 |
|
@@ -214,30 +222,26 @@ if latest_webui or latest_exstensions:
|
|
214 |
## Update extensions
|
215 |
if latest_exstensions:
|
216 |
get_ipython().system('{\'for dir in \' + webui_path + \'/extensions/*/; do cd \\"$dir\\" && git reset --hard && git pull; done\'}')
|
217 |
-
del cap
|
218 |
print(f"\r✨ Updating {action} Completed!")
|
219 |
|
220 |
|
221 |
# === FIXING EXTENSIONS ===
|
222 |
anxety_repos = "https://huggingface.co/NagisaNao/fast_repo/resolve/main"
|
223 |
-
|
224 |
-
with capture.capture_output() as cap:
|
225 |
# --- Umi-Wildcard ---
|
226 |
get_ipython().system("sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default")
|
227 |
# --- Encrypt-Image ---
|
228 |
get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui")
|
229 |
-
del cap
|
230 |
|
231 |
|
232 |
## Version switching
|
233 |
if commit_hash:
|
234 |
print('⏳ Time machine activation...', end="")
|
235 |
-
with capture.capture_output()
|
236 |
get_ipython().run_line_magic('cd', '{webui_path}')
|
237 |
get_ipython().system('git config --global user.email "[email protected]"')
|
238 |
get_ipython().system('git config --global user.name "Your Name"')
|
239 |
get_ipython().system('git reset --hard {commit_hash}')
|
240 |
-
del cap
|
241 |
print(f"\r⌛️ The time machine has been activated! Current commit: \033[34m{commit_hash}\033[0m")
|
242 |
|
243 |
|
@@ -565,9 +569,8 @@ if detailed_download == "on":
|
|
565 |
download(url)
|
566 |
print("\n\033[33m# =============================== #\n\033[0m")
|
567 |
else:
|
568 |
-
with capture.capture_output()
|
569 |
download(url)
|
570 |
-
del cap
|
571 |
|
572 |
print("\r🏁 Download Complete!" + " "*15)
|
573 |
|
@@ -579,12 +582,11 @@ get_ipython().system('find {webui_path} \\( -type d \\( -name ".ipynb_checkpoint
|
|
579 |
## Install of Custom extensions
|
580 |
if len(extension_repo) > 0:
|
581 |
print("✨ Installing custom extensions...", end='')
|
582 |
-
with capture.capture_output()
|
583 |
for repo, repo_name in extension_repo:
|
584 |
if not repo_name:
|
585 |
repo_name = repo.split('/')[-1]
|
586 |
get_ipython().system('cd {extensions_dir} && git clone {repo} {repo_name} && cd {repo_name} && git fetch')
|
587 |
-
del cap
|
588 |
print(f"\r📦 Installed '{len(extension_repo)}', Custom extensions!")
|
589 |
|
590 |
|
|
|
29 |
|
30 |
os.chdir(root_path)
|
31 |
|
32 |
+
|
33 |
# ============ loading settings V4 =============
|
34 |
def load_settings(path):
|
35 |
if os.path.exists(path):
|
|
|
85 |
subprocess.run(install_cmd, shell=True, capture_output=True)
|
86 |
|
87 |
# Additional specific packages
|
88 |
+
with capture.capture_output():
|
89 |
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
90 |
get_ipython().system('curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl')
|
91 |
get_ipython().system('curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.32/zrok_0.4.32_linux_amd64.tar.gz && tar -xzf zrok_0.4.32_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.32_linux_amd64.tar.gz')
|
|
|
92 |
|
93 |
clear_output()
|
94 |
|
|
|
103 |
|
104 |
# =================== OTHER ====================
|
105 |
# Setup Timer
|
106 |
+
start_colab = int(os.environ.get("START_COLAB", time.time() - 5))
|
107 |
+
os.environ["START_COLAB"] = str(start_colab)
|
108 |
+
|
109 |
+
def download_cfg_files(file_paths, destination_path):
|
110 |
+
base_url = "https://huggingface.co/NagisaNao/SD-CONFIGS/resolve/main"
|
111 |
+
for filename in file_paths:
|
112 |
+
file_name = filename.split('/')[-1]
|
113 |
+
get_ipython().system('wget -O {destination_path}/{file_name} {base_url}/{filename}')
|
114 |
+
|
115 |
+
def cfg_download():
|
116 |
+
common_files = ["styles.csv"]
|
117 |
+
a1111_files = ["A1111/config.json", "A1111/ui-config.json"]
|
118 |
+
forge_files = ["reForge/config.json", "reForge/ui-config.json"]
|
119 |
+
|
120 |
+
with capture.capture_output():
|
121 |
+
download_cfg_files(common_files, webui_path)
|
122 |
+
ui_files = a1111_files if UI == 'A1111' else forge_files
|
123 |
+
download_cfg_files(ui_files, webui_path)
|
124 |
+
|
125 |
+
def remove_dir(directory_path):
|
126 |
if directory_path and os.path.exists(directory_path):
|
127 |
try:
|
128 |
shutil.rmtree(directory_path)
|
129 |
except Exception:
|
130 |
get_ipython().system('rm -rf {directory_path}')
|
131 |
|
132 |
+
TEMPORARY_DIR = f'{root_path}/temp_dir'
|
|
|
|
|
133 |
def copy_items_with_replace(src_base, dst_base):
|
134 |
items_to_copy = [
|
135 |
'embeddings',
|
|
|
140 |
]
|
141 |
|
142 |
print("⌚ Moving files...", end='')
|
|
|
143 |
for item in items_to_copy:
|
144 |
src = os.path.join(src_base, item)
|
145 |
dst = os.path.join(dst_base, item)
|
146 |
|
147 |
if os.path.exists(src):
|
148 |
if os.path.exists(dst):
|
149 |
+
remove_dir(dst)
|
150 |
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
151 |
shutil.move(src, dst)
|
152 |
print("\r🔥 Files moved!" + " "*15)
|
|
|
165 |
start_install = time.time()
|
166 |
print(f"⌚ Unpacking Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...", end='')
|
167 |
|
168 |
+
with capture.capture_output():
|
169 |
download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip"
|
170 |
if UI == 'Forge':
|
171 |
download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip"
|
172 |
|
|
|
173 |
zip_path = f"{root_path}/repo.zip"
|
174 |
+
get_ipython().system('aria2c --console-log-level=error -c -x 16 -s 16 -k 1M {download_url} -d {root_path} -o repo.zip')
|
175 |
get_ipython().system('unzip -q -o {zip_path} -d {webui_path}')
|
176 |
get_ipython().system('rm -rf {zip_path}')
|
177 |
|
178 |
+
get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
|
|
179 |
|
180 |
install_time = time.time() - start_install
|
181 |
minutes, seconds = divmod(int(install_time), 60)
|
182 |
print(f"\r🚀 Unpacking complete! For {minutes:02}:{seconds:02} ⚡" + " "*15)
|
183 |
|
184 |
+
if os.path.exists(TEMPORARY_DIR):
|
185 |
+
copy_items_with_replace(TEMPORARY_DIR, webui_path)
|
186 |
+
remove_dir(TEMPORARY_DIR)
|
187 |
|
188 |
# ================= MAIN CODE ==================
|
189 |
if os.path.exists(webui_path):
|
190 |
if UI != OLD_UI:
|
191 |
print(f'Switching the WebUI from \033[33m{OLD_UI}\033[0m to \033[33m{UI}\033[0m:')
|
192 |
+
copy_items_with_replace(webui_path, TEMPORARY_DIR)
|
193 |
+
remove_dir(webui_path)
|
194 |
os.environ['SDW_OLD_UI'] = UI
|
195 |
time.sleep(2)
|
196 |
clear_output()
|
197 |
|
198 |
if not os.path.exists(webui_path):
|
199 |
unpack_webui()
|
200 |
+
cfg_download()
|
201 |
else:
|
202 |
print("🚀 All unpacked... Skip. ⚡")
|
203 |
timer_colab = handle_colab_timer(webui_path, start_colab)
|
|
|
209 |
if latest_webui or latest_exstensions:
|
210 |
action = "WebUI and Extensions" if latest_webui and latest_exstensions else ("WebUI" if latest_webui else "Extensions")
|
211 |
print(f"⌚️ Updating {action}...", end='')
|
212 |
+
with capture.capture_output():
|
213 |
get_ipython().system('git config --global user.email "[email protected]"')
|
214 |
get_ipython().system('git config --global user.name "Your Name"')
|
215 |
|
|
|
222 |
## Update extensions
|
223 |
if latest_exstensions:
|
224 |
get_ipython().system('{\'for dir in \' + webui_path + \'/extensions/*/; do cd \\"$dir\\" && git reset --hard && git pull; done\'}')
|
|
|
225 |
print(f"\r✨ Updating {action} Completed!")
|
226 |
|
227 |
|
228 |
# === FIXING EXTENSIONS ===
|
229 |
anxety_repos = "https://huggingface.co/NagisaNao/fast_repo/resolve/main"
|
230 |
+
with capture.capture_output():
|
|
|
231 |
# --- Umi-Wildcard ---
|
232 |
get_ipython().system("sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default")
|
233 |
# --- Encrypt-Image ---
|
234 |
get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui")
|
|
|
235 |
|
236 |
|
237 |
## Version switching
|
238 |
if commit_hash:
|
239 |
print('⏳ Time machine activation...', end="")
|
240 |
+
with capture.capture_output():
|
241 |
get_ipython().run_line_magic('cd', '{webui_path}')
|
242 |
get_ipython().system('git config --global user.email "[email protected]"')
|
243 |
get_ipython().system('git config --global user.name "Your Name"')
|
244 |
get_ipython().system('git reset --hard {commit_hash}')
|
|
|
245 |
print(f"\r⌛️ The time machine has been activated! Current commit: \033[34m{commit_hash}\033[0m")
|
246 |
|
247 |
|
|
|
569 |
download(url)
|
570 |
print("\n\033[33m# =============================== #\n\033[0m")
|
571 |
else:
|
572 |
+
with capture.capture_output():
|
573 |
download(url)
|
|
|
574 |
|
575 |
print("\r🏁 Download Complete!" + " "*15)
|
576 |
|
|
|
582 |
## Install of Custom extensions
|
583 |
if len(extension_repo) > 0:
|
584 |
print("✨ Installing custom extensions...", end='')
|
585 |
+
with capture.capture_output():
|
586 |
for repo, repo_name in extension_repo:
|
587 |
if not repo_name:
|
588 |
repo_name = repo.split('/')[-1]
|
589 |
get_ipython().system('cd {extensions_dir} && git clone {repo} {repo_name} && cd {repo_name} && git fetch')
|
|
|
590 |
print(f"\r📦 Installed '{len(extension_repo)}', Custom extensions!")
|
591 |
|
592 |
|
files_cells/python/en/widgets_en.py
CHANGED
@@ -3,8 +3,7 @@
|
|
3 |
import os
|
4 |
import json
|
5 |
import time
|
6 |
-
|
7 |
-
from ipywidgets import widgets, Layout, Label, Button, VBox, HBox
|
8 |
from IPython.display import display, HTML, Javascript, clear_output
|
9 |
|
10 |
|
|
|
3 |
import os
|
4 |
import json
|
5 |
import time
|
6 |
+
from ipywidgets import widgets
|
|
|
7 |
from IPython.display import display, HTML, Javascript, clear_output
|
8 |
|
9 |
|
files_cells/python/ru/auto_cleaner_ru.py
CHANGED
@@ -4,8 +4,7 @@ from directory_setup import models_dir, vaes_dir, control_dir, loras_dir, output
|
|
4 |
|
5 |
import os
|
6 |
import time
|
7 |
-
|
8 |
-
from ipywidgets import Label, Button, VBox, HBox
|
9 |
from IPython.display import display, HTML
|
10 |
|
11 |
|
@@ -34,7 +33,7 @@ directories = {
|
|
34 |
}
|
35 |
|
36 |
""" functions """
|
37 |
-
def clean_directory(directory):
|
38 |
deleted_files = 0
|
39 |
|
40 |
for root, dirs, files in os.walk(directory):
|
@@ -43,7 +42,7 @@ def clean_directory(directory):
|
|
43 |
|
44 |
if file.endswith(".txt"):
|
45 |
continue
|
46 |
-
if file.endswith((".safetensors", ".pt"
|
47 |
deleted_files += 1
|
48 |
|
49 |
os.remove(file_path)
|
@@ -65,7 +64,7 @@ def on_execute_button_press(button):
|
|
65 |
|
66 |
for option in selected_cleaners:
|
67 |
if option in directories:
|
68 |
-
deleted_files_dict[option] = clean_directory(directories[option])
|
69 |
|
70 |
output.clear_output()
|
71 |
|
|
|
4 |
|
5 |
import os
|
6 |
import time
|
7 |
+
from ipywidgets import widgets
|
|
|
8 |
from IPython.display import display, HTML
|
9 |
|
10 |
|
|
|
33 |
}
|
34 |
|
35 |
""" functions """
|
36 |
+
def clean_directory(directory, directory_type):
|
37 |
deleted_files = 0
|
38 |
|
39 |
for root, dirs, files in os.walk(directory):
|
|
|
42 |
|
43 |
if file.endswith(".txt"):
|
44 |
continue
|
45 |
+
if file.endswith((".safetensors", ".pt")) or directory_type == "Images":
|
46 |
deleted_files += 1
|
47 |
|
48 |
os.remove(file_path)
|
|
|
64 |
|
65 |
for option in selected_cleaners:
|
66 |
if option in directories:
|
67 |
+
deleted_files_dict[option] = clean_directory(directories[option], option)
|
68 |
|
69 |
output.clear_output()
|
70 |
|
files_cells/python/ru/downloading_ru.py
CHANGED
@@ -29,6 +29,7 @@ OLD_UI = os.getenv('SDW_OLD_UI')
|
|
29 |
|
30 |
os.chdir(root_path)
|
31 |
|
|
|
32 |
# ============ loading settings V4 =============
|
33 |
def load_settings(path):
|
34 |
if os.path.exists(path):
|
@@ -84,11 +85,10 @@ if not os.path.exists(flag_file):
|
|
84 |
subprocess.run(install_cmd, shell=True, capture_output=True)
|
85 |
|
86 |
# Additional specific packages
|
87 |
-
with capture.capture_output()
|
88 |
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
89 |
get_ipython().system('curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl')
|
90 |
get_ipython().system('curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.32/zrok_0.4.32_linux_amd64.tar.gz && tar -xzf zrok_0.4.32_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.32_linux_amd64.tar.gz')
|
91 |
-
del cap
|
92 |
|
93 |
clear_output()
|
94 |
|
@@ -103,23 +103,33 @@ if not os.path.exists(flag_file):
|
|
103 |
|
104 |
# =================== OTHER ====================
|
105 |
# Setup Timer
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
if directory_path and os.path.exists(directory_path):
|
115 |
try:
|
116 |
shutil.rmtree(directory_path)
|
117 |
except Exception:
|
118 |
get_ipython().system('rm -rf {directory_path}')
|
119 |
|
120 |
-
|
121 |
-
temporarily_dir = f'{root_path}/temp_dir'
|
122 |
-
|
123 |
def copy_items_with_replace(src_base, dst_base):
|
124 |
items_to_copy = [
|
125 |
'embeddings',
|
@@ -130,14 +140,13 @@ def copy_items_with_replace(src_base, dst_base):
|
|
130 |
]
|
131 |
|
132 |
print("⌚ Перемещение файлов...", end='')
|
133 |
-
time.sleep(1)
|
134 |
for item in items_to_copy:
|
135 |
src = os.path.join(src_base, item)
|
136 |
dst = os.path.join(dst_base, item)
|
137 |
|
138 |
if os.path.exists(src):
|
139 |
if os.path.exists(dst):
|
140 |
-
|
141 |
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
142 |
shutil.move(src, dst)
|
143 |
print("\r🔥 Файлы перемещены!" + " "*15)
|
@@ -156,40 +165,39 @@ def unpack_webui():
|
|
156 |
start_install = time.time()
|
157 |
print(f"⌚ Распаковка Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...", end='')
|
158 |
|
159 |
-
with capture.capture_output()
|
160 |
download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip"
|
161 |
if UI == 'Forge':
|
162 |
download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip"
|
163 |
|
164 |
-
aria2_args = "--console-log-level=error -c -x 16 -s 16 -k 1M"
|
165 |
zip_path = f"{root_path}/repo.zip"
|
166 |
-
get_ipython().system('aria2c
|
167 |
get_ipython().system('unzip -q -o {zip_path} -d {webui_path}')
|
168 |
get_ipython().system('rm -rf {zip_path}')
|
169 |
|
170 |
-
get_ipython().system(
|
171 |
-
del cap
|
172 |
|
173 |
install_time = time.time() - start_install
|
174 |
minutes, seconds = divmod(int(install_time), 60)
|
175 |
print(f"\r🚀 Распаковка Завершена! За {minutes:02}:{seconds:02} ⚡" + " "*15)
|
176 |
|
177 |
-
if os.path.exists(
|
178 |
-
copy_items_with_replace(
|
179 |
-
|
180 |
|
181 |
# ================= MAIN CODE ==================
|
182 |
if os.path.exists(webui_path):
|
183 |
if UI != OLD_UI:
|
184 |
print(f'Переключение веб-интерфейса с \033[33m{OLD_UI}\033[0m на \033[33m{UI}\033[0m:')
|
185 |
-
copy_items_with_replace(webui_path,
|
186 |
-
|
187 |
os.environ['SDW_OLD_UI'] = UI
|
188 |
time.sleep(2)
|
189 |
clear_output()
|
190 |
|
191 |
if not os.path.exists(webui_path):
|
192 |
unpack_webui()
|
|
|
193 |
else:
|
194 |
print("🚀 Все распакованно... Пропуск. ⚡")
|
195 |
timer_colab = handle_colab_timer(webui_path, start_colab)
|
@@ -201,7 +209,7 @@ else:
|
|
201 |
if latest_webui or latest_exstensions:
|
202 |
action = "WebUI и Расширений" if latest_webui and latest_exstensions else ("WebUI" if latest_webui else "Расширений")
|
203 |
print(f"⌚️ Обновление {action}...", end='')
|
204 |
-
with capture.capture_output()
|
205 |
get_ipython().system('git config --global user.email "[email protected]"')
|
206 |
get_ipython().system('git config --global user.name "Your Name"')
|
207 |
|
@@ -214,30 +222,26 @@ if latest_webui or latest_exstensions:
|
|
214 |
## Update extensions
|
215 |
if latest_exstensions:
|
216 |
get_ipython().system('{\'for dir in \' + webui_path + \'/extensions/*/; do cd \\"$dir\\" && git reset --hard && git pull; done\'}')
|
217 |
-
del cap
|
218 |
print(f"\r✨ Обновление {action} Завершено!")
|
219 |
|
220 |
|
221 |
# === FIXING EXTENSIONS ===
|
222 |
anxety_repos = "https://huggingface.co/NagisaNao/fast_repo/resolve/main"
|
223 |
-
|
224 |
-
with capture.capture_output() as cap:
|
225 |
# --- Umi-Wildcard ---
|
226 |
get_ipython().system("sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default")
|
227 |
# --- Encrypt-Image ---
|
228 |
get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui")
|
229 |
-
del cap
|
230 |
|
231 |
|
232 |
## Version switching
|
233 |
if commit_hash:
|
234 |
print('⏳ Активация машины времени...', end="")
|
235 |
-
with capture.capture_output()
|
236 |
get_ipython().run_line_magic('cd', '{webui_path}')
|
237 |
get_ipython().system('git config --global user.email "[email protected]"')
|
238 |
get_ipython().system('git config --global user.name "Your Name"')
|
239 |
get_ipython().system('git reset --hard {commit_hash}')
|
240 |
-
del cap
|
241 |
print(f"\r⌛️ Машина времени активированна! Текущий коммит: \033[34m{commit_hash}\033[0m")
|
242 |
|
243 |
|
@@ -565,9 +569,8 @@ if detailed_download == "on":
|
|
565 |
download(url)
|
566 |
print("\n\033[33m# =============================== #\n\033[0m")
|
567 |
else:
|
568 |
-
with capture.capture_output()
|
569 |
download(url)
|
570 |
-
del cap
|
571 |
|
572 |
print("\r🏁 Скачивание Завершено!" + " "*15)
|
573 |
|
@@ -579,12 +582,11 @@ get_ipython().system('find {webui_path} \\( -type d \\( -name ".ipynb_checkpoint
|
|
579 |
## Install of Custom extensions
|
580 |
if len(extension_repo) > 0:
|
581 |
print("✨ Установка кастомных расширений...", end='')
|
582 |
-
with capture.capture_output()
|
583 |
for repo, repo_name in extension_repo:
|
584 |
if not repo_name:
|
585 |
repo_name = repo.split('/')[-1]
|
586 |
get_ipython().system('cd {extensions_dir} && git clone {repo} {repo_name} && cd {repo_name} && git fetch')
|
587 |
-
del cap
|
588 |
print(f"\r📦 Установлено '{len(extension_repo)}', Кастомных расширений!")
|
589 |
|
590 |
|
|
|
29 |
|
30 |
os.chdir(root_path)
|
31 |
|
32 |
+
|
33 |
# ============ loading settings V4 =============
|
34 |
def load_settings(path):
|
35 |
if os.path.exists(path):
|
|
|
85 |
subprocess.run(install_cmd, shell=True, capture_output=True)
|
86 |
|
87 |
# Additional specific packages
|
88 |
+
with capture.capture_output()
|
89 |
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
90 |
get_ipython().system('curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl')
|
91 |
get_ipython().system('curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.32/zrok_0.4.32_linux_amd64.tar.gz && tar -xzf zrok_0.4.32_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.32_linux_amd64.tar.gz')
|
|
|
92 |
|
93 |
clear_output()
|
94 |
|
|
|
103 |
|
104 |
# =================== OTHER ====================
|
105 |
# Setup Timer
|
106 |
+
start_colab = int(os.environ.get("START_COLAB", time.time() - 5))
|
107 |
+
os.environ["START_COLAB"] = str(start_colab)
|
108 |
+
|
109 |
+
def download_cfg_files(file_paths, destination_path):
|
110 |
+
base_url = "https://huggingface.co/NagisaNao/SD-CONFIGS/resolve/main"
|
111 |
+
for filename in file_paths:
|
112 |
+
file_name = filename.split('/')[-1]
|
113 |
+
get_ipython().system('wget -O {destination_path}/{file_name} {base_url}/{filename}')
|
114 |
+
|
115 |
+
def cfg_download():
|
116 |
+
common_files = ["styles.csv"]
|
117 |
+
a1111_files = ["A1111/config.json", "A1111/ui-config.json"]
|
118 |
+
forge_files = ["reForge/config.json", "reForge/ui-config.json"]
|
119 |
+
|
120 |
+
with capture.capture_output():
|
121 |
+
download_cfg_files(common_files, webui_path)
|
122 |
+
ui_files = a1111_files if UI == 'A1111' else forge_files
|
123 |
+
download_cfg_files(ui_files, webui_path)
|
124 |
+
|
125 |
+
def remove_dir(directory_path):
|
126 |
if directory_path and os.path.exists(directory_path):
|
127 |
try:
|
128 |
shutil.rmtree(directory_path)
|
129 |
except Exception:
|
130 |
get_ipython().system('rm -rf {directory_path}')
|
131 |
|
132 |
+
TEMPORARY_DIR = f'{root_path}/temp_dir'
|
|
|
|
|
133 |
def copy_items_with_replace(src_base, dst_base):
|
134 |
items_to_copy = [
|
135 |
'embeddings',
|
|
|
140 |
]
|
141 |
|
142 |
print("⌚ Перемещение файлов...", end='')
|
|
|
143 |
for item in items_to_copy:
|
144 |
src = os.path.join(src_base, item)
|
145 |
dst = os.path.join(dst_base, item)
|
146 |
|
147 |
if os.path.exists(src):
|
148 |
if os.path.exists(dst):
|
149 |
+
remove_dir(dst)
|
150 |
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
151 |
shutil.move(src, dst)
|
152 |
print("\r🔥 Файлы перемещены!" + " "*15)
|
|
|
165 |
start_install = time.time()
|
166 |
print(f"⌚ Распаковка Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...", end='')
|
167 |
|
168 |
+
with capture.capture_output():
|
169 |
download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip"
|
170 |
if UI == 'Forge':
|
171 |
download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip"
|
172 |
|
|
|
173 |
zip_path = f"{root_path}/repo.zip"
|
174 |
+
get_ipython().system('aria2c --console-log-level=error -c -x 16 -s 16 -k 1M {download_url} -d {root_path} -o repo.zip')
|
175 |
get_ipython().system('unzip -q -o {zip_path} -d {webui_path}')
|
176 |
get_ipython().system('rm -rf {zip_path}')
|
177 |
|
178 |
+
get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
|
|
179 |
|
180 |
install_time = time.time() - start_install
|
181 |
minutes, seconds = divmod(int(install_time), 60)
|
182 |
print(f"\r🚀 Распаковка Завершена! За {minutes:02}:{seconds:02} ⚡" + " "*15)
|
183 |
|
184 |
+
if os.path.exists(TEMPORARY_DIR):
|
185 |
+
copy_items_with_replace(TEMPORARY_DIR, webui_path)
|
186 |
+
remove_dir(TEMPORARY_DIR)
|
187 |
|
188 |
# ================= MAIN CODE ==================
|
189 |
if os.path.exists(webui_path):
|
190 |
if UI != OLD_UI:
|
191 |
print(f'Переключение веб-интерфейса с \033[33m{OLD_UI}\033[0m на \033[33m{UI}\033[0m:')
|
192 |
+
copy_items_with_replace(webui_path, TEMPORARY_DIR)
|
193 |
+
remove_dir(webui_path)
|
194 |
os.environ['SDW_OLD_UI'] = UI
|
195 |
time.sleep(2)
|
196 |
clear_output()
|
197 |
|
198 |
if not os.path.exists(webui_path):
|
199 |
unpack_webui()
|
200 |
+
cfg_download()
|
201 |
else:
|
202 |
print("🚀 Все распакованно... Пропуск. ⚡")
|
203 |
timer_colab = handle_colab_timer(webui_path, start_colab)
|
|
|
209 |
if latest_webui or latest_exstensions:
|
210 |
action = "WebUI и Расширений" if latest_webui and latest_exstensions else ("WebUI" if latest_webui else "Расширений")
|
211 |
print(f"⌚️ Обновление {action}...", end='')
|
212 |
+
with capture.capture_output():
|
213 |
get_ipython().system('git config --global user.email "[email protected]"')
|
214 |
get_ipython().system('git config --global user.name "Your Name"')
|
215 |
|
|
|
222 |
## Update extensions
|
223 |
if latest_exstensions:
|
224 |
get_ipython().system('{\'for dir in \' + webui_path + \'/extensions/*/; do cd \\"$dir\\" && git reset --hard && git pull; done\'}')
|
|
|
225 |
print(f"\r✨ Обновление {action} Завершено!")
|
226 |
|
227 |
|
228 |
# === FIXING EXTENSIONS ===
|
229 |
anxety_repos = "https://huggingface.co/NagisaNao/fast_repo/resolve/main"
|
230 |
+
with capture.capture_output():
|
|
|
231 |
# --- Umi-Wildcard ---
|
232 |
get_ipython().system("sed -i '521s/open=\\(False\\|True\\)/open=False/' {webui_path}/extensions/Umi-AI-Wildcards/scripts/wildcard_recursive.py # Closed accordion by default")
|
233 |
# --- Encrypt-Image ---
|
234 |
get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js # Removes the weird text in webui")
|
|
|
235 |
|
236 |
|
237 |
## Version switching
|
238 |
if commit_hash:
|
239 |
print('⏳ Активация машины времени...', end="")
|
240 |
+
with capture.capture_output():
|
241 |
get_ipython().run_line_magic('cd', '{webui_path}')
|
242 |
get_ipython().system('git config --global user.email "[email protected]"')
|
243 |
get_ipython().system('git config --global user.name "Your Name"')
|
244 |
get_ipython().system('git reset --hard {commit_hash}')
|
|
|
245 |
print(f"\r⌛️ Машина времени активированна! Текущий коммит: \033[34m{commit_hash}\033[0m")
|
246 |
|
247 |
|
|
|
569 |
download(url)
|
570 |
print("\n\033[33m# =============================== #\n\033[0m")
|
571 |
else:
|
572 |
+
with capture.capture_output():
|
573 |
download(url)
|
|
|
574 |
|
575 |
print("\r🏁 Скачивание Завершено!" + " "*15)
|
576 |
|
|
|
582 |
## Install of Custom extensions
|
583 |
if len(extension_repo) > 0:
|
584 |
print("✨ Установка кастомных расширений...", end='')
|
585 |
+
with capture.capture_output():
|
586 |
for repo, repo_name in extension_repo:
|
587 |
if not repo_name:
|
588 |
repo_name = repo.split('/')[-1]
|
589 |
get_ipython().system('cd {extensions_dir} && git clone {repo} {repo_name} && cd {repo_name} && git fetch')
|
|
|
590 |
print(f"\r📦 Установлено '{len(extension_repo)}', Кастомных расширений!")
|
591 |
|
592 |
|
files_cells/python/ru/widgets_ru.py
CHANGED
@@ -3,8 +3,7 @@
|
|
3 |
import os
|
4 |
import json
|
5 |
import time
|
6 |
-
|
7 |
-
from ipywidgets import widgets, Layout, Label, Button, VBox, HBox
|
8 |
from IPython.display import display, HTML, Javascript, clear_output
|
9 |
|
10 |
|
|
|
3 |
import os
|
4 |
import json
|
5 |
import time
|
6 |
+
from ipywidgets import widgets
|
|
|
7 |
from IPython.display import display, HTML, Javascript, clear_output
|
8 |
|
9 |
|