Delete sagemaker/files_cells
Browse files- sagemaker/files_cells/notebooks/en/auto-cleaner_en.ipynb +0 -380
- sagemaker/files_cells/notebooks/en/downloading_en.ipynb +0 -594
- sagemaker/files_cells/notebooks/en/launch_en.ipynb +0 -134
- sagemaker/files_cells/notebooks/en/widgets_en.ipynb +0 -619
- sagemaker/files_cells/notebooks/ru/auto-cleaner_ru.ipynb +0 -380
- sagemaker/files_cells/notebooks/ru/downloading_ru.ipynb +0 -594
- sagemaker/files_cells/notebooks/ru/launch_ru.ipynb +0 -134
- sagemaker/files_cells/notebooks/ru/widgets_ru.ipynb +0 -619
- sagemaker/files_cells/python/en/auto-cleaner_en.py +0 -353
- sagemaker/files_cells/python/en/downloading_en.py +0 -564
- sagemaker/files_cells/python/en/launch_en.py +0 -107
- sagemaker/files_cells/python/en/widgets_en.py +0 -592
- sagemaker/files_cells/python/ru/auto-cleaner_ru.py +0 -353
- sagemaker/files_cells/python/ru/downloading_ru.py +0 -564
- sagemaker/files_cells/python/ru/launch_ru.py +0 -107
- sagemaker/files_cells/python/ru/widgets_ru.py +0 -592
sagemaker/files_cells/notebooks/en/auto-cleaner_en.ipynb
DELETED
@@ -1,380 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"nbformat": 4,
|
3 |
-
"nbformat_minor": 0,
|
4 |
-
"metadata": {
|
5 |
-
"colab": {
|
6 |
-
"provenance": []
|
7 |
-
},
|
8 |
-
"kernelspec": {
|
9 |
-
"name": "python3",
|
10 |
-
"display_name": "Python 3"
|
11 |
-
},
|
12 |
-
"language_info": {
|
13 |
-
"name": "python"
|
14 |
-
}
|
15 |
-
},
|
16 |
-
"cells": [
|
17 |
-
{
|
18 |
-
"cell_type": "code",
|
19 |
-
"source": [
|
20 |
-
"##~ AutoCleaner V3.6 CODE | BY: ANXETY ~##\n",
|
21 |
-
"\n",
|
22 |
-
"# --change log--\n",
|
23 |
-
"\"\"\"\n",
|
24 |
-
"V3.6 | 13.03.24\n",
|
25 |
-
"Fixed selection window\n",
|
26 |
-
"Dynamic update of memory display\n",
|
27 |
-
"\"\"\"\n",
|
28 |
-
"\n",
|
29 |
-
"\n",
|
30 |
-
"import os\n",
|
31 |
-
"import time\n",
|
32 |
-
"import ipywidgets as widgets\n",
|
33 |
-
"from ipywidgets import Label, Button, VBox, HBox\n",
|
34 |
-
"from IPython.display import display, HTML, Javascript\n",
|
35 |
-
"\n",
|
36 |
-
"\n",
|
37 |
-
"# ================= DETECT ENV =================\n",
|
38 |
-
"def detect_environment():\n",
|
39 |
-
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
40 |
-
" environments = {\n",
|
41 |
-
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
42 |
-
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
43 |
-
" 'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', \"/home/studio-lab-user/content\")\n",
|
44 |
-
" }\n",
|
45 |
-
"\n",
|
46 |
-
" for env_var, (environment, path) in environments.items():\n",
|
47 |
-
" if env_var in os.environ:\n",
|
48 |
-
" return environment, path, free_plan\n",
|
49 |
-
"\n",
|
50 |
-
"env, root_path, free_plan = detect_environment()\n",
|
51 |
-
"webui_path = f\"{root_path}/sdw\"\n",
|
52 |
-
"# ----------------------------------------------\n",
|
53 |
-
"\n",
|
54 |
-
"\n",
|
55 |
-
"directories = {\n",
|
56 |
-
" \"Images\": f\"{webui_path}/outputs\",\n",
|
57 |
-
" \"Models\": f\"{webui_path}/models/Stable-diffusion/\",\n",
|
58 |
-
" \"Vae\": f\"{webui_path}/models/VAE/\",\n",
|
59 |
-
" \"LoRa\": f\"{webui_path}/models/Lora/\",\n",
|
60 |
-
" \"ControlNet Models\": f\"{webui_path}/models/ControlNet/\"\n",
|
61 |
-
"}\n",
|
62 |
-
"\n",
|
63 |
-
"\n",
|
64 |
-
"# ==================== CSS ====================\n",
|
65 |
-
"CSS = \"\"\"\n",
|
66 |
-
"<style>\n",
|
67 |
-
"/* General Styles */\n",
|
68 |
-
"\n",
|
69 |
-
"hr {\n",
|
70 |
-
" border-color: grey;\n",
|
71 |
-
" background-color: grey;\n",
|
72 |
-
" opacity: 0.25;\n",
|
73 |
-
"}\n",
|
74 |
-
"\n",
|
75 |
-
".instruction_AC {\n",
|
76 |
-
" font-family: cursive;\n",
|
77 |
-
" font-size: 18px;\n",
|
78 |
-
" color: grey;\n",
|
79 |
-
" user-select: none;\n",
|
80 |
-
" cursor: default;\n",
|
81 |
-
"}\n",
|
82 |
-
"\n",
|
83 |
-
"\n",
|
84 |
-
"/* Container style */\n",
|
85 |
-
"\n",
|
86 |
-
".container_AC {\n",
|
87 |
-
" position: relative;\n",
|
88 |
-
" background-color: #232323;\n",
|
89 |
-
" width: 800px;\n",
|
90 |
-
" height: auto;\n",
|
91 |
-
" padding: 15px;\n",
|
92 |
-
" border-radius: 15px;\n",
|
93 |
-
" box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);\n",
|
94 |
-
" margin-bottom: 5px;\n",
|
95 |
-
" overflow: visible;\n",
|
96 |
-
"}\n",
|
97 |
-
"\n",
|
98 |
-
".container_AC::before {\n",
|
99 |
-
" position: absolute;\n",
|
100 |
-
" top: 5px;\n",
|
101 |
-
" right: 10px;\n",
|
102 |
-
" content: \"AutoCleanerV3.6\";\n",
|
103 |
-
" font-weight: bold;\n",
|
104 |
-
" font-size: 24px;\n",
|
105 |
-
" color: rgba(0, 0, 0, 0.2);\n",
|
106 |
-
"}\n",
|
107 |
-
"\n",
|
108 |
-
".container_AC::after {\n",
|
109 |
-
" position: absolute;\n",
|
110 |
-
" top: 30px;\n",
|
111 |
-
" right: 10px;\n",
|
112 |
-
" content: \"ANXETY\";\n",
|
113 |
-
" font-weight: bold;\n",
|
114 |
-
" font-size: 18px;\n",
|
115 |
-
" color: rgba(0, 0, 0, 0.2);\n",
|
116 |
-
"}\n",
|
117 |
-
"\n",
|
118 |
-
".custom-select-multiple_AC select {\n",
|
119 |
-
" padding: 10px;\n",
|
120 |
-
" font-family: cursive;\n",
|
121 |
-
" border: 1px solid #262626 !important;\n",
|
122 |
-
" border-radius: 10px;\n",
|
123 |
-
" color: white;\n",
|
124 |
-
" background-color: #1c1c1c;\n",
|
125 |
-
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
126 |
-
"}\n",
|
127 |
-
"\n",
|
128 |
-
".output_AC {\n",
|
129 |
-
" padding: 10px;\n",
|
130 |
-
" height: auto;\n",
|
131 |
-
" border: 1px solid #262626;\n",
|
132 |
-
" border-radius: 10px;\n",
|
133 |
-
" background-color: #1c1c1c;\n",
|
134 |
-
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
135 |
-
" width: auto;\n",
|
136 |
-
" box-sizing: border-box;\n",
|
137 |
-
"}\n",
|
138 |
-
"\n",
|
139 |
-
".output_message_AC {\n",
|
140 |
-
" font-family: cursive;\n",
|
141 |
-
" color: white !important;\n",
|
142 |
-
" font-size: 14px;\n",
|
143 |
-
" user-select: none;\n",
|
144 |
-
" cursor: default\n",
|
145 |
-
"}\n",
|
146 |
-
"\n",
|
147 |
-
"\n",
|
148 |
-
".storage_info_AC {\n",
|
149 |
-
" padding: 5px 20px;\n",
|
150 |
-
" height: auto;\n",
|
151 |
-
" border: 1px solid #262626;\n",
|
152 |
-
" border-radius: 10px;\n",
|
153 |
-
" background-color: #1c1c1c;\n",
|
154 |
-
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
155 |
-
" width: auto;\n",
|
156 |
-
" font-family: cursive;\n",
|
157 |
-
" color: #B2B2B2 !important;\n",
|
158 |
-
" font-size: 14px;\n",
|
159 |
-
" user-select: none;\n",
|
160 |
-
" cursor: default\n",
|
161 |
-
"}\n",
|
162 |
-
"\n",
|
163 |
-
"\n",
|
164 |
-
"/* Button and storage info layout */\n",
|
165 |
-
".lower_information_panel_AC {\n",
|
166 |
-
" display: flex;\n",
|
167 |
-
" align-items: center;\n",
|
168 |
-
" justify-content: space-between;\n",
|
169 |
-
"}\n",
|
170 |
-
"\n",
|
171 |
-
"\n",
|
172 |
-
"/* Button style */\n",
|
173 |
-
"\n",
|
174 |
-
".button_AC {\n",
|
175 |
-
" width: auto;\n",
|
176 |
-
" font-family: cursive;\n",
|
177 |
-
" color: white !important;\n",
|
178 |
-
" font-size: 14px;\n",
|
179 |
-
" font-weight: bold;\n",
|
180 |
-
" height: 35px;\n",
|
181 |
-
" border-radius: 15px;\n",
|
182 |
-
" background-image: radial-gradient(circle at top left, purple 10%, violet 90%);\n",
|
183 |
-
" background-size: 200% 200%;\n",
|
184 |
-
" background-position: left bottom;\n",
|
185 |
-
" transition: background 0.5s ease-in-out, transform 0.3s ease;\n",
|
186 |
-
"}\n",
|
187 |
-
"\n",
|
188 |
-
".button_AC:hover {\n",
|
189 |
-
" cursor: pointer;\n",
|
190 |
-
" background-size: 200% 200%;\n",
|
191 |
-
" background-position: right bottom;\n",
|
192 |
-
" transform: translateY(1px);\n",
|
193 |
-
"}\n",
|
194 |
-
"\n",
|
195 |
-
".button_execute_AC:hover {\n",
|
196 |
-
" background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);\n",
|
197 |
-
"}\n",
|
198 |
-
"\n",
|
199 |
-
".button_clear_AC:hover {\n",
|
200 |
-
" background-image: radial-gradient(circle at top left, purple 10%, #fc3468 90%);\n",
|
201 |
-
"}\n",
|
202 |
-
"\n",
|
203 |
-
".button_execute_AC:active,\n",
|
204 |
-
".button_clear_AC:active {\n",
|
205 |
-
" filter: brightness(0.75);\n",
|
206 |
-
"}\n",
|
207 |
-
"\n",
|
208 |
-
".jupyter-widgets.lm-Widget:focus {\n",
|
209 |
-
" outline: none;\n",
|
210 |
-
"}\n",
|
211 |
-
"\n",
|
212 |
-
"\n",
|
213 |
-
"/* Animation of elements */\n",
|
214 |
-
"\n",
|
215 |
-
"/* Emergence */\n",
|
216 |
-
".container_AC {\n",
|
217 |
-
" animation-name: slideInTopBlur;\n",
|
218 |
-
" animation-duration: 0.7s;\n",
|
219 |
-
" animation-fill-mode: forwards;\n",
|
220 |
-
"}\n",
|
221 |
-
"\n",
|
222 |
-
"@keyframes slideInTopBlur {\n",
|
223 |
-
" 0% {\n",
|
224 |
-
" transform: translate3d(0, 50%, 0) scale(0.85) rotate3d(1, 0, 0, -85deg);\n",
|
225 |
-
" filter: blur(5px) grayscale(1) brightness(0.5);\n",
|
226 |
-
" opacity: 0;\n",
|
227 |
-
" }\n",
|
228 |
-
" 100% {\n",
|
229 |
-
" transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);\n",
|
230 |
-
" filter: blur(0) grayscale(0) brightness(1);\n",
|
231 |
-
" opacity: 1;\n",
|
232 |
-
" }\n",
|
233 |
-
"}\n",
|
234 |
-
"\n",
|
235 |
-
"/* Leaving */\n",
|
236 |
-
".container_AC.hide {\n",
|
237 |
-
" animation-name: slideOutTopBlur;\n",
|
238 |
-
" animation-duration: 0.5s;\n",
|
239 |
-
" animation-fill-mode: forwards;\n",
|
240 |
-
"}\n",
|
241 |
-
"\n",
|
242 |
-
"@keyframes slideOutTopBlur {\n",
|
243 |
-
" 0% {\n",
|
244 |
-
" transform: translate3d(0, 0, 0) scale(1);\n",
|
245 |
-
" filter: blur(0) grayscale(0) brightness(1);\n",
|
246 |
-
" opacity: 1;\n",
|
247 |
-
" }\n",
|
248 |
-
" 100% {\n",
|
249 |
-
" transform: translate3d(0, -100%, 0);\n",
|
250 |
-
" filter: blur(5px) grayscale(1) brightness(0);\n",
|
251 |
-
" opacity: 0;\n",
|
252 |
-
" }\n",
|
253 |
-
"}\n",
|
254 |
-
"</style>\n",
|
255 |
-
"\"\"\"\n",
|
256 |
-
"\n",
|
257 |
-
"display(HTML(CSS))\n",
|
258 |
-
"# ==================== CSS ====================\n",
|
259 |
-
"\n",
|
260 |
-
"\n",
|
261 |
-
"# ================ AutoCleaner function ================\n",
|
262 |
-
"def clean_directory(directory):\n",
|
263 |
-
" deleted_files = 0\n",
|
264 |
-
" for root, dirs, files in os.walk(directory):\n",
|
265 |
-
" for file in files:\n",
|
266 |
-
" if file.endswith(\".txt\"):\n",
|
267 |
-
" continue\n",
|
268 |
-
" os.remove(os.path.join(root, file))\n",
|
269 |
-
" if not file.endswith(\".yaml\"):\n",
|
270 |
-
" deleted_files += 1\n",
|
271 |
-
" return deleted_files\n",
|
272 |
-
"\n",
|
273 |
-
"\n",
|
274 |
-
"def get_word_variant(n, variants):\n",
|
275 |
-
" unit = abs(n) % 10\n",
|
276 |
-
" tens = abs(n) % 100\n",
|
277 |
-
" if tens in range(11, 15):\n",
|
278 |
-
" return variants[2]\n",
|
279 |
-
" elif unit == 1:\n",
|
280 |
-
" return variants[0]\n",
|
281 |
-
" elif unit in range(2, 5):\n",
|
282 |
-
" return variants[1]\n",
|
283 |
-
" else:\n",
|
284 |
-
" return variants[2]\n",
|
285 |
-
"\n",
|
286 |
-
"\n",
|
287 |
-
"def update_memory_info():\n",
|
288 |
-
" disk_space = psutil.disk_usage(os.getcwd())\n",
|
289 |
-
" total = disk_space.total / (1024 ** 3)\n",
|
290 |
-
" used = disk_space.used / (1024 ** 3)\n",
|
291 |
-
" free = disk_space.free / (1024 ** 3)\n",
|
292 |
-
"\n",
|
293 |
-
" storage_info.value = f'''\n",
|
294 |
-
" <div class=\"storage_info_AC\">Total storage: {total:.2f} GB <span style=\"color: #555\">|</span> Used: {used:.2f} GB <span style=\"color: #555\">|</span> Free: {free:.2f} GB</div>\n",
|
295 |
-
" '''\n",
|
296 |
-
"\n",
|
297 |
-
"\n",
|
298 |
-
"def on_execute_button_press(button):\n",
|
299 |
-
" selected_cleaners = auto_cleaner_widget.value\n",
|
300 |
-
" deleted_files_dict = {}\n",
|
301 |
-
"\n",
|
302 |
-
" for option in selected_cleaners:\n",
|
303 |
-
" if option in directories:\n",
|
304 |
-
" deleted_files_dict[option] = clean_directory(directories[option])\n",
|
305 |
-
"\n",
|
306 |
-
" output.clear_output()\n",
|
307 |
-
"\n",
|
308 |
-
" with output:\n",
|
309 |
-
" for message in generate_messages(deleted_files_dict):\n",
|
310 |
-
" message_widget = HTML(f'<p class=\"output_message_AC\">{message}</p>')\n",
|
311 |
-
" display(message_widget)\n",
|
312 |
-
"\n",
|
313 |
-
" update_memory_info()\n",
|
314 |
-
"\n",
|
315 |
-
"\n",
|
316 |
-
"def on_clear_button_press(button):\n",
|
317 |
-
" container.add_class(\"hide\")\n",
|
318 |
-
" time.sleep(0.5)\n",
|
319 |
-
" widgets.Widget.close_all()\n",
|
320 |
-
"\n",
|
321 |
-
"\n",
|
322 |
-
"def generate_messages(deleted_files_dict):\n",
|
323 |
-
" messages = []\n",
|
324 |
-
" word_variants = {\n",
|
325 |
-
" \"Images\": [\"Image\", \"Images\", \"Images\"],\n",
|
326 |
-
" \"Models\": [\"Model\", \"Models\", \"Models\"],\n",
|
327 |
-
" \"Vae\": [\"VAE\", \"VAE\", \"VAE\"],\n",
|
328 |
-
" \"LoRa\": [\"LoRa\", \"LoRa\", \"LoRa\"],\n",
|
329 |
-
" \"ControlNet Models\": [\"ControlNet Model\", \"ControlNet Models\", \"ControlNet Models\"]\n",
|
330 |
-
" }\n",
|
331 |
-
" deleted_word_variants = [\"Deleted\", \"Deleted\", \"Deleted\"]\n",
|
332 |
-
" for key, value in deleted_files_dict.items():\n",
|
333 |
-
" word_variant = word_variants.get(key, [\"\", \"\", \"\"])\n",
|
334 |
-
" deleted_word = get_word_variant(value, deleted_word_variants)\n",
|
335 |
-
" object_word = get_word_variant(value, word_variant)\n",
|
336 |
-
" messages.append(f\"{deleted_word} {value} {object_word}\")\n",
|
337 |
-
" return messages\n",
|
338 |
-
"# ================ AutoCleaner function ================\n",
|
339 |
-
"\n",
|
340 |
-
"\n",
|
341 |
-
"# --- storage memory ---\n",
|
342 |
-
"import psutil\n",
|
343 |
-
"disk_space = psutil.disk_usage(os.getcwd())\n",
|
344 |
-
"total = disk_space.total / (1024 ** 3)\n",
|
345 |
-
"used = disk_space.used / (1024 ** 3)\n",
|
346 |
-
"free = disk_space.free / (1024 ** 3)\n",
|
347 |
-
"\n",
|
348 |
-
"\n",
|
349 |
-
"# UI Code\n",
|
350 |
-
"AutoCleaner_options = AutoCleaner_options = list(directories.keys())\n",
|
351 |
-
"instruction_label = widgets.HTML('''\n",
|
352 |
-
"<span class=\"instruction_AC\">Use <span style=\"color: #B2B2B2;\">ctrl</span> or <span style=\"color: #B2B2B2;\">shift</span> for multiple selections.</span>\n",
|
353 |
-
"''')\n",
|
354 |
-
"auto_cleaner_widget = widgets.SelectMultiple(options=AutoCleaner_options, layout=widgets.Layout(width='auto')).add_class(\"custom-select-multiple_AC\")\n",
|
355 |
-
"output = widgets.Output().add_class(\"output_AC\")\n",
|
356 |
-
"# ---\n",
|
357 |
-
"execute_button = Button(description='Execute Cleaning').add_class(\"button_execute_AC\").add_class(\"button_AC\")\n",
|
358 |
-
"execute_button.on_click(on_execute_button_press)\n",
|
359 |
-
"clear_button = Button(description='Hide Widget').add_class(\"button_clear_AC\").add_class(\"button_AC\")\n",
|
360 |
-
"clear_button.on_click(on_clear_button_press)\n",
|
361 |
-
"# ---\n",
|
362 |
-
"storage_info = widgets.HTML(f'''\n",
|
363 |
-
"<div class=\"storage_info_AC\">Total storage: {total:.2f} GB <span style=\"color: #555\">|</span> Used: {used:.2f} GB <span style=\"color: #555\">|</span> Free: {free:.2f} GB</div>\n",
|
364 |
-
"''')\n",
|
365 |
-
"# ---\n",
|
366 |
-
"buttons = widgets.HBox([execute_button, clear_button])\n",
|
367 |
-
"lower_information_panel = widgets.HBox([buttons, storage_info]).add_class(\"lower_information_panel_AC\")\n",
|
368 |
-
"\n",
|
369 |
-
"container = VBox([instruction_label, widgets.HTML('<hr>'), auto_cleaner_widget, output, widgets.HTML('<hr>'), lower_information_panel]).add_class(\"container_AC\")\n",
|
370 |
-
"\n",
|
371 |
-
"display(container)"
|
372 |
-
],
|
373 |
-
"metadata": {
|
374 |
-
"id": "I22dFg7F2j3G"
|
375 |
-
},
|
376 |
-
"execution_count": null,
|
377 |
-
"outputs": []
|
378 |
-
}
|
379 |
-
]
|
380 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/notebooks/en/downloading_en.ipynb
DELETED
@@ -1,594 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"nbformat": 4,
|
3 |
-
"nbformat_minor": 0,
|
4 |
-
"metadata": {
|
5 |
-
"colab": {
|
6 |
-
"provenance": []
|
7 |
-
},
|
8 |
-
"kernelspec": {
|
9 |
-
"name": "python3",
|
10 |
-
"display_name": "Python 3"
|
11 |
-
},
|
12 |
-
"language_info": {
|
13 |
-
"name": "python"
|
14 |
-
}
|
15 |
-
},
|
16 |
-
"cells": [
|
17 |
-
{
|
18 |
-
"cell_type": "code",
|
19 |
-
"source": [
|
20 |
-
"##~ DOWNLOADING CODE | BY: ANXETY ~##\n",
|
21 |
-
"\n",
|
22 |
-
"import os\n",
|
23 |
-
"import re\n",
|
24 |
-
"import time\n",
|
25 |
-
"import json\n",
|
26 |
-
"import requests\n",
|
27 |
-
"import subprocess\n",
|
28 |
-
"from datetime import timedelta\n",
|
29 |
-
"from subprocess import getoutput\n",
|
30 |
-
"from urllib.parse import unquote\n",
|
31 |
-
"from IPython.utils import capture\n",
|
32 |
-
"from IPython.display import clear_output\n",
|
33 |
-
"\n",
|
34 |
-
"\n",
|
35 |
-
"# ================= DETECT ENV =================\n",
|
36 |
-
"def detect_environment():\n",
|
37 |
-
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
38 |
-
" environments = {\n",
|
39 |
-
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
40 |
-
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
41 |
-
" 'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', \"/home/studio-lab-user/content\")\n",
|
42 |
-
" }\n",
|
43 |
-
"\n",
|
44 |
-
" for env_var, (environment, path) in environments.items():\n",
|
45 |
-
" if env_var in os.environ:\n",
|
46 |
-
" return environment, path, free_plan\n",
|
47 |
-
"\n",
|
48 |
-
"env, root_path, free_plan = detect_environment()\n",
|
49 |
-
"webui_path = f\"{root_path}/sdw\"\n",
|
50 |
-
"# ----------------------------------------------\n",
|
51 |
-
"\n",
|
52 |
-
"\n",
|
53 |
-
"# === ONLY SAGEMAKER ===\n",
|
54 |
-
"if env == \"SageMaker Studio Lab\":\n",
|
55 |
-
" print(\"Updating dependencies, may take some time...\")\n",
|
56 |
-
" !pip install -q --upgrade torchsde\n",
|
57 |
-
" !pip install -q --upgrade pip\n",
|
58 |
-
" !pip install -q --upgrade psutil\n",
|
59 |
-
"\n",
|
60 |
-
" clear_output()\n",
|
61 |
-
"\n",
|
62 |
-
"\n",
|
63 |
-
"# ================ LIBRARIES ================\n",
|
64 |
-
"flag_file = f\"{root_path}/libraries_installed.txt\"\n",
|
65 |
-
"\n",
|
66 |
-
"if not os.path.exists(flag_file):\n",
|
67 |
-
" # automatic1111 update webui to 1.8.0\n",
|
68 |
-
" xformers = \"xformers==0.0.23.post1 triton==2.1.0\"\n",
|
69 |
-
" torch = \"torch==2.1.2+cu121 torchvision==0.16.2+cu121 torchaudio==2.1.2 --extra-index-url https://download.pytorch.org/whl/cu121\"\n",
|
70 |
-
"\n",
|
71 |
-
" print(\"💿 Installing the libraries, it's going to take a while...\", end='')\n",
|
72 |
-
" with capture.capture_output() as cap:\n",
|
73 |
-
" !pip install -U gdown\n",
|
74 |
-
" !apt-get update && apt -y install aria2\n",
|
75 |
-
" !npm install -g localtunnel &> /dev/null\n",
|
76 |
-
" !curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}\n",
|
77 |
-
" !curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl\n",
|
78 |
-
" !pip install insightface\n",
|
79 |
-
" !curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.23/zrok_0.4.23_linux_amd64.tar.gz && tar -xzf zrok_0.4.23_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.23_linux_amd64.tar.gz\n",
|
80 |
-
"\n",
|
81 |
-
" if env == \"SageMaker Studio Lab\":\n",
|
82 |
-
" %pip install -q opencv-python-headless huggingface-hub\n",
|
83 |
-
" %conda update -q -n base conda\n",
|
84 |
-
" %conda install -q -y aria2\n",
|
85 |
-
" %conda install -q -y glib\n",
|
86 |
-
" !pip install tensorflow\n",
|
87 |
-
"\n",
|
88 |
-
" !wget -P /home/studio-lab-user https://huggingface.co/NagisaNao/fast_repo/resolve/main/sagemaker/FULL_DELETED_NOTEBOOK.ipynb\n",
|
89 |
-
"\n",
|
90 |
-
" if env == \"Google Colab\":\n",
|
91 |
-
" !pip install xformers==0.0.25 --no-deps\n",
|
92 |
-
" else:\n",
|
93 |
-
" !pip install -q {torch} -U\n",
|
94 |
-
" !pip install -q {xformers} -U\n",
|
95 |
-
"\n",
|
96 |
-
" with open(flag_file, \"w\") as f:\n",
|
97 |
-
" f.write(\"hey ;3\")\n",
|
98 |
-
" del cap\n",
|
99 |
-
" print(\"\\r🍪 Libraries are installed!\" + \" \"*35)\n",
|
100 |
-
" time.sleep(2)\n",
|
101 |
-
" clear_output()\n",
|
102 |
-
"\n",
|
103 |
-
"\n",
|
104 |
-
"# ================= loading settings V4 =================\n",
|
105 |
-
"def load_settings(path):\n",
|
106 |
-
" if os.path.exists(path):\n",
|
107 |
-
" with open(path, 'r') as file:\n",
|
108 |
-
" return json.load(file)\n",
|
109 |
-
" return {}\n",
|
110 |
-
"\n",
|
111 |
-
"settings = load_settings(f'{root_path}/settings.json')\n",
|
112 |
-
"\n",
|
113 |
-
"variables = [\n",
|
114 |
-
" 'Model', 'Model_Num', 'Inpainting_Model',\n",
|
115 |
-
" 'Vae', 'Vae_Num',\n",
|
116 |
-
" 'latest_webui', 'latest_exstensions', 'detailed_download',\n",
|
117 |
-
" 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',\n",
|
118 |
-
" 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
|
119 |
-
" 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'\n",
|
120 |
-
"]\n",
|
121 |
-
"\n",
|
122 |
-
"locals().update({key: settings.get(key) for key in variables})\n",
|
123 |
-
"\n",
|
124 |
-
"\n",
|
125 |
-
"# ================= OTHER =================\n",
|
126 |
-
"try:\n",
|
127 |
-
" start_colab\n",
|
128 |
-
"except:\n",
|
129 |
-
" start_colab = int(time.time())-5\n",
|
130 |
-
"\n",
|
131 |
-
"# CONFIG DIR\n",
|
132 |
-
"models_dir = f\"{webui_path}/models/Stable-diffusion\"\n",
|
133 |
-
"vaes_dir = f\"{webui_path}/models/VAE\"\n",
|
134 |
-
"embeddings_dir = f\"{webui_path}/embeddings\"\n",
|
135 |
-
"loras_dir = f\"{webui_path}/models/Lora\"\n",
|
136 |
-
"extensions_dir = f\"{webui_path}/extensions\"\n",
|
137 |
-
"control_dir = f\"{webui_path}/models/ControlNet\"\n",
|
138 |
-
"\n",
|
139 |
-
"\n",
|
140 |
-
"# ================= MAIN CODE =================\n",
|
141 |
-
"# --- Obsolescence warning ---\n",
|
142 |
-
"if env == \"SageMaker Studio Lab\":\n",
|
143 |
-
" print(\"You are using the 'SageMaker' environment - this environment is outdated so many bugs will not be fixed and it will be cut in functionality. To save memory and/or to avoid bugs.\\n\\n\")\n",
|
144 |
-
"\n",
|
145 |
-
"\n",
|
146 |
-
"if not os.path.exists(webui_path):\n",
|
147 |
-
" start_install = int(time.time())\n",
|
148 |
-
" print(\"⌚ Unpacking Stable Diffusion...\", end='')\n",
|
149 |
-
" with capture.capture_output() as cap:\n",
|
150 |
-
" !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip -o repo.zip\n",
|
151 |
-
" !unzip -q -o repo.zip -d {webui_path}\n",
|
152 |
-
" !rm -rf repo.zip\n",
|
153 |
-
"\n",
|
154 |
-
" %cd {root_path}\n",
|
155 |
-
" os.environ[\"SAFETENSORS_FAST_GPU\"]='1'\n",
|
156 |
-
" os.environ[\"CUDA_MODULE_LOADING\"]=\"LAZY\"\n",
|
157 |
-
" os.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"3\"\n",
|
158 |
-
" os.environ[\"PYTHONWARNINGS\"] = \"ignore\"\n",
|
159 |
-
"\n",
|
160 |
-
" !echo -n {start_colab} > {webui_path}/static/colabTimer.txt\n",
|
161 |
-
" del cap\n",
|
162 |
-
" install_time = timedelta(seconds=time.time()-start_install)\n",
|
163 |
-
" print(\"\\r🚀 Unpacking is complete! For\",\"%02d:%02d:%02d ⚡\\n\" % (install_time.seconds / 3600, (install_time.seconds / 60) % 60, install_time.seconds % 60), end='', flush=True)\n",
|
164 |
-
"else:\n",
|
165 |
-
" if env == \"SageMaker Studio Lab\":\n",
|
166 |
-
" !echo -n {start_colab} > {webui_path}/static/colabTimer.txt\n",
|
167 |
-
" print(\"🚀 All unpacked... Skip. ⚡\")\n",
|
168 |
-
" start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
|
169 |
-
" time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
|
170 |
-
" print(f\"⌚️ You have been conducting this session for - \\033[33m{time_since_start}\\033[0m\")\n",
|
171 |
-
"\n",
|
172 |
-
"\n",
|
173 |
-
"## Changes extensions and WebUi\n",
|
174 |
-
"if latest_webui or latest_exstensions:\n",
|
175 |
-
" action = \"Updating WebUI and Extensions\" if latest_webui and latest_exstensions else (\"WebUI Update\" if latest_webui else \"Update Extensions\")\n",
|
176 |
-
" print(f\"⌚️ {action}...\", end='', flush=True)\n",
|
177 |
-
" with capture.capture_output() as cap:\n",
|
178 |
-
" !git config --global user.email \"[email protected]\"\n",
|
179 |
-
" !git config --global user.name \"Your Name\"\n",
|
180 |
-
"\n",
|
181 |
-
" ## Update Webui\n",
|
182 |
-
" if latest_webui:\n",
|
183 |
-
" %cd {webui_path}\n",
|
184 |
-
" !git restore .\n",
|
185 |
-
" !git pull -X theirs --rebase --autostash\n",
|
186 |
-
"\n",
|
187 |
-
" ## Update extensions\n",
|
188 |
-
" if latest_exstensions:\n",
|
189 |
-
" if env != \"SageMaker Studio Lab\":\n",
|
190 |
-
" !{'for dir in ' + webui_path + '/extensions/*/; do cd \\\"$dir\\\" && git reset --hard && git pull; done'}\n",
|
191 |
-
" else:\n",
|
192 |
-
" !{'for dir in /home/studio-lab-user/content/sdw/extensions/*/; do cd \\\"$dir\\\" && git fetch origin && git pull; done'}\n",
|
193 |
-
"\n",
|
194 |
-
" # My Chinese friend, you broke the images again in the latest update... >W<'\n",
|
195 |
-
" %cd {webui_path}/extensions/Encrypt-Image\n",
|
196 |
-
" !git reset --hard 376358d8854472b9ea50e9fc8800367d1ca51137 # stable commit :3\n",
|
197 |
-
"\n",
|
198 |
-
" !cd {webui_path}/repositories/stable-diffusion-stability-ai && git restore .\n",
|
199 |
-
" del cap\n",
|
200 |
-
" print(f\"\\r✨ {action} Completed!\")\n",
|
201 |
-
"\n",
|
202 |
-
"\n",
|
203 |
-
"# === FIXING ERRORS ===\n",
|
204 |
-
"# --- Encrypt-Image ---\n",
|
205 |
-
"!sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js\n",
|
206 |
-
"\n",
|
207 |
-
"# --- SageMaker ---\n",
|
208 |
-
"if env == \"SageMaker Studio Lab\":\n",
|
209 |
-
" with capture.capture_output() as cap:\n",
|
210 |
-
" # --- SuperMerger Remove ---\n",
|
211 |
-
" if os.path.exists(f\"{webui_path}/extensions/supermerger\"):\n",
|
212 |
-
" !rm -rf {webui_path}/extensions/supermerger\n",
|
213 |
-
" # --- Launch (Style) ---\n",
|
214 |
-
" !wget -O {webui_path}/modules/styles.py https://huggingface.co/NagisaNao/fast_repo/resolve/main/sagemaker/fixing/webui/styles.py\n",
|
215 |
-
" del cap\n",
|
216 |
-
"\n",
|
217 |
-
"\n",
|
218 |
-
"## Version switching\n",
|
219 |
-
"if commit_hash:\n",
|
220 |
-
" print('⏳ Time machine activation...', end=\"\", flush=True)\n",
|
221 |
-
" with capture.capture_output() as cap:\n",
|
222 |
-
" %cd {webui_path}\n",
|
223 |
-
" !git config --global user.email \"[email protected]\"\n",
|
224 |
-
" !git config --global user.name \"Your Name\"\n",
|
225 |
-
" !git reset --hard {commit_hash}\n",
|
226 |
-
" del cap\n",
|
227 |
-
" print(f\"\\r⌛️ The time machine has been activated! Current commit: \\033[34m{commit_hash}\\033[0m\")\n",
|
228 |
-
"\n",
|
229 |
-
"\n",
|
230 |
-
"## Downloading model and stuff | oh yeah~ I'm starting to misunderstand my own code ( almost my own ;3 )\n",
|
231 |
-
"print(\"📦 Downloading models and stuff...\", end='')\n",
|
232 |
-
"model_list = {\n",
|
233 |
-
" \"1.Anime (by XpucT) + INP\": [\n",
|
234 |
-
" {\"url\": \"https://huggingface.co/XpucT/Anime/resolve/main/Anime_v2.safetensors\", \"name\": \"Anime_v2.safetensors\"},\n",
|
235 |
-
" {\"url\": \"https://huggingface.co/XpucT/Anime/resolve/main/Anime_v2-inpainting.safetensors\", \"name\": \"Anime_v2-inpainting.safetensors\"}\n",
|
236 |
-
" ],\n",
|
237 |
-
" \"2.BluMix [Anime] [V7]\": [\n",
|
238 |
-
" {\"url\": \"https://civitai.com/api/download/models/361779\", \"name\": \"BluMix_v7.safetensors\"}\n",
|
239 |
-
" ],\n",
|
240 |
-
" \"3.Cetus-Mix [Anime] [V4] + INP\": [\n",
|
241 |
-
" {\"url\": \"https://civitai.com/api/download/models/130298\", \"name\": \"CetusMix_V4.safetensors\"},\n",
|
242 |
-
" {\"url\": \"https://civitai.com/api/download/models/139882\", \"name\": \"CetusMix_V4-inpainting.safetensors\"}\n",
|
243 |
-
" ],\n",
|
244 |
-
" \"4.Counterfeit [Anime] [V3] + INP\": [\n",
|
245 |
-
" {\"url\": \"https://civitai.com/api/download/models/125050\", \"name\": \"Counterfeit_V3.safetensors\"},\n",
|
246 |
-
" {\"url\": \"https://civitai.com/api/download/models/137911\", \"name\": \"Counterfeit_V3-inpainting.safetensors\"}\n",
|
247 |
-
" ],\n",
|
248 |
-
" \"5.CuteColor [Anime] [V3]\": [\n",
|
249 |
-
" {\"url\": \"https://civitai.com/api/download/models/138754\", \"name\": \"CuteColor_V3.safetensors\"}\n",
|
250 |
-
" ],\n",
|
251 |
-
" \"6.Dark-Sushi-Mix [Anime]\": [\n",
|
252 |
-
" {\"url\": \"https://civitai.com/api/download/models/101640\", \"name\": \"DarkSushiMix_2_5D.safetensors\"},\n",
|
253 |
-
" {\"url\": \"https://civitai.com/api/download/models/56071\", \"name\": \"DarkSushiMix_colorful.safetensors\"}\n",
|
254 |
-
" ],\n",
|
255 |
-
" \"7.Deliberate [Realism] [V6] + INP\": [\n",
|
256 |
-
" {\"url\": \"https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v6.safetensors\", \"name\": \"Deliberate_v6.safetensors\"},\n",
|
257 |
-
" {\"url\": \"https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v6-inpainting.safetensors\", \"name\": \"Deliberate_v6-inpainting.safetensors\"}\n",
|
258 |
-
" ],\n",
|
259 |
-
" \"8.Meina-Mix [Anime] [V11] + INP\": [\n",
|
260 |
-
" {\"url\": \"https://civitai.com/api/download/models/119057\", \"name\": \"MeinaMix_V11.safetensors\"},\n",
|
261 |
-
" {\"url\": \"https://civitai.com/api/download/models/120702\", \"name\": \"MeinaMix_V11-inpainting.safetensors\"}\n",
|
262 |
-
" ],\n",
|
263 |
-
" \"9.Mix-Pro [Anime] [V4] + INP\": [\n",
|
264 |
-
" {\"url\": \"https://civitai.com/api/download/models/125668\", \"name\": \"MixPro_V4.safetensors\"},\n",
|
265 |
-
" {\"url\": \"https://civitai.com/api/download/models/139878\", \"name\": \"MixPro_V4-inpainting.safetensors\"}\n",
|
266 |
-
" ]\n",
|
267 |
-
"}\n",
|
268 |
-
"\n",
|
269 |
-
"# 1-4 (fp16/cleaned)\n",
|
270 |
-
"vae_list = {\n",
|
271 |
-
" \"1.Anime.vae\": [\n",
|
272 |
-
" {\"url\": \"https://civitai.com/api/download/models/131654\", \"name\": \"Anime.vae.safetensors\"},\n",
|
273 |
-
" {\"url\": \"https://civitai.com/api/download/models/131658\", \"name\": \"vae-ft-mse.vae.safetensors\"}\n",
|
274 |
-
" ],\n",
|
275 |
-
" \"2.Anything.vae\": [{\"url\": \"https://civitai.com/api/download/models/131656\", \"name\": \"Anything.vae.safetensors\"}],\n",
|
276 |
-
" \"3.Blessed2.vae\": [{\"url\": \"https://civitai.com/api/download/models/142467\", \"name\": \"Blessed2.vae.safetensors\"}],\n",
|
277 |
-
" \"4.ClearVae.vae\": [{\"url\": \"https://civitai.com/api/download/models/133362\", \"name\": \"ClearVae_23.vae.safetensors\"}],\n",
|
278 |
-
" \"5.WD.vae\": [{\"url\": \"https://huggingface.co/NoCrypt/resources/resolve/main/VAE/wd.vae.safetensors\", \"name\": \"WD.vae.safetensors\"}]\n",
|
279 |
-
"}\n",
|
280 |
-
"\n",
|
281 |
-
"controlnet_list = {\n",
|
282 |
-
" \"1.canny\": [\n",
|
283 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny_fp16.safetensors\", \"name\": \"control_v11p_sd15_canny_fp16.safetensors\"},\n",
|
284 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_canny_fp16.yaml\", \"name\": \"control_v11p_sd15_canny_fp16.yaml\"}\n",
|
285 |
-
" ],\n",
|
286 |
-
" \"2.openpose\": [\n",
|
287 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose_fp16.safetensors\", \"name\": \"control_v11p_sd15_openpose_fp16.safetensors\"},\n",
|
288 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_openpose_fp16.yaml\", \"name\": \"control_v11p_sd15_openpose_fp16.yaml\"}\n",
|
289 |
-
" ],\n",
|
290 |
-
" \"3.depth\": [\n",
|
291 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors\", \"name\": \"control_v11f1p_sd15_depth_fp16.safetensors\"},\n",
|
292 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1p_sd15_depth_fp16.yaml\", \"name\": \"control_v11f1p_sd15_depth_fp16.yaml\"},\n",
|
293 |
-
" {\"url\": \"https://huggingface.co/NagisaNao/models/resolve/main/ControlNet_v11/control_v11p_sd15_depth_anything_fp16.safetensors\", \"name\": \"control_v11p_sd15_depth_anything_fp16.safetensors\"}\n",
|
294 |
-
" ],\n",
|
295 |
-
" \"4.normal_map\": [\n",
|
296 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors\", \"name\": \"control_v11p_sd15_normalbae_fp16.safetensors\"},\n",
|
297 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_normalbae_fp16.yaml\", \"name\": \"control_v11p_sd15_normalbae_fp16.yaml\"}\n",
|
298 |
-
" ],\n",
|
299 |
-
" \"5.mlsd\": [\n",
|
300 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors\", \"name\": \"control_v11p_sd15_mlsd_fp16.safetensors\"},\n",
|
301 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_mlsd_fp16.yaml\", \"name\": \"control_v11p_sd15_mlsd_fp16.yaml\"}\n",
|
302 |
-
" ],\n",
|
303 |
-
" \"6.lineart\": [\n",
|
304 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart_fp16.safetensors\", \"name\": \"control_v11p_sd15_lineart_fp16.safetensors\"},\n",
|
305 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors\", \"name\": \"control_v11p_sd15s2_lineart_anime_fp16.safetensors\"},\n",
|
306 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_lineart_fp16.yaml\", \"name\": \"control_v11p_sd15_lineart_fp16.yaml\"},\n",
|
307 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15s2_lineart_anime_fp16.yaml\", \"name\": \"control_v11p_sd15s2_lineart_anime_fp16.yaml\"}\n",
|
308 |
-
" ],\n",
|
309 |
-
" \"7.soft_edge\": [\n",
|
310 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_softedge_fp16.safetensors\", \"name\": \"control_v11p_sd15_softedge_fp16.safetensors\"},\n",
|
311 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_softedge_fp16.yaml\", \"name\": \"control_v11p_sd15_softedge_fp16.yaml\"}\n",
|
312 |
-
" ],\n",
|
313 |
-
" \"8.scribble\": [\n",
|
314 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_scribble_fp16.safetensors\", \"name\": \"control_v11p_sd15_scribble_fp16.safetensors\"},\n",
|
315 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_scribble_fp16.yaml\", \"name\": \"control_v11p_sd15_scribble_fp16.yaml\"}\n",
|
316 |
-
" ],\n",
|
317 |
-
" \"9.segmentation\": [\n",
|
318 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_seg_fp16.safetensors\", \"name\": \"control_v11p_sd15_seg_fp16.safetensors\"},\n",
|
319 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_seg_fp16.yaml\", \"name\": \"control_v11p_sd15_seg_fp16.yaml\"}\n",
|
320 |
-
" ],\n",
|
321 |
-
" \"10.shuffle\": [\n",
|
322 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors\", \"name\": \"control_v11e_sd15_shuffle_fp16.safetensors\"},\n",
|
323 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_shuffle_fp16.yaml\", \"name\": \"control_v11e_sd15_shuffle_fp16.yaml\"}\n",
|
324 |
-
" ],\n",
|
325 |
-
" \"11.tile\": [\n",
|
326 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1e_sd15_tile_fp16.safetensors\", \"name\": \"control_v11f1e_sd15_tile_fp16.safetensors\"},\n",
|
327 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1e_sd15_tile_fp16.yaml\", \"name\": \"control_v11f1e_sd15_tile_fp16.yaml\"}\n",
|
328 |
-
" ],\n",
|
329 |
-
" \"12.inpaint\": [\n",
|
330 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors\", \"name\": \"control_v11p_sd15_inpaint_fp16.safetensors\"},\n",
|
331 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_inpaint_fp16.yaml\", \"name\": \"control_v11p_sd15_inpaint_fp16.yaml\"}\n",
|
332 |
-
" ],\n",
|
333 |
-
" \"13.instruct_p2p\": [\n",
|
334 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors\", \"name\": \"control_v11e_sd15_ip2p_fp16.safetensors\"},\n",
|
335 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_ip2p_fp16.yaml\", \"name\": \"control_v11e_sd15_ip2p_fp16.yaml\"}\n",
|
336 |
-
" ]\n",
|
337 |
-
"}\n",
|
338 |
-
"\n",
|
339 |
-
"extension_repo = []\n",
|
340 |
-
"prefixes = {\n",
|
341 |
-
" # It's complicated, but supplementing has become easier\n",
|
342 |
-
" \"model\": [models_dir, \"Model_url\"],\n",
|
343 |
-
" \"vae\": [vaes_dir, \"Vae_url\"],\n",
|
344 |
-
" \"lora\": [loras_dir, \"LoRA_url\"],\n",
|
345 |
-
" \"embed\": [embeddings_dir, \"Embedding_url\"],\n",
|
346 |
-
" \"extension\": [extensions_dir, \"Extensions_url\"],\n",
|
347 |
-
" \"control\": [control_dir, \"ControlNet_url\"]\n",
|
348 |
-
"}\n",
|
349 |
-
"\n",
|
350 |
-
"!mkdir -p {models_dir} {vaes_dir} {loras_dir} {embeddings_dir} {extensions_dir} {control_dir}\n",
|
351 |
-
"\n",
|
352 |
-
"url = \"\"\n",
|
353 |
-
"ControlNet_url = \"\"\n",
|
354 |
-
"hf_token = optional_huggingface_token if optional_huggingface_token else \"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\"\n",
|
355 |
-
"user_header = f\"\\\"Authorization: Bearer {hf_token}\\\"\"\n",
|
356 |
-
"\n",
|
357 |
-
"''' main download code '''\n",
|
358 |
-
"\n",
|
359 |
-
"def handle_manual(url):\n",
|
360 |
-
" original_url = url\n",
|
361 |
-
" url = url.split(':', 1)[1]\n",
|
362 |
-
" file_name = re.search(r'\\[(.*?)\\]', url)\n",
|
363 |
-
" file_name = file_name.group(1) if file_name else None\n",
|
364 |
-
" if file_name:\n",
|
365 |
-
" url = re.sub(r'\\[.*?\\]', '', url)\n",
|
366 |
-
"\n",
|
367 |
-
" for prefix, (dir, _) in prefixes.items():\n",
|
368 |
-
" if original_url.startswith(f\"{prefix}:\"):\n",
|
369 |
-
" if prefix != \"extension\":\n",
|
370 |
-
" manual_download(url, dir, file_name=file_name)\n",
|
371 |
-
" else:\n",
|
372 |
-
" extension_repo.append((url, file_name))\n",
|
373 |
-
"\n",
|
374 |
-
"def manual_download(url, dst_dir, file_name):\n",
|
375 |
-
" basename = url.split(\"/\")[-1] if file_name is None else file_name\n",
|
376 |
-
" header_option = f\"--header={user_header}\"\n",
|
377 |
-
"\n",
|
378 |
-
" print(\"\\033[32m---\"*45 + f\"\\n\\033[33mURL: \\033[34m{url}\\n\\033[33mSAVE DIR: \\033[34m{dst_dir}\\n\\033[33mFILE NAME: \\033[34m{file_name}\\033[32m\\n~~~\\033[0m\")\n",
|
379 |
-
"\n",
|
380 |
-
" # I do it at my own risk..... Fucking CivitAi >:(\n",
|
381 |
-
" civitai_token = \"62c0c5956b2f9defbd844d754000180b\"\n",
|
382 |
-
" if 'civitai' in url and civitai_token:\n",
|
383 |
-
" url = f\"{url}?token={civitai_token}\"\n",
|
384 |
-
"\n",
|
385 |
-
" # -- GDrive --\n",
|
386 |
-
" if 'drive.google' in url:\n",
|
387 |
-
" if 'folders' in url:\n",
|
388 |
-
" !gdown --folder \"{url}\" -O {dst_dir} --fuzzy -c\n",
|
389 |
-
" else:\n",
|
390 |
-
" if file_name:\n",
|
391 |
-
" !gdown \"{url}\" -O {dst_dir}/{file_name} --fuzzy -c\n",
|
392 |
-
" else:\n",
|
393 |
-
" !gdown \"{url}\" -O {dst_dir} --fuzzy -c\n",
|
394 |
-
" # -- Huggin Face --\n",
|
395 |
-
" elif 'huggingface' in url:\n",
|
396 |
-
" if '/blob/' in url:\n",
|
397 |
-
" url = url.replace('/blob/', '/resolve/')\n",
|
398 |
-
" if file_name:\n",
|
399 |
-
" !aria2c {header_option} --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -c -j5 -x16 -s16 -k1M -d {dst_dir} -o {basename} {url}\n",
|
400 |
-
" else:\n",
|
401 |
-
" parsed_link = f'\\n{url}\\n\\tout={unquote(url.split(\"/\")[-1])}'\n",
|
402 |
-
" !echo -e \"{parsed_link}\" | aria2c {header_option} --console-log-level=error --summary-interval=10 -i- -j5 -x16 -s16 -k1M -c -d \"{dst_dir}\" -o {basename}\n",
|
403 |
-
" # -- Other --\n",
|
404 |
-
" elif 'http' in url or 'magnet' in url:\n",
|
405 |
-
" if file_name:\n",
|
406 |
-
" !aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -o {file_name} {url}\n",
|
407 |
-
" else:\n",
|
408 |
-
" parsed_link = '\"{}\"'.format(url)\n",
|
409 |
-
" !aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -Z {parsed_link}\n",
|
410 |
-
"\n",
|
411 |
-
"def download(url):\n",
|
412 |
-
" links_and_paths = url.split(',')\n",
|
413 |
-
"\n",
|
414 |
-
" for link_or_path in links_and_paths:\n",
|
415 |
-
" link_or_path = link_or_path.strip()\n",
|
416 |
-
" if not link_or_path:\n",
|
417 |
-
" continue\n",
|
418 |
-
" if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):\n",
|
419 |
-
" handle_manual(link_or_path)\n",
|
420 |
-
" continue\n",
|
421 |
-
"\n",
|
422 |
-
" url, dst_dir, file_name = link_or_path.split()\n",
|
423 |
-
" manual_download(url, dst_dir, file_name)\n",
|
424 |
-
"\n",
|
425 |
-
"''' submodels - added urls '''\n",
|
426 |
-
"\n",
|
427 |
-
"submodels = []\n",
|
428 |
-
"\n",
|
429 |
-
"def add_submodels(selection, num_selection, model_dict, dst_dir):\n",
|
430 |
-
" if selection == \"none\":\n",
|
431 |
-
" return []\n",
|
432 |
-
" if selection == \"ALL\":\n",
|
433 |
-
" all_models = []\n",
|
434 |
-
" for models in model_dict.values():\n",
|
435 |
-
" all_models.extend(models)\n",
|
436 |
-
" selected_models = all_models\n",
|
437 |
-
" else:\n",
|
438 |
-
" selected_models = model_dict[selection]\n",
|
439 |
-
" selected_nums = map(int, num_selection.replace(',', '').split())\n",
|
440 |
-
"\n",
|
441 |
-
" for num in selected_nums:\n",
|
442 |
-
" if 1 <= num <= len(model_dict):\n",
|
443 |
-
" name = list(model_dict)[num - 1]\n",
|
444 |
-
" selected_models.extend(model_dict[name])\n",
|
445 |
-
"\n",
|
446 |
-
" unique_models = list({model['name']: model for model in selected_models}.values())\n",
|
447 |
-
"\n",
|
448 |
-
" for model in unique_models:\n",
|
449 |
-
" model['dst_dir'] = dst_dir\n",
|
450 |
-
"\n",
|
451 |
-
" return unique_models\n",
|
452 |
-
"\n",
|
453 |
-
"submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model\n",
|
454 |
-
"submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae\n",
|
455 |
-
"submodels += add_submodels(controlnet, \"\" if controlnet == \"ALL\" else controlnet_Num, controlnet_list, control_dir) # controlnet\n",
|
456 |
-
"\n",
|
457 |
-
"for submodel in submodels:\n",
|
458 |
-
" if not Inpainting_Model and \"inpainting\" in submodel['name']:\n",
|
459 |
-
" continue\n",
|
460 |
-
" url += f\"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, \"\n",
|
461 |
-
"\n",
|
462 |
-
"''' file.txt - added urls '''\n",
|
463 |
-
"\n",
|
464 |
-
"unique_urls = []\n",
|
465 |
-
"\n",
|
466 |
-
"def process_file_download(file_url):\n",
|
467 |
-
" if file_url.startswith(\"http\"):\n",
|
468 |
-
" if \"blob\" in file_url:\n",
|
469 |
-
" file_url = file_url.replace(\"blob\", \"raw\")\n",
|
470 |
-
" response = requests.get(file_url)\n",
|
471 |
-
" lines = response.text.split('\\n')\n",
|
472 |
-
" else:\n",
|
473 |
-
" with open(file_url, 'r') as file:\n",
|
474 |
-
" lines = file.readlines()\n",
|
475 |
-
"\n",
|
476 |
-
" current_tag = None\n",
|
477 |
-
" for line in lines:\n",
|
478 |
-
" if any(f'# {tag}' in line.lower() for tag in prefixes):\n",
|
479 |
-
" current_tag = next((tag for tag in prefixes if tag in line.lower()))\n",
|
480 |
-
"\n",
|
481 |
-
" urls = [url.strip() for url in line.split(',')]\n",
|
482 |
-
" for url in urls:\n",
|
483 |
-
" if url.startswith(\"http\") and url not in unique_urls:\n",
|
484 |
-
" globals()[prefixes[current_tag][1]] += \", \" + url\n",
|
485 |
-
" unique_urls.append(url)\n",
|
486 |
-
"\n",
|
487 |
-
"# fix all possible errors/options and function call\n",
|
488 |
-
"if custom_file_urls:\n",
|
489 |
-
" for custom_file_url in custom_file_urls.replace(',', '').split():\n",
|
490 |
-
" if not custom_file_url.endswith('.txt'):\n",
|
491 |
-
" custom_file_url += '.txt'\n",
|
492 |
-
" if not custom_file_url.startswith('http'):\n",
|
493 |
-
" if not custom_file_url.startswith(root_path):\n",
|
494 |
-
" custom_file_url = f'{root_path}/{custom_file_url}'\n",
|
495 |
-
"\n",
|
496 |
-
" try:\n",
|
497 |
-
" process_file_download(custom_file_url)\n",
|
498 |
-
" except FileNotFoundError:\n",
|
499 |
-
" pass\n",
|
500 |
-
"\n",
|
501 |
-
"# url prefixing\n",
|
502 |
-
"urls = [globals()[urls[1]] for urls in prefixes.values()]\n",
|
503 |
-
"for i, prefix in enumerate(prefixes):\n",
|
504 |
-
" if urls[i]:\n",
|
505 |
-
" prefixed_urls = [f\"{prefix}:{url}\" for url in urls[i].replace(',', '').split()]\n",
|
506 |
-
" if prefixed_urls:\n",
|
507 |
-
" url += \", \".join(prefixed_urls) + \", \"\n",
|
508 |
-
"\n",
|
509 |
-
"if detailed_download == \"on\":\n",
|
510 |
-
" print(\"\\n\\n\\033[33m# ====== Detailed Download ====== #\\n\\033[0m\")\n",
|
511 |
-
" download(url)\n",
|
512 |
-
" print(\"\\n\\033[33m# =============================== #\\n\\033[0m\")\n",
|
513 |
-
"else:\n",
|
514 |
-
" with capture.capture_output() as cap:\n",
|
515 |
-
" download(url)\n",
|
516 |
-
" del cap\n",
|
517 |
-
"\n",
|
518 |
-
"print(\"\\r🏁 Download Complete!\" + \" \"*15)\n",
|
519 |
-
"\n",
|
520 |
-
"\n",
|
521 |
-
"# Cleaning shit after downloading...\n",
|
522 |
-
"!find {webui_path} \\( -type d \\( -name \".ipynb_checkpoints\" -o -name \".aria2\" \\) -o -type f -name \"*.aria2\" \\) -exec rm -r {{}} \\; >/dev/null 2>&1\n",
|
523 |
-
"\n",
|
524 |
-
"\n",
|
525 |
-
"## Install of Custom extensions\n",
|
526 |
-
"if len(extension_repo) > 0:\n",
|
527 |
-
" print(\"✨ Installing custom extensions...\", end='', flush=True)\n",
|
528 |
-
" with capture.capture_output() as cap:\n",
|
529 |
-
" for repo, repo_name in extension_repo:\n",
|
530 |
-
" if not repo_name:\n",
|
531 |
-
" repo_name = repo.split('/')[-1]\n",
|
532 |
-
" !cd {extensions_dir} \\\n",
|
533 |
-
" && git clone {repo} {repo_name} \\\n",
|
534 |
-
" && cd {repo_name} \\\n",
|
535 |
-
" && git fetch\n",
|
536 |
-
" del cap\n",
|
537 |
-
" print(f\"\\r📦 Installed '{len(extension_repo)}', Custom extensions!\")\n",
|
538 |
-
"\n",
|
539 |
-
"\n",
|
540 |
-
"## List Models and stuff\n",
|
541 |
-
"if detailed_download == \"off\":\n",
|
542 |
-
" print(\"\\n\\n\\033[33mIf you don't see any downloaded files, enable the 'Detailed Downloads' feature in the widget.\")\n",
|
543 |
-
"\n",
|
544 |
-
"if any(not file.endswith('.txt') for file in os.listdir(models_dir)):\n",
|
545 |
-
" print(\"\\n\\033[33m➤ Models\\033[0m\")\n",
|
546 |
-
" !find {models_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'\n",
|
547 |
-
"if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):\n",
|
548 |
-
" print(\"\\n\\033[33m➤ VAEs\\033[0m\")\n",
|
549 |
-
" !find {vaes_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'\n",
|
550 |
-
"if any(not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file)) for file in os.listdir(embeddings_dir)):\n",
|
551 |
-
" print(\"\\n\\033[33m➤ Embeddings\\033[0m\")\n",
|
552 |
-
" !find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'\n",
|
553 |
-
"if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):\n",
|
554 |
-
" print(\"\\n\\033[33m➤ LoRAs\\033[0m\")\n",
|
555 |
-
" !find {loras_dir}/ -mindepth 1 ! -name '*.keep' -printf '%f\\n'\n",
|
556 |
-
"print(f\"\\n\\033[33m➤ Extensions\\033[0m\")\n",
|
557 |
-
"!find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'\n",
|
558 |
-
"if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):\n",
|
559 |
-
" print(\"\\n\\033[33m➤ ControlNet\\033[0m\")\n",
|
560 |
-
" !find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\(.*\\)_fp16\\.safetensors$/\\1/'\n",
|
561 |
-
"\n",
|
562 |
-
"\n",
|
563 |
-
"# === OTHER ===\n",
|
564 |
-
"# Downlaod discord tags UmiWildcards\n",
|
565 |
-
"files_umi = [\n",
|
566 |
-
" \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/200_pan_gen.txt\",\n",
|
567 |
-
" \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/150_bra_gen.txt\"\n",
|
568 |
-
"]\n",
|
569 |
-
"save_dir_path = f\"{webui_path}/extensions/Umi-AI-Wildcards/wildcards/discord\"\n",
|
570 |
-
"\n",
|
571 |
-
"with capture.capture_output() as cap:\n",
|
572 |
-
" for file in files_umi:\n",
|
573 |
-
" !aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {save_dir_path} {file}\n",
|
574 |
-
"del cap\n",
|
575 |
-
"\n",
|
576 |
-
"\n",
|
577 |
-
"# === ONLY SAGEMAKER ===\n",
|
578 |
-
"if env == \"SageMaker Studio Lab\":\n",
|
579 |
-
" with capture.capture_output() as cap:\n",
|
580 |
-
" !rm -rf /home/studio-lab-user/.conda/envs/studiolab-safemode\n",
|
581 |
-
" !rm -rf /home/studio-lab-user/.conda/envs/sagemaker-distribution\n",
|
582 |
-
" !rm -rf /home/studio-lab-user/.conda/pkgs/cache\n",
|
583 |
-
" !pip cache purge\n",
|
584 |
-
" !rm -rf ~/.cache\n",
|
585 |
-
" del cap"
|
586 |
-
],
|
587 |
-
"metadata": {
|
588 |
-
"id": "2lJmbqrs3Mu8"
|
589 |
-
},
|
590 |
-
"execution_count": null,
|
591 |
-
"outputs": []
|
592 |
-
}
|
593 |
-
]
|
594 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/notebooks/en/launch_en.ipynb
DELETED
@@ -1,134 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"nbformat": 4,
|
3 |
-
"nbformat_minor": 0,
|
4 |
-
"metadata": {
|
5 |
-
"colab": {
|
6 |
-
"provenance": []
|
7 |
-
},
|
8 |
-
"kernelspec": {
|
9 |
-
"name": "python3",
|
10 |
-
"display_name": "Python 3"
|
11 |
-
},
|
12 |
-
"language_info": {
|
13 |
-
"name": "python"
|
14 |
-
}
|
15 |
-
},
|
16 |
-
"cells": [
|
17 |
-
{
|
18 |
-
"cell_type": "code",
|
19 |
-
"execution_count": null,
|
20 |
-
"metadata": {
|
21 |
-
"id": "JKTCrY9LU7Oq"
|
22 |
-
},
|
23 |
-
"outputs": [],
|
24 |
-
"source": [
|
25 |
-
"##~ LAUNCH CODE | BY: ANXETY ~##\n",
|
26 |
-
"\n",
|
27 |
-
"import os\n",
|
28 |
-
"import re\n",
|
29 |
-
"import time\n",
|
30 |
-
"import json\n",
|
31 |
-
"import requests\n",
|
32 |
-
"from datetime import timedelta\n",
|
33 |
-
"\n",
|
34 |
-
"\n",
|
35 |
-
"# ================= DETECT ENV =================\n",
|
36 |
-
"def detect_environment():\n",
|
37 |
-
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
38 |
-
" environments = {\n",
|
39 |
-
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
40 |
-
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
41 |
-
" 'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', \"/home/studio-lab-user/content\")\n",
|
42 |
-
" }\n",
|
43 |
-
"\n",
|
44 |
-
" for env_var, (environment, path) in environments.items():\n",
|
45 |
-
" if env_var in os.environ:\n",
|
46 |
-
" return environment, path, free_plan\n",
|
47 |
-
"\n",
|
48 |
-
"env, root_path, free_plan = detect_environment()\n",
|
49 |
-
"webui_path = f\"{root_path}/sdw\"\n",
|
50 |
-
"# ----------------------------------------------\n",
|
51 |
-
"\n",
|
52 |
-
"def load_settings():\n",
|
53 |
-
" SETTINGS_FILE = f'{root_path}/settings.json'\n",
|
54 |
-
" if os.path.exists(SETTINGS_FILE):\n",
|
55 |
-
" with open(SETTINGS_FILE, 'r') as f:\n",
|
56 |
-
" settings = json.load(f)\n",
|
57 |
-
" return settings\n",
|
58 |
-
"\n",
|
59 |
-
"settings = load_settings()\n",
|
60 |
-
"ngrok_token = settings['ngrok_token']\n",
|
61 |
-
"zrok_token = settings['zrok_token']\n",
|
62 |
-
"commandline_arguments = settings['commandline_arguments']\n",
|
63 |
-
"\n",
|
64 |
-
"\n",
|
65 |
-
"# ======================== TUNNEL ========================\n",
|
66 |
-
"if env != \"SageMaker Studio Lab\":\n",
|
67 |
-
" import cloudpickle as pickle\n",
|
68 |
-
"\n",
|
69 |
-
" def get_public_ip(version='ipv4'):\n",
|
70 |
-
" try:\n",
|
71 |
-
" url = f'https://api64.ipify.org?format=json&{version}=true'\n",
|
72 |
-
" response = requests.get(url)\n",
|
73 |
-
" data = response.json()\n",
|
74 |
-
" public_ip = data['ip']\n",
|
75 |
-
" return public_ip\n",
|
76 |
-
" except Exception as e:\n",
|
77 |
-
" print(f\"Error getting public {version} address:\", e)\n",
|
78 |
-
"\n",
|
79 |
-
" public_ipv4 = get_public_ip(version='ipv4')\n",
|
80 |
-
"\n",
|
81 |
-
" tunnel_class = pickle.load(open(f\"{root_path}/new_tunnel\", \"rb\"), encoding=\"utf-8\")\n",
|
82 |
-
" tunnel_port= 1769\n",
|
83 |
-
" tunnel = tunnel_class(tunnel_port)\n",
|
84 |
-
" tunnel.add_tunnel(command=\"cl tunnel --url localhost:{port}\", name=\"cl\", pattern=re.compile(r\"[\\w-]+\\.trycloudflare\\.com\"))\n",
|
85 |
-
" tunnel.add_tunnel(command=\"lt --port {port}\", name=\"lt\", pattern=re.compile(r\"[\\w-]+\\.loca\\.lt\"), note=\"Password : \" + \"\\033[32m\" + public_ipv4 + \"\\033[0m\" + \" rerun cell if 404 error.\")\n",
|
86 |
-
"\n",
|
87 |
-
" ''' add zrok tunnel '''\n",
|
88 |
-
" if zrok_token:\n",
|
89 |
-
" !zrok enable {zrok_token} &> /dev/null\n",
|
90 |
-
" tunnel.add_tunnel(command=\"zrok share public http://localhost:{port}/ --headless\", name=\"zrok\", pattern=re.compile(r\"[\\w-]+\\.share\\.zrok\\.io\"))\n",
|
91 |
-
"# ======================== TUNNEL ========================\n",
|
92 |
-
"\n",
|
93 |
-
"\n",
|
94 |
-
"# automatic fixing path V2\n",
|
95 |
-
"!sed -i 's#\"tagger_hf_cache_dir\": \".*models/interrogators\"#\"tagger_hf_cache_dir\": \"{root_path}/sdw/models/interrogators\"#' {webui_path}/config.json\n",
|
96 |
-
"!sed -i 's#\"additional_networks_extra_lora_path\": \".*models/Lora/\"#\"additional_networks_extra_lora_path\": \"{root_path}/sdw/models/Lora/\"#' {webui_path}/config.json\n",
|
97 |
-
"# ---\n",
|
98 |
-
"!sed -i 's/\"sd_checkpoint_hash\": \".*\"/\"sd_checkpoint_hash\": \"\"/g; s/\"sd_model_checkpoint\": \".*\"/\"sd_model_checkpoint\": \"\"/g; s/\"sd_vae\": \".*\"/\"sd_vae\": \"None\"/g' {webui_path}/config.json\n",
|
99 |
-
"\n",
|
100 |
-
"\n",
|
101 |
-
"if env != \"SageMaker Studio Lab\":\n",
|
102 |
-
" with tunnel:\n",
|
103 |
-
" %cd {webui_path}\n",
|
104 |
-
" commandline_arguments += f\" --port=1769\"\n",
|
105 |
-
"\n",
|
106 |
-
" if ngrok_token:\n",
|
107 |
-
" commandline_arguments += ' --ngrok ' + ngrok_token\n",
|
108 |
-
" if env != \"Google Colab\":\n",
|
109 |
-
" commandline_arguments += f\" --encrypt-pass=1769\"\n",
|
110 |
-
"\n",
|
111 |
-
" !COMMANDLINE_ARGS=\"{commandline_arguments}\" python launch.py\n",
|
112 |
-
"\n",
|
113 |
-
" start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
|
114 |
-
" time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
|
115 |
-
" print(f\"\\n⌚️ \\033[0mYou have been conducting this session for - \\033[33m{time_since_start}\\033[0m\\n\\n\")\n",
|
116 |
-
"\n",
|
117 |
-
"else:\n",
|
118 |
-
" if ngrok_token:\n",
|
119 |
-
" %cd {webui_path}\n",
|
120 |
-
"\n",
|
121 |
-
" commandline_arguments += ' --ngrok ' + ngrok_token\n",
|
122 |
-
"\n",
|
123 |
-
" !COMMANDLINE_ARGS=\"{commandline_arguments}\" python launch.py\n",
|
124 |
-
"\n",
|
125 |
-
" start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
|
126 |
-
" time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
|
127 |
-
" print(f\"\\n⌚️ \\033[0mYou have been conducting this session for - \\033[33m{time_since_start}\\033[0m\\n\\n\")\n",
|
128 |
-
"\n",
|
129 |
-
" else:\n",
|
130 |
-
" print(\"Oops... I think you forgot to insert the token `ngrok`..... go back to widgets and insert it to start webui... no way without it :/\\nYou can get the token here:\\n\\nhttps://dashboard.ngrok.com/get-started/your-authtoken\")"
|
131 |
-
]
|
132 |
-
}
|
133 |
-
]
|
134 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/notebooks/en/widgets_en.ipynb
DELETED
@@ -1,619 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"nbformat": 4,
|
3 |
-
"nbformat_minor": 0,
|
4 |
-
"metadata": {
|
5 |
-
"colab": {
|
6 |
-
"provenance": []
|
7 |
-
},
|
8 |
-
"kernelspec": {
|
9 |
-
"name": "python3",
|
10 |
-
"display_name": "Python 3"
|
11 |
-
},
|
12 |
-
"language_info": {
|
13 |
-
"name": "python"
|
14 |
-
}
|
15 |
-
},
|
16 |
-
"cells": [
|
17 |
-
{
|
18 |
-
"cell_type": "code",
|
19 |
-
"source": [
|
20 |
-
"##~ WIDGET CODE | BY: ANXETY ~##\n",
|
21 |
-
"\n",
|
22 |
-
"import os\n",
|
23 |
-
"import json\n",
|
24 |
-
"import time\n",
|
25 |
-
"import ipywidgets as widgets\n",
|
26 |
-
"from ipywidgets import widgets, Layout, Label, Button, VBox, HBox\n",
|
27 |
-
"from IPython.display import display, HTML, Javascript, clear_output\n",
|
28 |
-
"\n",
|
29 |
-
"\n",
|
30 |
-
"# ================= DETECT ENV =================\n",
|
31 |
-
"def detect_environment():\n",
|
32 |
-
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
33 |
-
" environments = {\n",
|
34 |
-
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
35 |
-
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
36 |
-
" 'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', \"/home/studio-lab-user/content\")\n",
|
37 |
-
" }\n",
|
38 |
-
"\n",
|
39 |
-
" for env_var, (environment, path) in environments.items():\n",
|
40 |
-
" if env_var in os.environ:\n",
|
41 |
-
" return environment, path, free_plan\n",
|
42 |
-
"\n",
|
43 |
-
"env, root_path, free_plan = detect_environment()\n",
|
44 |
-
"webui_path = f\"{root_path}/sdw\"\n",
|
45 |
-
"\n",
|
46 |
-
"!mkdir -p {root_path}\n",
|
47 |
-
"# ----------------------------------------------\n",
|
48 |
-
"\n",
|
49 |
-
"\n",
|
50 |
-
"# ==================== CSS JS ====================\n",
|
51 |
-
"# custom background images (test)\n",
|
52 |
-
"import argparse\n",
|
53 |
-
"parser = argparse.ArgumentParser(description='This script processes an background image.')\n",
|
54 |
-
"parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')\n",
|
55 |
-
"parser.add_argument('-o', '--opacity', type=float, help='Opacity level for the image, between 0 and 1', metavar='', default=0.3)\n",
|
56 |
-
"parser.add_argument('-b', '--blur', type=str, help='Blur level for the image', metavar='', default=0)\n",
|
57 |
-
"parser.add_argument('-y', type=int, help='Y coordinate for the image in px', metavar='', default=0)\n",
|
58 |
-
"parser.add_argument('-x', type=int, help='X coordinate for the image in px', metavar='', default=0)\n",
|
59 |
-
"parser.add_argument('-s', '--scale', type=int, help='Scale image in %%', metavar='', default=100)\n",
|
60 |
-
"parser.add_argument('-m', '--mode', type=str, help='Specify \"no-repeat\" so that the image pattern is not repeated.', metavar='', default='repeat')\n",
|
61 |
-
"parser.add_argument('-t', '--transparent', action='store_true', help='Flag to exclude z-index from CSS. Makes fields transparent')\n",
|
62 |
-
"args = parser.parse_args()\n",
|
63 |
-
"# ---\n",
|
64 |
-
"url_img, opacity_img, blur_img, y_img, x_img, scale_img, mode_img = args.image, args.opacity, args.blur, args.y, args.x, args.scale, args.mode\n",
|
65 |
-
"\n",
|
66 |
-
"# WTF COLAB - WHAT THE FUCK IS THE DIFFERENCE OF 40 PIXELS!?!?!?\n",
|
67 |
-
"fix_heigh_img = \"-780px\"\n",
|
68 |
-
"if env == \"Google Colab\": # betrayal..\n",
|
69 |
-
" fix_heigh_img = \"-740px\"\n",
|
70 |
-
"\n",
|
71 |
-
"container_background = f'''\n",
|
72 |
-
"<style>\n",
|
73 |
-
":root {{\n",
|
74 |
-
" --img_background: url({url_img});\n",
|
75 |
-
" --img_opacity: {opacity_img};\n",
|
76 |
-
" --img_blur: {blur_img}px;\n",
|
77 |
-
" --image_y: {y_img}px;\n",
|
78 |
-
" --image_x: {x_img}px;\n",
|
79 |
-
" --img_scale: {scale_img}%;\n",
|
80 |
-
" --img_mode: {mode_img};\n",
|
81 |
-
" --img_height_dif: {fix_heigh_img}\n",
|
82 |
-
"}}\n",
|
83 |
-
"\n",
|
84 |
-
".widget-dropdown select,\n",
|
85 |
-
".widget-text input[type=\"text\"] {{\n",
|
86 |
-
" height: 30px;\n",
|
87 |
-
" background-color: #1c1c1c;\n",
|
88 |
-
" border: 1px solid #262626;\n",
|
89 |
-
" border-radius: 10px;\n",
|
90 |
-
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
91 |
-
" transition: all 0.3s ease-in-out;\n",
|
92 |
-
"'''\n",
|
93 |
-
"\n",
|
94 |
-
"if not args.transparent:\n",
|
95 |
-
" container_background += \" z-index: 1;\\n</style>\\n\"\n",
|
96 |
-
"\n",
|
97 |
-
"display(HTML(container_background))\n",
|
98 |
-
"# ---\n",
|
99 |
-
"\n",
|
100 |
-
"CSS = '''\n",
|
101 |
-
"<style>\n",
|
102 |
-
"/* General Styles */\n",
|
103 |
-
".header {\n",
|
104 |
-
" font-family: cursive;\n",
|
105 |
-
" font-size: 20px;\n",
|
106 |
-
" font-weight: bold;\n",
|
107 |
-
" color: #ff8cee;\n",
|
108 |
-
" margin-bottom: 15px;\n",
|
109 |
-
" user-select: none;\n",
|
110 |
-
" cursor: default;\n",
|
111 |
-
" display: inline-block;\n",
|
112 |
-
"}\n",
|
113 |
-
"\n",
|
114 |
-
"hr {\n",
|
115 |
-
" border-color: grey;\n",
|
116 |
-
" background-color: grey;\n",
|
117 |
-
" opacity: 0.25;\n",
|
118 |
-
"}\n",
|
119 |
-
"\n",
|
120 |
-
"a {\n",
|
121 |
-
" text-decoration: none;\n",
|
122 |
-
" color: inherit;\n",
|
123 |
-
"}\n",
|
124 |
-
"\n",
|
125 |
-
"\n",
|
126 |
-
"/* Container style */\n",
|
127 |
-
"\n",
|
128 |
-
".container {\n",
|
129 |
-
" position: relative;\n",
|
130 |
-
" background-color: #232323;\n",
|
131 |
-
" width: 1080px;\n",
|
132 |
-
" padding: 10px 15px;\n",
|
133 |
-
" border-radius: 15px;\n",
|
134 |
-
" box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);\n",
|
135 |
-
" margin-bottom: 5px;\n",
|
136 |
-
" overflow: hidden;\n",
|
137 |
-
"}\n",
|
138 |
-
"\n",
|
139 |
-
".container::after {\n",
|
140 |
-
" position: absolute;\n",
|
141 |
-
" top: 5px;\n",
|
142 |
-
" right: 10px;\n",
|
143 |
-
" content: \"ANXETY\";\n",
|
144 |
-
" font-weight: bold;\n",
|
145 |
-
" font-size: 24px;\n",
|
146 |
-
" color: rgba(0, 0, 0, 0.2);\n",
|
147 |
-
"}\n",
|
148 |
-
"\n",
|
149 |
-
"/* background img */\n",
|
150 |
-
".container::before {\n",
|
151 |
-
" content: \"\";\n",
|
152 |
-
" position: absolute;\n",
|
153 |
-
" top: 0;\n",
|
154 |
-
" left: 0;\n",
|
155 |
-
" right: 0;\n",
|
156 |
-
" bottom: 0;\n",
|
157 |
-
" background-image: var(--img_background);\n",
|
158 |
-
" background-size: var(--img_scale);\n",
|
159 |
-
" background-repeat: var(--img_mode);\n",
|
160 |
-
" opacity: var(--img_opacity);\n",
|
161 |
-
" mix-blend-mode: screen;\n",
|
162 |
-
" pointer-events: none;\n",
|
163 |
-
" filter: blur(var(--img_blur));\n",
|
164 |
-
"}\n",
|
165 |
-
"\n",
|
166 |
-
".image_1::before {\n",
|
167 |
-
" background-position: var(--image_x) calc(-120px - var(--image_y));\n",
|
168 |
-
"}\n",
|
169 |
-
".image_2::before {\n",
|
170 |
-
" background-position: var(--image_x) calc(-290px - var(--image_y));\n",
|
171 |
-
"}\n",
|
172 |
-
".image_3::before {\n",
|
173 |
-
" background-position: var(--image_x) calc(-430px - var(--image_y));\n",
|
174 |
-
"}\n",
|
175 |
-
".image_4::before {\n",
|
176 |
-
" background-position: var(--image_x) calc(var(--img_height_dif) - var(--image_y));\n",
|
177 |
-
"}\n",
|
178 |
-
"\n",
|
179 |
-
".container_custom_downlad {\n",
|
180 |
-
" height: 55px;\n",
|
181 |
-
" transition: all 0.5s;\n",
|
182 |
-
"}\n",
|
183 |
-
"\n",
|
184 |
-
".container_custom_downlad.expanded {\n",
|
185 |
-
" height: 270px;\n",
|
186 |
-
"}\n",
|
187 |
-
"\n",
|
188 |
-
"\n",
|
189 |
-
"/* Element text style */\n",
|
190 |
-
"\n",
|
191 |
-
".widget-html,\n",
|
192 |
-
".widget-button,\n",
|
193 |
-
".widget-text label,\n",
|
194 |
-
".widget-checkbox label,\n",
|
195 |
-
".widget-dropdown label,\n",
|
196 |
-
".widget-dropdown select,\n",
|
197 |
-
".widget-text input[type=\"text\"] {\n",
|
198 |
-
" font-family: cursive;\n",
|
199 |
-
" font-size: 14px;\n",
|
200 |
-
" color: white !important;\n",
|
201 |
-
" user-select: none;\n",
|
202 |
-
"}\n",
|
203 |
-
"\n",
|
204 |
-
".widget-text input[type=\"text\"]::placeholder {\n",
|
205 |
-
" color: grey;\n",
|
206 |
-
"}\n",
|
207 |
-
"\n",
|
208 |
-
"\n",
|
209 |
-
"/* Input field styles */\n",
|
210 |
-
"/*\n",
|
211 |
-
".widget-dropdown select,\n",
|
212 |
-
".widget-text input[type=\"text\"] {\n",
|
213 |
-
" height: 30px;\n",
|
214 |
-
" background-color: #1c1c1c;\n",
|
215 |
-
" border: 1px solid #262626;\n",
|
216 |
-
" border-radius: 10px;\n",
|
217 |
-
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
218 |
-
" transition: all 0.3s ease-in-out;\n",
|
219 |
-
"}\n",
|
220 |
-
"*/\n",
|
221 |
-
"\n",
|
222 |
-
".widget-dropdown select:focus,\n",
|
223 |
-
".widget-text input[type=\"text\"]:focus {\n",
|
224 |
-
" border-color: #006ee5;\n",
|
225 |
-
"}\n",
|
226 |
-
"\n",
|
227 |
-
".widget-dropdown select:hover,\n",
|
228 |
-
".widget-text input[type=\"text\"]:hover {\n",
|
229 |
-
" transform: scale(1.003);\n",
|
230 |
-
" background-color: #262626;\n",
|
231 |
-
" box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);\n",
|
232 |
-
"}\n",
|
233 |
-
"\n",
|
234 |
-
"\n",
|
235 |
-
"/* Slider Checkbox style */\n",
|
236 |
-
"\n",
|
237 |
-
".widget-checkbox input[type=\"checkbox\"] {\n",
|
238 |
-
" appearance: none;\n",
|
239 |
-
" position: relative;\n",
|
240 |
-
" top: 4px; /* Why is he taller?! */\n",
|
241 |
-
" width: 40px;\n",
|
242 |
-
" height: 20px;\n",
|
243 |
-
" border: none;\n",
|
244 |
-
" border-radius: 10px;\n",
|
245 |
-
" background-color: #20b2aa;\n",
|
246 |
-
" cursor: pointer;\n",
|
247 |
-
" box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);\n",
|
248 |
-
" transition: background-color 0.3s ease;\n",
|
249 |
-
"}\n",
|
250 |
-
".widget-checkbox input[type=\"checkbox\"]:checked {\n",
|
251 |
-
" background-color: #2196F3;\n",
|
252 |
-
"}\n",
|
253 |
-
"\n",
|
254 |
-
".widget-checkbox input[type=\"checkbox\"]:before {\n",
|
255 |
-
" content: '';\n",
|
256 |
-
" position: absolute;\n",
|
257 |
-
" top: 50%;\n",
|
258 |
-
" left: 3px;\n",
|
259 |
-
" width: 16px;\n",
|
260 |
-
" height: 16px;\n",
|
261 |
-
" border-radius: inherit;\n",
|
262 |
-
" background-color: white;\n",
|
263 |
-
" box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);\n",
|
264 |
-
" transform: translateY(-50%);\n",
|
265 |
-
" transition: left 0.3s ease;\n",
|
266 |
-
"}\n",
|
267 |
-
".widget-checkbox input[type=\"checkbox\"]:checked:before {\n",
|
268 |
-
" left: 21px;\n",
|
269 |
-
"}\n",
|
270 |
-
"\n",
|
271 |
-
"\n",
|
272 |
-
"/* Button styles */\n",
|
273 |
-
"\n",
|
274 |
-
".button_save {\n",
|
275 |
-
" font-size: 15px;\n",
|
276 |
-
" font-weight: bold;\n",
|
277 |
-
" width: 120px;\n",
|
278 |
-
" height: 35px;\n",
|
279 |
-
" border-radius: 15px;\n",
|
280 |
-
" background-image: radial-gradient(circle at top left, purple 10%, violet 90%);\n",
|
281 |
-
" background-size: 200% 200%;\n",
|
282 |
-
" background-position: left bottom;\n",
|
283 |
-
" transition: background 0.5s ease-in-out, transform 0.3s ease;\n",
|
284 |
-
"}\n",
|
285 |
-
"\n",
|
286 |
-
".button_save:hover {\n",
|
287 |
-
" cursor: pointer;\n",
|
288 |
-
" background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);\n",
|
289 |
-
" background-size: 200% 200%;\n",
|
290 |
-
" background-position: right bottom;\n",
|
291 |
-
" transform: translateY(1px);\n",
|
292 |
-
"}\n",
|
293 |
-
"\n",
|
294 |
-
".button_ngrok {\n",
|
295 |
-
" font-size: 12px;\n",
|
296 |
-
" height: 30px;\n",
|
297 |
-
" border-radius: 10px;\n",
|
298 |
-
" padding: 1px 12px;\n",
|
299 |
-
" background-image: radial-gradient(circle at top left, purple 10%, violet 90%);\n",
|
300 |
-
" background-size: 200% 200%;\n",
|
301 |
-
" background-position: left bottom;\n",
|
302 |
-
" transition: background 0.5s ease-in-out, transform 0.3s ease;\n",
|
303 |
-
" white-space: nowrap;\n",
|
304 |
-
"}\n",
|
305 |
-
"\n",
|
306 |
-
".button_ngrok:hover {\n",
|
307 |
-
" cursor: pointer;\n",
|
308 |
-
" background-image: radial-gradient(circle at top left, purple 10%, #1D94BB 90%);\n",
|
309 |
-
" background-size: 200% 200%;\n",
|
310 |
-
" background-position: right bottom;\n",
|
311 |
-
" transform: translateY(1px);\n",
|
312 |
-
"}\n",
|
313 |
-
"\n",
|
314 |
-
".button_save:active,\n",
|
315 |
-
".button_ngrok:active {\n",
|
316 |
-
" filter: brightness(0.75) !important;\n",
|
317 |
-
"}\n",
|
318 |
-
"\n",
|
319 |
-
"/* Removes ugly stroke from widget buttons. */\n",
|
320 |
-
".jupyter-widgets.lm-Widget:focus {\n",
|
321 |
-
" outline: none;\n",
|
322 |
-
"}\n",
|
323 |
-
"\n",
|
324 |
-
"\n",
|
325 |
-
"/* Popup style of `FAQ` window */\n",
|
326 |
-
"\n",
|
327 |
-
".info {\n",
|
328 |
-
" position: absolute;\n",
|
329 |
-
" top: -5px;\n",
|
330 |
-
" right: 95px;\n",
|
331 |
-
" color: grey;\n",
|
332 |
-
" font-family: cursive;\n",
|
333 |
-
" font-size: 14px;\n",
|
334 |
-
" font-weight: normal;\n",
|
335 |
-
" user-select: none;\n",
|
336 |
-
" pointer-events: none;\n",
|
337 |
-
" opacity: 0;\n",
|
338 |
-
" transition: opacity 0.3s ease-in-out;\n",
|
339 |
-
" display: inline-block;\n",
|
340 |
-
"}\n",
|
341 |
-
"\n",
|
342 |
-
".popup {\n",
|
343 |
-
" position: absolute;\n",
|
344 |
-
" top: 120px;\n",
|
345 |
-
" z-index: 999;\n",
|
346 |
-
" width: auto;\n",
|
347 |
-
" padding: 10px;\n",
|
348 |
-
" text-align: center;\n",
|
349 |
-
" background-color: rgba(255, 255, 255, 0.05);\n",
|
350 |
-
" backdrop-filter: blur(20px);\n",
|
351 |
-
" border: 1px solid rgba(255, 255, 255, 0.45);\n",
|
352 |
-
" border-radius: 8px;\n",
|
353 |
-
" box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);\n",
|
354 |
-
" opacity: 0;\n",
|
355 |
-
" color: #fff;\n",
|
356 |
-
" font-size: 16px;\n",
|
357 |
-
" font-family: cursive;\n",
|
358 |
-
" user-select: none;\n",
|
359 |
-
" cursor: default;\n",
|
360 |
-
" pointer-events: none;\n",
|
361 |
-
" transform: rotate(-5deg);\n",
|
362 |
-
" transition: top 0.3s ease-in-out, opacity 0.3s ease-in-out, transform 0.3s ease-in-out;\n",
|
363 |
-
"}\n",
|
364 |
-
"\n",
|
365 |
-
".sample {\n",
|
366 |
-
" display: inline-block;\n",
|
367 |
-
" margin-top: 25px;\n",
|
368 |
-
" padding: 10px 100px;\n",
|
369 |
-
" background-color: rgba(255, 255, 255, 0.2);\n",
|
370 |
-
" color: #c6e2ff;\n",
|
371 |
-
" border: 2px solid rgba(255, 255, 255, 0.2);\n",
|
372 |
-
" border-radius: 8px;\n",
|
373 |
-
" box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), inset 0 0 25px rgba(255, 255, 255, 0.2);\n",
|
374 |
-
"}\n",
|
375 |
-
"\n",
|
376 |
-
".info.showed {\n",
|
377 |
-
" opacity: 1;\n",
|
378 |
-
" pointer-events: auto;\n",
|
379 |
-
"}\n",
|
380 |
-
"\n",
|
381 |
-
".info:hover + .popup {\n",
|
382 |
-
" top: 35px;\n",
|
383 |
-
" opacity: 1;\n",
|
384 |
-
" pointer-events: initial;\n",
|
385 |
-
" transform: rotate(0deg);\n",
|
386 |
-
"}\n",
|
387 |
-
"\n",
|
388 |
-
"\n",
|
389 |
-
"/* Animation of elements */\n",
|
390 |
-
"\n",
|
391 |
-
".container,\n",
|
392 |
-
".button_save {\n",
|
393 |
-
" animation-name: showedWidgets;\n",
|
394 |
-
" animation-duration: 1s;\n",
|
395 |
-
" animation-fill-mode: forwards;\n",
|
396 |
-
"}\n",
|
397 |
-
"\n",
|
398 |
-
".container.hide,\n",
|
399 |
-
".button_save.hide {\n",
|
400 |
-
" animation-name: hideWidgets;\n",
|
401 |
-
" animation-duration: 0.5s;\n",
|
402 |
-
" animation-fill-mode: forwards;\n",
|
403 |
-
"}\n",
|
404 |
-
"\n",
|
405 |
-
"@keyframes showedWidgets {\n",
|
406 |
-
" 0% {\n",
|
407 |
-
" transform: translate3d(-65%, 15%, 0) scale(0) rotate(15deg);\n",
|
408 |
-
" filter: blur(25px) grayscale(1) brightness(0.3);\n",
|
409 |
-
" opacity: 0;\n",
|
410 |
-
" }\n",
|
411 |
-
" 100% {\n",
|
412 |
-
" transform: translate3d(0, 0, 0) scale(1) rotate(0deg);\n",
|
413 |
-
" filter: blur(0) grayscale(0) brightness(1);\n",
|
414 |
-
" opacity: 1;\n",
|
415 |
-
" }\n",
|
416 |
-
"}\n",
|
417 |
-
"\n",
|
418 |
-
"@keyframes hideWidgets {\n",
|
419 |
-
" 0% {\n",
|
420 |
-
" transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);\n",
|
421 |
-
" filter: blur(0) grayscale(0) brightness(1);\n",
|
422 |
-
" opacity: 1;\n",
|
423 |
-
" }\n",
|
424 |
-
" 100% {\n",
|
425 |
-
" transform: translate3d(0, 5%, 0) scale(0.9) rotate3d(1, 0, 0, 90deg);\n",
|
426 |
-
" filter: blur(15px) grayscale(1) brightness(0.5);\n",
|
427 |
-
" opacity: 0;\n",
|
428 |
-
" }\n",
|
429 |
-
"}\n",
|
430 |
-
"</style>\n",
|
431 |
-
"\n",
|
432 |
-
"<!-- TOGGLE 'CustomDL' SCRIPT -->\n",
|
433 |
-
"<script>\n",
|
434 |
-
"function toggleContainer() {\n",
|
435 |
-
" let downloadContainer = document.querySelector('.container_custom_downlad');\n",
|
436 |
-
" let info = document.querySelector('.info');\n",
|
437 |
-
"\n",
|
438 |
-
" downloadContainer.classList.toggle('expanded');\n",
|
439 |
-
" info.classList.toggle('showed');\n",
|
440 |
-
"}\n",
|
441 |
-
"</script>\n",
|
442 |
-
"'''\n",
|
443 |
-
"\n",
|
444 |
-
"display(HTML(CSS))\n",
|
445 |
-
"# ==================== CSS JS ====================\n",
|
446 |
-
"\n",
|
447 |
-
"\n",
|
448 |
-
"# ==================== WIDGETS ====================\n",
|
449 |
-
"# --- global widgets ---\n",
|
450 |
-
"style = {'description_width': 'initial'}\n",
|
451 |
-
"layout = widgets.Layout(min_width='1047px')\n",
|
452 |
-
"\n",
|
453 |
-
"HR = widgets.HTML('<hr>')\n",
|
454 |
-
"\n",
|
455 |
-
"# --- MODEL ---\n",
|
456 |
-
"model_header = widgets.HTML('<div class=\"header\">Model Selection<div>')\n",
|
457 |
-
"model_options = ['none',\n",
|
458 |
-
" '1.Anime (by XpucT) + INP',\n",
|
459 |
-
" '2.BluMix [Anime] [V7]',\n",
|
460 |
-
" '3.Cetus-Mix [Anime] [V4] + INP',\n",
|
461 |
-
" '4.Counterfeit [Anime] [V3] + INP',\n",
|
462 |
-
" '5.CuteColor [Anime] [V3]',\n",
|
463 |
-
" '6.Dark-Sushi-Mix [Anime]',\n",
|
464 |
-
" '7.Deliberate [Realism] [V6] + INP',\n",
|
465 |
-
" '8.Meina-Mix [Anime] [V11] + INP',\n",
|
466 |
-
" '9.Mix-Pro [Anime] [V4] + INP']\n",
|
467 |
-
"# ---\n",
|
468 |
-
"Model_widget = widgets.Dropdown(options=model_options, value='4.Counterfeit [Anime] [V3] + INP', description='Model:', style=style, layout=layout)\n",
|
469 |
-
"Model_Num_widget = widgets.Text(description='Model Number:', placeholder='Enter the model numbers to be downloaded using comma/space.', style=style, layout=layout)\n",
|
470 |
-
"Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Models', style=style)\n",
|
471 |
-
"\n",
|
472 |
-
"''' Display Model'''\n",
|
473 |
-
"all_model_box = widgets.VBox([model_header, Model_widget, Model_Num_widget, Inpainting_Model_widget]).add_class(\"container\").add_class(\"image_1\")\n",
|
474 |
-
"display(all_model_box)\n",
|
475 |
-
"\n",
|
476 |
-
"# --- VAE ---\n",
|
477 |
-
"vae_header = widgets.HTML('<div class=\"header\" >VAE Selection</div>')\n",
|
478 |
-
"vae_options = ['none',\n",
|
479 |
-
" '1.Anime.vae',\n",
|
480 |
-
" '2.Anything.vae',\n",
|
481 |
-
" '3.Blessed2.vae',\n",
|
482 |
-
" '4.ClearVae.vae',\n",
|
483 |
-
" '5.WD.vae']\n",
|
484 |
-
"Vae_widget = widgets.Dropdown(options=vae_options, value='3.Blessed2.vae', description='Vae:', style=style, layout=layout)\n",
|
485 |
-
"Vae_Num_widget = widgets.Text(description='Vae Number:', placeholder='Enter the vae numbers to be downloaded using comma/space.', style=style, layout=layout)\n",
|
486 |
-
"\n",
|
487 |
-
"''' Display Vae'''\n",
|
488 |
-
"all_vae_box= widgets.VBox([vae_header, Vae_widget, Vae_Num_widget]).add_class(\"container\").add_class(\"image_2\")\n",
|
489 |
-
"display(all_vae_box)\n",
|
490 |
-
"\n",
|
491 |
-
"# --- ADDITIONAL ---\n",
|
492 |
-
"additional_header = widgets.HTML('<div class=\"header\">Additional</div>')\n",
|
493 |
-
"latest_webui_widget = widgets.Checkbox(value=True, description='Update WebUI', style=style)\n",
|
494 |
-
"latest_exstensions_widget = widgets.Checkbox(value=True, description='Update Extensions', style=style)\n",
|
495 |
-
"detailed_download_widget = widgets.Dropdown(options=['off', 'on'], value='off', description='Detailed Download:', style=style)\n",
|
496 |
-
"latest_changes_widget = HBox([latest_webui_widget, latest_exstensions_widget, detailed_download_widget], layout=widgets.Layout(justify_content='space-between'))\n",
|
497 |
-
"controlnet_options = ['none', 'ALL', '1.canny',\n",
|
498 |
-
" '2.openpose', '3.depth',\n",
|
499 |
-
" '4.normal_map', '5.mlsd',\n",
|
500 |
-
" '6.lineart', '7.soft_edge',\n",
|
501 |
-
" '8.scribble', '9.segmentation',\n",
|
502 |
-
" '10.shuffle', '11.tile',\n",
|
503 |
-
" '12.inpaint', '13.instruct_p2p']\n",
|
504 |
-
"# ---\n",
|
505 |
-
"controlnet_widget = widgets.Dropdown(options=controlnet_options, value='none', description='ControlNet:', style=style, layout=layout)\n",
|
506 |
-
"controlnet_Num_widget = widgets.Text(description='ControlNet Number:', placeholder='Enter the ControlNet model numbers to be downloaded using comma/space.', style=style, layout=layout)\n",
|
507 |
-
"commit_hash_widget = widgets.Text(description='Commit Hash:', style=style, layout=layout)\n",
|
508 |
-
"optional_huggingface_token_widget = widgets.Text(description='HuggingFace Token:', style=style, layout=layout)\n",
|
509 |
-
"ngrok_token_widget = widgets.Text(description='Ngrok Token:', style=style, layout=widgets.Layout(width='1047px'))\n",
|
510 |
-
"ngrock_button = widgets.HTML('<a href=\"https://dashboard.ngrok.com/get-started/your-authtoken\" target=\"_blank\">Get Ngrok Token</a>').add_class(\"button_ngrok\")\n",
|
511 |
-
"ngrok_widget = widgets.HBox([ngrok_token_widget, ngrock_button], style=style, layout=layout)\n",
|
512 |
-
"zrok_token_widget = widgets.Text(description='Zrok Token:', style=style, layout=widgets.Layout(width='1047px'))\n",
|
513 |
-
"zrok_button = widgets.HTML('<a href=\"https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU\" target=\"_blank\">Reg Zrok Token</a>').add_class(\"button_ngrok\")\n",
|
514 |
-
"zrok_widget = widgets.HBox([zrok_token_widget, zrok_button], style=style, layout=layout)\n",
|
515 |
-
"# ---\n",
|
516 |
-
"commandline_arguments_options = \"--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers\"\n",
|
517 |
-
"commandline_arguments_widget = widgets.Text(description='Arguments:', value=commandline_arguments_options, style=style, layout=layout)\n",
|
518 |
-
"\n",
|
519 |
-
"''' Display Additional'''\n",
|
520 |
-
"additional_widget_list = [additional_header, latest_changes_widget, HR, controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, zrok_widget, HR, commandline_arguments_widget]\n",
|
521 |
-
"if free_plan and env == \"Google Colab\": # remove ngrok from colab\n",
|
522 |
-
" additional_widget_list.remove(ngrok_widget)\n",
|
523 |
-
"if env == \"SageMaker Studio Lab\": # remove zrok from sagemaker\n",
|
524 |
-
" additional_widget_list.remove(zrok_widget)\n",
|
525 |
-
"# ```\n",
|
526 |
-
"all_additional_box = widgets.VBox(additional_widget_list).add_class(\"container\").add_class(\"image_3\")\n",
|
527 |
-
"display(all_additional_box)\n",
|
528 |
-
"\n",
|
529 |
-
"# --- CUSTOM DOWNLOAD ---\n",
|
530 |
-
"custom_download_header_popup = widgets.HTML('''\n",
|
531 |
-
"<style>\n",
|
532 |
-
"/* Term Colors */\n",
|
533 |
-
".sample_label {color: #dbafff;}\n",
|
534 |
-
".braces {color: #ffff00;}\n",
|
535 |
-
".extension {color: #eb934b;}\n",
|
536 |
-
".file_name {color: #ffffd8;}\n",
|
537 |
-
"</style>\n",
|
538 |
-
"\n",
|
539 |
-
"<div class=\"header\" style=\"cursor: pointer;\" onclick=\"toggleContainer()\">Custom Download</div>\n",
|
540 |
-
"<!-- PopUp Window -->\n",
|
541 |
-
"<div class=\"info\">INFO</div>\n",
|
542 |
-
"<div class=\"popup\">\n",
|
543 |
-
" Separate multiple URLs with a comma/space. For a <span class=\"file_name\">custom name</span> file/extension, specify it with <span class=\"braces\">[]</span>\n",
|
544 |
-
" after the URL without spaces.\n",
|
545 |
-
" <span style=\"color: #ff9999\">For files, be sure to specify</span> - <span class=\"extension\">Filename Extension.</span>\n",
|
546 |
-
" <div class=\"sample\">\n",
|
547 |
-
" <span class=\"sample_label\">Example for File:</span>\n",
|
548 |
-
" https://civitai.com/api/download/models/229782<span class=\"braces\">[</span><span class=\"file_name\">Detailer</span><span class=\"extension\">.safetensors</span><span class=\"braces\">]</span>\n",
|
549 |
-
" <br>\n",
|
550 |
-
" <span class=\"sample_label\">Example for Extension:</span>\n",
|
551 |
-
" https://github.com/hako-mikan/sd-webui-regional-prompter<span class=\"braces\">[</span><span class=\"file_name\">Regional-Prompter</span><span class=\"braces\">]</span>\n",
|
552 |
-
" </div>\n",
|
553 |
-
"</div>\n",
|
554 |
-
"''')\n",
|
555 |
-
"# ---\n",
|
556 |
-
"Model_url_widget = widgets.Text(description='Model:', style=style, layout=layout)\n",
|
557 |
-
"Vae_url_widget = widgets.Text(description='Vae:', style=style, layout=layout)\n",
|
558 |
-
"LoRA_url_widget = widgets.Text(description='LoRa:', style=style, layout=layout)\n",
|
559 |
-
"Embedding_url_widget = widgets.Text(description='Embedding:', style=style, layout=layout)\n",
|
560 |
-
"Extensions_url_widget = widgets.Text(description='Extensions:', style=style, layout=layout)\n",
|
561 |
-
"custom_file_urls_widget = widgets.Text(description='File (txt):', style=style, layout=layout)\n",
|
562 |
-
"\n",
|
563 |
-
"''' Display CustomDl'''\n",
|
564 |
-
"all_custom_box = widgets.VBox([\n",
|
565 |
-
" custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget\n",
|
566 |
-
" ]).add_class(\"container\").add_class(\"image_4\").add_class(\"container_custom_downlad\")\n",
|
567 |
-
"display(all_custom_box)\n",
|
568 |
-
"\n",
|
569 |
-
"# --- Save Button ---\n",
|
570 |
-
"save_button = widgets.Button(description='Save').add_class(\"button_save\")\n",
|
571 |
-
"display(save_button)\n",
|
572 |
-
"\n",
|
573 |
-
"\n",
|
574 |
-
"# ============ Load / Save - Settings V2 ============\n",
|
575 |
-
"SETTINGS_FILE = f'{root_path}/settings.json'\n",
|
576 |
-
"\n",
|
577 |
-
"settings_keys = [\n",
|
578 |
-
" 'Model', 'Model_Num', 'Inpainting_Model',\n",
|
579 |
-
" 'Vae', 'Vae_Num',\n",
|
580 |
-
" 'latest_webui', 'latest_exstensions', 'detailed_download',\n",
|
581 |
-
" 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',\n",
|
582 |
-
" 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
|
583 |
-
" 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'\n",
|
584 |
-
"]\n",
|
585 |
-
"\n",
|
586 |
-
"def save_settings():\n",
|
587 |
-
" settings = {key: globals()[f\"{key}_widget\"].value for key in settings_keys}\n",
|
588 |
-
" with open(SETTINGS_FILE, 'w') as f:\n",
|
589 |
-
" json.dump(settings, f)\n",
|
590 |
-
"\n",
|
591 |
-
"def load_settings():\n",
|
592 |
-
" if os.path.exists(SETTINGS_FILE):\n",
|
593 |
-
" with open(SETTINGS_FILE, 'r') as f:\n",
|
594 |
-
" settings = json.load(f)\n",
|
595 |
-
" for key in settings_keys:\n",
|
596 |
-
" globals()[f\"{key}_widget\"].value = settings.get(key)\n",
|
597 |
-
"\n",
|
598 |
-
"def save_data(button):\n",
|
599 |
-
" save_settings()\n",
|
600 |
-
"\n",
|
601 |
-
" # --- uhh - hide... ---\n",
|
602 |
-
" widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]\n",
|
603 |
-
" for widget in widgets_list:\n",
|
604 |
-
" widget.add_class(\"hide\")\n",
|
605 |
-
" time.sleep(0.5)\n",
|
606 |
-
"\n",
|
607 |
-
" widgets.Widget.close_all()\n",
|
608 |
-
"\n",
|
609 |
-
"settings = load_settings()\n",
|
610 |
-
"save_button.on_click(save_data)"
|
611 |
-
],
|
612 |
-
"metadata": {
|
613 |
-
"id": "2lJmbqrs3Mu8"
|
614 |
-
},
|
615 |
-
"execution_count": null,
|
616 |
-
"outputs": []
|
617 |
-
}
|
618 |
-
]
|
619 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/notebooks/ru/auto-cleaner_ru.ipynb
DELETED
@@ -1,380 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"nbformat": 4,
|
3 |
-
"nbformat_minor": 0,
|
4 |
-
"metadata": {
|
5 |
-
"colab": {
|
6 |
-
"provenance": []
|
7 |
-
},
|
8 |
-
"kernelspec": {
|
9 |
-
"name": "python3",
|
10 |
-
"display_name": "Python 3"
|
11 |
-
},
|
12 |
-
"language_info": {
|
13 |
-
"name": "python"
|
14 |
-
}
|
15 |
-
},
|
16 |
-
"cells": [
|
17 |
-
{
|
18 |
-
"cell_type": "code",
|
19 |
-
"source": [
|
20 |
-
"##~ AutoCleaner V3.6 CODE | BY: ANXETY ~##\n",
|
21 |
-
"\n",
|
22 |
-
"# --change log--\n",
|
23 |
-
"\"\"\"\n",
|
24 |
-
"V3.6 | 13.03.24\n",
|
25 |
-
"Fixed selection window\n",
|
26 |
-
"Dynamic update of memory display\n",
|
27 |
-
"\"\"\"\n",
|
28 |
-
"\n",
|
29 |
-
"\n",
|
30 |
-
"import os\n",
|
31 |
-
"import time\n",
|
32 |
-
"import ipywidgets as widgets\n",
|
33 |
-
"from ipywidgets import Label, Button, VBox, HBox\n",
|
34 |
-
"from IPython.display import display, HTML\n",
|
35 |
-
"\n",
|
36 |
-
"\n",
|
37 |
-
"# ================= DETECT ENV =================\n",
|
38 |
-
"def detect_environment():\n",
|
39 |
-
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
40 |
-
" environments = {\n",
|
41 |
-
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
42 |
-
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
43 |
-
" 'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', \"/home/studio-lab-user/content\")\n",
|
44 |
-
" }\n",
|
45 |
-
"\n",
|
46 |
-
" for env_var, (environment, path) in environments.items():\n",
|
47 |
-
" if env_var in os.environ:\n",
|
48 |
-
" return environment, path, free_plan\n",
|
49 |
-
"\n",
|
50 |
-
"env, root_path, free_plan = detect_environment()\n",
|
51 |
-
"webui_path = f\"{root_path}/sdw\"\n",
|
52 |
-
"# ----------------------------------------------\n",
|
53 |
-
"\n",
|
54 |
-
"\n",
|
55 |
-
"directories = {\n",
|
56 |
-
" \"Изображения\": f\"{webui_path}/outputs\",\n",
|
57 |
-
" \"Модели\": f\"{webui_path}/models/Stable-diffusion/\",\n",
|
58 |
-
" \"Vae\": f\"{webui_path}/models/VAE/\",\n",
|
59 |
-
" \"LoRa\": f\"{webui_path}/models/Lora/\",\n",
|
60 |
-
" \"ControlNet Модели\": f\"{webui_path}/models/ControlNet/\"\n",
|
61 |
-
"}\n",
|
62 |
-
"\n",
|
63 |
-
"\n",
|
64 |
-
"# ==================== CSS ====================\n",
|
65 |
-
"CSS_AC = \"\"\"\n",
|
66 |
-
"<style>\n",
|
67 |
-
"/* General Styles */\n",
|
68 |
-
"\n",
|
69 |
-
"hr {\n",
|
70 |
-
" border-color: grey;\n",
|
71 |
-
" background-color: grey;\n",
|
72 |
-
" opacity: 0.25;\n",
|
73 |
-
"}\n",
|
74 |
-
"\n",
|
75 |
-
".instruction_AC {\n",
|
76 |
-
" font-family: cursive;\n",
|
77 |
-
" font-size: 18px;\n",
|
78 |
-
" color: grey;\n",
|
79 |
-
" user-select: none;\n",
|
80 |
-
" cursor: default;\n",
|
81 |
-
"}\n",
|
82 |
-
"\n",
|
83 |
-
"\n",
|
84 |
-
"/* Container style */\n",
|
85 |
-
"\n",
|
86 |
-
".container_AC {\n",
|
87 |
-
" position: relative;\n",
|
88 |
-
" background-color: #232323;\n",
|
89 |
-
" width: 800px;\n",
|
90 |
-
" height: auto;\n",
|
91 |
-
" padding: 15px;\n",
|
92 |
-
" border-radius: 15px;\n",
|
93 |
-
" box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);\n",
|
94 |
-
" margin-bottom: 5px;\n",
|
95 |
-
" overflow: visible;\n",
|
96 |
-
"}\n",
|
97 |
-
"\n",
|
98 |
-
".container_AC::before {\n",
|
99 |
-
" position: absolute;\n",
|
100 |
-
" top: 5px;\n",
|
101 |
-
" right: 10px;\n",
|
102 |
-
" content: \"AutoCleanerV3.6\";\n",
|
103 |
-
" font-weight: bold;\n",
|
104 |
-
" font-size: 24px;\n",
|
105 |
-
" color: rgba(0, 0, 0, 0.2);\n",
|
106 |
-
"}\n",
|
107 |
-
"\n",
|
108 |
-
".container_AC::after {\n",
|
109 |
-
" position: absolute;\n",
|
110 |
-
" top: 30px;\n",
|
111 |
-
" right: 10px;\n",
|
112 |
-
" content: \"ANXETY\";\n",
|
113 |
-
" font-weight: bold;\n",
|
114 |
-
" font-size: 18px;\n",
|
115 |
-
" color: rgba(0, 0, 0, 0.2);\n",
|
116 |
-
"}\n",
|
117 |
-
"\n",
|
118 |
-
".custom-select-multiple_AC select {\n",
|
119 |
-
" padding: 10px;\n",
|
120 |
-
" font-family: cursive;\n",
|
121 |
-
" border: 1px solid #262626 !important;\n",
|
122 |
-
" border-radius: 10px;\n",
|
123 |
-
" color: white;\n",
|
124 |
-
" background-color: #1c1c1c;\n",
|
125 |
-
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
126 |
-
"}\n",
|
127 |
-
"\n",
|
128 |
-
".output_AC {\n",
|
129 |
-
" padding: 10px;\n",
|
130 |
-
" height: auto;\n",
|
131 |
-
" border: 1px solid #262626;\n",
|
132 |
-
" border-radius: 10px;\n",
|
133 |
-
" background-color: #1c1c1c;\n",
|
134 |
-
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
135 |
-
" width: auto;\n",
|
136 |
-
" box-sizing: border-box;\n",
|
137 |
-
"}\n",
|
138 |
-
"\n",
|
139 |
-
".output_message_AC {\n",
|
140 |
-
" font-family: cursive;\n",
|
141 |
-
" color: white !important;\n",
|
142 |
-
" font-size: 14px;\n",
|
143 |
-
" user-select: none;\n",
|
144 |
-
" cursor: default\n",
|
145 |
-
"}\n",
|
146 |
-
"\n",
|
147 |
-
"\n",
|
148 |
-
".storage_info_AC {\n",
|
149 |
-
" padding: 5px 20px;\n",
|
150 |
-
" height: auto;\n",
|
151 |
-
" border: 1px solid #262626;\n",
|
152 |
-
" border-radius: 10px;\n",
|
153 |
-
" background-color: #1c1c1c;\n",
|
154 |
-
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
155 |
-
" width: auto;\n",
|
156 |
-
" font-family: cursive;\n",
|
157 |
-
" color: #B2B2B2 !important;\n",
|
158 |
-
" font-size: 14px;\n",
|
159 |
-
" user-select: none;\n",
|
160 |
-
" cursor: default\n",
|
161 |
-
"}\n",
|
162 |
-
"\n",
|
163 |
-
"\n",
|
164 |
-
"/* Button and storage info layout */\n",
|
165 |
-
".lower_information_panel_AC {\n",
|
166 |
-
" display: flex;\n",
|
167 |
-
" align-items: center;\n",
|
168 |
-
" justify-content: space-between;\n",
|
169 |
-
"}\n",
|
170 |
-
"\n",
|
171 |
-
"\n",
|
172 |
-
"/* Button style */\n",
|
173 |
-
"\n",
|
174 |
-
".button_AC {\n",
|
175 |
-
" width: auto;\n",
|
176 |
-
" font-family: cursive;\n",
|
177 |
-
" color: white !important;\n",
|
178 |
-
" font-size: 14px;\n",
|
179 |
-
" font-weight: bold;\n",
|
180 |
-
" height: 35px;\n",
|
181 |
-
" border-radius: 15px;\n",
|
182 |
-
" background-image: radial-gradient(circle at top left, purple 10%, violet 90%);\n",
|
183 |
-
" background-size: 200% 200%;\n",
|
184 |
-
" background-position: left bottom;\n",
|
185 |
-
" transition: background 0.5s ease-in-out, transform 0.3s ease;\n",
|
186 |
-
"}\n",
|
187 |
-
"\n",
|
188 |
-
".button_AC:hover {\n",
|
189 |
-
" cursor: pointer;\n",
|
190 |
-
" background-size: 200% 200%;\n",
|
191 |
-
" background-position: right bottom;\n",
|
192 |
-
" transform: translateY(1px);\n",
|
193 |
-
"}\n",
|
194 |
-
"\n",
|
195 |
-
".button_execute_AC:hover {\n",
|
196 |
-
" background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);\n",
|
197 |
-
"}\n",
|
198 |
-
"\n",
|
199 |
-
".button_clear_AC:hover {\n",
|
200 |
-
" background-image: radial-gradient(circle at top left, purple 10%, #fc3468 90%);\n",
|
201 |
-
"}\n",
|
202 |
-
"\n",
|
203 |
-
".button_execute_AC:active,\n",
|
204 |
-
".button_clear_AC:active {\n",
|
205 |
-
" filter: brightness(0.75);\n",
|
206 |
-
"}\n",
|
207 |
-
"\n",
|
208 |
-
".jupyter-widgets.lm-Widget:focus {\n",
|
209 |
-
" outline: none;\n",
|
210 |
-
"}\n",
|
211 |
-
"\n",
|
212 |
-
"\n",
|
213 |
-
"/* Animation of elements */\n",
|
214 |
-
"\n",
|
215 |
-
"/* Emergence */\n",
|
216 |
-
".container_AC {\n",
|
217 |
-
" animation-name: slideInTopBlur;\n",
|
218 |
-
" animation-duration: 0.7s;\n",
|
219 |
-
" animation-fill-mode: forwards;\n",
|
220 |
-
"}\n",
|
221 |
-
"\n",
|
222 |
-
"@keyframes slideInTopBlur {\n",
|
223 |
-
" 0% {\n",
|
224 |
-
" transform: translate3d(0, 50%, 0) scale(0.85) rotate3d(1, 0, 0, -85deg);\n",
|
225 |
-
" filter: blur(5px) grayscale(1) brightness(0.5);\n",
|
226 |
-
" opacity: 0;\n",
|
227 |
-
" }\n",
|
228 |
-
" 100% {\n",
|
229 |
-
" transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);\n",
|
230 |
-
" filter: blur(0) grayscale(0) brightness(1);\n",
|
231 |
-
" opacity: 1;\n",
|
232 |
-
" }\n",
|
233 |
-
"}\n",
|
234 |
-
"\n",
|
235 |
-
"/* Leaving */\n",
|
236 |
-
".container_AC.hide {\n",
|
237 |
-
" animation-name: slideOutTopBlur;\n",
|
238 |
-
" animation-duration: 0.3s;\n",
|
239 |
-
" animation-fill-mode: forwards;\n",
|
240 |
-
"}\n",
|
241 |
-
"\n",
|
242 |
-
"@keyframes slideOutTopBlur {\n",
|
243 |
-
" 0% {\n",
|
244 |
-
" transform: translate3d(0, 0, 0) scale(1);\n",
|
245 |
-
" filter: blur(0) grayscale(0) brightness(1);\n",
|
246 |
-
" opacity: 1;\n",
|
247 |
-
" }\n",
|
248 |
-
" 100% {\n",
|
249 |
-
" transform: translate3d(0, -100%, 0);\n",
|
250 |
-
" filter: blur(5px) grayscale(1) brightness(0);\n",
|
251 |
-
" opacity: 0;\n",
|
252 |
-
" }\n",
|
253 |
-
"}\n",
|
254 |
-
"</style>\n",
|
255 |
-
"\"\"\"\n",
|
256 |
-
"\n",
|
257 |
-
"display(HTML(CSS_AC))\n",
|
258 |
-
"# ==================== CSS ====================\n",
|
259 |
-
"\n",
|
260 |
-
"\n",
|
261 |
-
"# ================ AutoCleaner function ================\n",
|
262 |
-
"def clean_directory(directory):\n",
|
263 |
-
" deleted_files = 0\n",
|
264 |
-
" for root, dirs, files in os.walk(directory):\n",
|
265 |
-
" for file in files:\n",
|
266 |
-
" if file.endswith(\".txt\"):\n",
|
267 |
-
" continue\n",
|
268 |
-
" os.remove(os.path.join(root, file))\n",
|
269 |
-
" if not file.endswith(\".yaml\"):\n",
|
270 |
-
" deleted_files += 1\n",
|
271 |
-
" return deleted_files\n",
|
272 |
-
"\n",
|
273 |
-
"\n",
|
274 |
-
"def get_word_variant(n, variants):\n",
|
275 |
-
" unit = abs(n) % 10\n",
|
276 |
-
" tens = abs(n) % 100\n",
|
277 |
-
" if tens in range(11, 15):\n",
|
278 |
-
" return variants[2]\n",
|
279 |
-
" elif unit == 1:\n",
|
280 |
-
" return variants[0]\n",
|
281 |
-
" elif unit in range(2, 5):\n",
|
282 |
-
" return variants[1]\n",
|
283 |
-
" else:\n",
|
284 |
-
" return variants[2]\n",
|
285 |
-
"\n",
|
286 |
-
"\n",
|
287 |
-
"def update_memory_info():\n",
|
288 |
-
" disk_space = psutil.disk_usage(os.getcwd())\n",
|
289 |
-
" total = disk_space.total / (1024 ** 3)\n",
|
290 |
-
" used = disk_space.used / (1024 ** 3)\n",
|
291 |
-
" free = disk_space.free / (1024 ** 3)\n",
|
292 |
-
"\n",
|
293 |
-
" storage_info.value = f'''\n",
|
294 |
-
" <div class=\"storage_info_AC\">Всего: {total:.2f} GB <span style=\"color: #555\">|</span> Используется: {used:.2f} GB <span style=\"color: #555\">|</span> Свободно: {free:.2f} GB</div>\n",
|
295 |
-
" '''\n",
|
296 |
-
"\n",
|
297 |
-
"\n",
|
298 |
-
"def on_execute_button_press(button):\n",
|
299 |
-
" selected_cleaners = auto_cleaner_widget.value\n",
|
300 |
-
" deleted_files_dict = {}\n",
|
301 |
-
"\n",
|
302 |
-
" for option in selected_cleaners:\n",
|
303 |
-
" if option in directories:\n",
|
304 |
-
" deleted_files_dict[option] = clean_directory(directories[option])\n",
|
305 |
-
"\n",
|
306 |
-
" output.clear_output()\n",
|
307 |
-
"\n",
|
308 |
-
" with output:\n",
|
309 |
-
" for message in generate_messages(deleted_files_dict):\n",
|
310 |
-
" message_widget = HTML(f'<p class=\"output_message_AC\">{message}</p>')\n",
|
311 |
-
" display(message_widget)\n",
|
312 |
-
"\n",
|
313 |
-
" update_memory_info()\n",
|
314 |
-
"\n",
|
315 |
-
"\n",
|
316 |
-
"def on_clear_button_press(button):\n",
|
317 |
-
" container.add_class(\"hide\")\n",
|
318 |
-
" time.sleep(0.5)\n",
|
319 |
-
" widgets.Widget.close_all()\n",
|
320 |
-
"\n",
|
321 |
-
"\n",
|
322 |
-
"def generate_messages(deleted_files_dict):\n",
|
323 |
-
" messages = []\n",
|
324 |
-
" word_variants = {\n",
|
325 |
-
" \"Изображения\": [\"Изображение\", \"Изображения\", \"Изображений\"],\n",
|
326 |
-
" \"Модели\": [\"Модель\", \"Модели\", \"Моделей\"],\n",
|
327 |
-
" \"Vae\": [\"VAE\", \"VAE\", \"VAE\"],\n",
|
328 |
-
" \"LoRa\": [\"LoRa\", \"LoRa\", \"LoRa\"],\n",
|
329 |
-
" \"ControlNet Модели\": [\"ControlNet Модель\", \"ControlNet Модели\", \"ControlNet Моделей\"]\n",
|
330 |
-
" }\n",
|
331 |
-
" deleted_word_variants = [\"Удалена\", \"Удалены\", \"Удалено\"]\n",
|
332 |
-
" for key, value in deleted_files_dict.items():\n",
|
333 |
-
" word_variant = word_variants.get(key, [\"\", \"\", \"\"])\n",
|
334 |
-
" deleted_word = get_word_variant(value, deleted_word_variants)\n",
|
335 |
-
" object_word = get_word_variant(value, word_variant)\n",
|
336 |
-
" messages.append(f\"{deleted_word} {value} {object_word}\")\n",
|
337 |
-
" return messages\n",
|
338 |
-
"# ================ AutoCleaner function ================\n",
|
339 |
-
"\n",
|
340 |
-
"\n",
|
341 |
-
"# --- storage memory ---\n",
|
342 |
-
"import psutil\n",
|
343 |
-
"disk_space = psutil.disk_usage(os.getcwd())\n",
|
344 |
-
"total = disk_space.total / (1024 ** 3)\n",
|
345 |
-
"used = disk_space.used / (1024 ** 3)\n",
|
346 |
-
"free = disk_space.free / (1024 ** 3)\n",
|
347 |
-
"\n",
|
348 |
-
"\n",
|
349 |
-
"# UI Code\n",
|
350 |
-
"AutoCleaner_options = AutoCleaner_options = list(directories.keys())\n",
|
351 |
-
"instruction_label = widgets.HTML('''\n",
|
352 |
-
"<span class=\"instruction_AC\">Используйте <span style=\"color: #B2B2B2;\">ctrl</span> или <span style=\"color: #B2B2B2;\">shift</span> для множественного выбора.</span>\n",
|
353 |
-
"''')\n",
|
354 |
-
"auto_cleaner_widget = widgets.SelectMultiple(options=AutoCleaner_options, layout=widgets.Layout(width=\"auto\")).add_class(\"custom-select-multiple_AC\")\n",
|
355 |
-
"output = widgets.Output().add_class(\"output_AC\")\n",
|
356 |
-
"# ---\n",
|
357 |
-
"execute_button = Button(description='Выполнить Очистку').add_class(\"button_execute_AC\").add_class(\"button_AC\")\n",
|
358 |
-
"execute_button.on_click(on_execute_button_press)\n",
|
359 |
-
"clear_button = Button(description='Скрыть Виджет').add_class(\"button_clear_AC\").add_class(\"button_AC\")\n",
|
360 |
-
"clear_button.on_click(on_clear_button_press)\n",
|
361 |
-
"# ---\n",
|
362 |
-
"storage_info = widgets.HTML(f'''\n",
|
363 |
-
"<div class=\"storage_info_AC\">Всего: {total:.2f} GB <span style=\"color: #555\">|</span> Используется: {used:.2f} GB <span style=\"color: #555\">|</span> Свободно: {free:.2f} GB</div>\n",
|
364 |
-
"''')\n",
|
365 |
-
"# ---\n",
|
366 |
-
"buttons = widgets.HBox([execute_button, clear_button])\n",
|
367 |
-
"lower_information_panel = widgets.HBox([buttons, storage_info]).add_class(\"lower_information_panel_AC\")\n",
|
368 |
-
"\n",
|
369 |
-
"container = VBox([instruction_label, widgets.HTML('<hr>'), auto_cleaner_widget, output, widgets.HTML('<hr>'), lower_information_panel]).add_class(\"container_AC\")\n",
|
370 |
-
"\n",
|
371 |
-
"display(container)"
|
372 |
-
],
|
373 |
-
"metadata": {
|
374 |
-
"id": "I22dFg7F2j3G"
|
375 |
-
},
|
376 |
-
"execution_count": null,
|
377 |
-
"outputs": []
|
378 |
-
}
|
379 |
-
]
|
380 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/notebooks/ru/downloading_ru.ipynb
DELETED
@@ -1,594 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"nbformat": 4,
|
3 |
-
"nbformat_minor": 0,
|
4 |
-
"metadata": {
|
5 |
-
"colab": {
|
6 |
-
"provenance": []
|
7 |
-
},
|
8 |
-
"kernelspec": {
|
9 |
-
"name": "python3",
|
10 |
-
"display_name": "Python 3"
|
11 |
-
},
|
12 |
-
"language_info": {
|
13 |
-
"name": "python"
|
14 |
-
}
|
15 |
-
},
|
16 |
-
"cells": [
|
17 |
-
{
|
18 |
-
"cell_type": "code",
|
19 |
-
"source": [
|
20 |
-
"##~ DOWNLOADING CODE | BY: ANXETY ~##\n",
|
21 |
-
"\n",
|
22 |
-
"import os\n",
|
23 |
-
"import re\n",
|
24 |
-
"import time\n",
|
25 |
-
"import json\n",
|
26 |
-
"import requests\n",
|
27 |
-
"import subprocess\n",
|
28 |
-
"from datetime import timedelta\n",
|
29 |
-
"from subprocess import getoutput\n",
|
30 |
-
"from urllib.parse import unquote\n",
|
31 |
-
"from IPython.utils import capture\n",
|
32 |
-
"from IPython.display import clear_output\n",
|
33 |
-
"\n",
|
34 |
-
"\n",
|
35 |
-
"# ================= DETECT ENV =================\n",
|
36 |
-
"def detect_environment():\n",
|
37 |
-
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
38 |
-
" environments = {\n",
|
39 |
-
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
40 |
-
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
41 |
-
" 'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', \"/home/studio-lab-user/content\")\n",
|
42 |
-
" }\n",
|
43 |
-
"\n",
|
44 |
-
" for env_var, (environment, path) in environments.items():\n",
|
45 |
-
" if env_var in os.environ:\n",
|
46 |
-
" return environment, path, free_plan\n",
|
47 |
-
"\n",
|
48 |
-
"env, root_path, free_plan = detect_environment()\n",
|
49 |
-
"webui_path = f\"{root_path}/sdw\"\n",
|
50 |
-
"# ----------------------------------------------\n",
|
51 |
-
"\n",
|
52 |
-
"\n",
|
53 |
-
"# === ONLY SAGEMAKER ===\n",
|
54 |
-
"if env == \"SageMaker Studio Lab\":\n",
|
55 |
-
" print(\"Обновление зависимостей, может занять некоторое время...\")\n",
|
56 |
-
" !pip install -q --upgrade torchsde\n",
|
57 |
-
" !pip install -q --upgrade pip\n",
|
58 |
-
" !pip install -q --upgrade psutil\n",
|
59 |
-
"\n",
|
60 |
-
" clear_output()\n",
|
61 |
-
"\n",
|
62 |
-
"\n",
|
63 |
-
"# ================ LIBRARIES ================\n",
|
64 |
-
"flag_file = f\"{root_path}/libraries_installed.txt\"\n",
|
65 |
-
"\n",
|
66 |
-
"if not os.path.exists(flag_file):\n",
|
67 |
-
" # automatic1111 update webui to 1.8.0\n",
|
68 |
-
" xformers = \"xformers==0.0.23.post1 triton==2.1.0\"\n",
|
69 |
-
" torch = \"torch==2.1.2+cu121 torchvision==0.16.2+cu121 torchaudio==2.1.2 --extra-index-url https://download.pytorch.org/whl/cu121\"\n",
|
70 |
-
"\n",
|
71 |
-
" print(\"💿 Установка библиотек, это займет какое-то время...\", end='')\n",
|
72 |
-
" with capture.capture_output() as cap:\n",
|
73 |
-
" !pip install -U gdown\n",
|
74 |
-
" !apt-get update && apt -y install aria2\n",
|
75 |
-
" !npm install -g localtunnel &> /dev/null\n",
|
76 |
-
" !curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}\n",
|
77 |
-
" !curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl\n",
|
78 |
-
" !pip install insightface\n",
|
79 |
-
" !curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.23/zrok_0.4.23_linux_amd64.tar.gz && tar -xzf zrok_0.4.23_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.23_linux_amd64.tar.gz\n",
|
80 |
-
"\n",
|
81 |
-
" if env == \"SageMaker Studio Lab\":\n",
|
82 |
-
" %pip install -q opencv-python-headless huggingface-hub\n",
|
83 |
-
" %conda update -q -n base conda\n",
|
84 |
-
" %conda install -q -y aria2\n",
|
85 |
-
" %conda install -q -y glib\n",
|
86 |
-
" !pip install tensorflow\n",
|
87 |
-
"\n",
|
88 |
-
" !wget -P /home/studio-lab-user https://huggingface.co/NagisaNao/fast_repo/resolve/main/sagemaker/FULL_DELETED_NOTEBOOK.ipynb\n",
|
89 |
-
"\n",
|
90 |
-
" if env == \"Google Colab\":\n",
|
91 |
-
" !pip install xformers==0.0.25 --no-deps\n",
|
92 |
-
" else:\n",
|
93 |
-
" !pip install -q {torch} -U\n",
|
94 |
-
" !pip install -q {xformers} -U\n",
|
95 |
-
"\n",
|
96 |
-
" with open(flag_file, \"w\") as f:\n",
|
97 |
-
" f.write(\"hey ;3\")\n",
|
98 |
-
" del cap\n",
|
99 |
-
" print(\"\\r🍪 Библиотеки установлены!\" + \" \"*35)\n",
|
100 |
-
" time.sleep(2)\n",
|
101 |
-
" clear_output()\n",
|
102 |
-
"\n",
|
103 |
-
"\n",
|
104 |
-
"# ================= loading settings V4 =================\n",
|
105 |
-
"def load_settings(path):\n",
|
106 |
-
" if os.path.exists(path):\n",
|
107 |
-
" with open(path, 'r') as file:\n",
|
108 |
-
" return json.load(file)\n",
|
109 |
-
" return {}\n",
|
110 |
-
"\n",
|
111 |
-
"settings = load_settings(f'{root_path}/settings.json')\n",
|
112 |
-
"\n",
|
113 |
-
"variables = [\n",
|
114 |
-
" 'Model', 'Model_Num', 'Inpainting_Model',\n",
|
115 |
-
" 'Vae', 'Vae_Num',\n",
|
116 |
-
" 'latest_webui', 'latest_exstensions', 'detailed_download',\n",
|
117 |
-
" 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',\n",
|
118 |
-
" 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
|
119 |
-
" 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'\n",
|
120 |
-
"]\n",
|
121 |
-
"\n",
|
122 |
-
"locals().update({key: settings.get(key) for key in variables})\n",
|
123 |
-
"\n",
|
124 |
-
"\n",
|
125 |
-
"# ================= OTHER =================\n",
|
126 |
-
"try:\n",
|
127 |
-
" start_colab\n",
|
128 |
-
"except:\n",
|
129 |
-
" start_colab = int(time.time())-5\n",
|
130 |
-
"\n",
|
131 |
-
"# CONFIG DIR\n",
|
132 |
-
"models_dir = f\"{webui_path}/models/Stable-diffusion\"\n",
|
133 |
-
"vaes_dir = f\"{webui_path}/models/VAE\"\n",
|
134 |
-
"embeddings_dir = f\"{webui_path}/embeddings\"\n",
|
135 |
-
"loras_dir = f\"{webui_path}/models/Lora\"\n",
|
136 |
-
"extensions_dir = f\"{webui_path}/extensions\"\n",
|
137 |
-
"control_dir = f\"{webui_path}/models/ControlNet\"\n",
|
138 |
-
"\n",
|
139 |
-
"\n",
|
140 |
-
"# ================= MAIN CODE =================\n",
|
141 |
-
"# --- Obsolescence warning ---\n",
|
142 |
-
"if env == \"SageMaker Studio Lab\":\n",
|
143 |
-
" print(\"Вы используете среду 'SageMaker' - эта среда устарела, поэтому многие ошибки не будут исправлены, а ее функциональность будет урезана. Для экономии памяти и/или во избежание ошибок.\\n\\n\")\n",
|
144 |
-
"\n",
|
145 |
-
"\n",
|
146 |
-
"if not os.path.exists(webui_path):\n",
|
147 |
-
" start_install = int(time.time())\n",
|
148 |
-
" print(\"⌚ Распоковка Stable Diffusion...\", end='')\n",
|
149 |
-
" with capture.capture_output() as cap:\n",
|
150 |
-
" !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip -o repo.zip\n",
|
151 |
-
" !unzip -q -o repo.zip -d {webui_path}\n",
|
152 |
-
" !rm -rf repo.zip\n",
|
153 |
-
"\n",
|
154 |
-
" %cd {root_path}\n",
|
155 |
-
" os.environ[\"SAFETENSORS_FAST_GPU\"]='1'\n",
|
156 |
-
" os.environ[\"CUDA_MODULE_LOADING\"]=\"LAZY\"\n",
|
157 |
-
" os.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"3\"\n",
|
158 |
-
" os.environ[\"PYTHONWARNINGS\"] = \"ignore\"\n",
|
159 |
-
"\n",
|
160 |
-
" !echo -n {start_colab} > {webui_path}/static/colabTimer.txt\n",
|
161 |
-
" del cap\n",
|
162 |
-
" install_time = timedelta(seconds=time.time()-start_install)\n",
|
163 |
-
" print(\"\\r🚀 Распаковка Завершена! За\",\"%02d:%02d:%02d ⚡\\n\" % (install_time.seconds / 3600, (install_time.seconds / 60) % 60, install_time.seconds % 60), end='', flush=True)\n",
|
164 |
-
"else:\n",
|
165 |
-
" if env == \"SageMaker Studio Lab\":\n",
|
166 |
-
" !echo -n {start_colab} > {webui_path}/static/colabTimer.txt\n",
|
167 |
-
" print(\"🚀 Все распакованно... Пропуск. ⚡\")\n",
|
168 |
-
" start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
|
169 |
-
" time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
|
170 |
-
" print(f\"⌚️ Вы проводите эту сессию в течение - \\033[33m{time_since_start}\\033[0m\")\n",
|
171 |
-
"\n",
|
172 |
-
"\n",
|
173 |
-
"## Changes extensions and WebUi\n",
|
174 |
-
"if latest_webui or latest_exstensions:\n",
|
175 |
-
" action = \"Обновление WebUI и Расширений\" if latest_webui and latest_exstensions else (\"Обновление WebUI\" if latest_webui else \"Обновление Расширений\")\n",
|
176 |
-
" print(f\"⌚️ {action}...\", end='', flush=True)\n",
|
177 |
-
" with capture.capture_output() as cap:\n",
|
178 |
-
" !git config --global user.email \"[email protected]\"\n",
|
179 |
-
" !git config --global user.name \"Your Name\"\n",
|
180 |
-
"\n",
|
181 |
-
" ## Update Webui\n",
|
182 |
-
" if latest_webui:\n",
|
183 |
-
" %cd {webui_path}\n",
|
184 |
-
" !git restore .\n",
|
185 |
-
" !git pull -X theirs --rebase --autostash\n",
|
186 |
-
"\n",
|
187 |
-
" ## Update extensions\n",
|
188 |
-
" if latest_exstensions:\n",
|
189 |
-
" if env != \"SageMaker Studio Lab\":\n",
|
190 |
-
" !{'for dir in ' + webui_path + '/extensions/*/; do cd \\\"$dir\\\" && git reset --hard && git pull; done'}\n",
|
191 |
-
" else:\n",
|
192 |
-
" !{'for dir in /home/studio-lab-user/content/sdw/extensions/*/; do cd \\\"$dir\\\" && git fetch origin && git pull; done'}\n",
|
193 |
-
"\n",
|
194 |
-
" # My Chinese friend, you broke the images again in the latest update... >W<'\n",
|
195 |
-
" %cd {webui_path}/extensions/Encrypt-Image\n",
|
196 |
-
" !git reset --hard 376358d8854472b9ea50e9fc8800367d1ca51137 # stable commit :3\n",
|
197 |
-
"\n",
|
198 |
-
" !cd {webui_path}/repositories/stable-diffusion-stability-ai && git restore .\n",
|
199 |
-
" del cap\n",
|
200 |
-
" print(f\"\\r✨ {action} Завершено!\")\n",
|
201 |
-
"\n",
|
202 |
-
"\n",
|
203 |
-
"# === FIXING ERRORS ===\n",
|
204 |
-
"# --- Encrypt-Image ---\n",
|
205 |
-
"!sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js\n",
|
206 |
-
"\n",
|
207 |
-
"# --- SageMaker ---\n",
|
208 |
-
"if env == \"SageMaker Studio Lab\":\n",
|
209 |
-
" with capture.capture_output() as cap:\n",
|
210 |
-
" # --- SuperMerger Remove ---\n",
|
211 |
-
" if os.path.exists(f\"{webui_path}/extensions/supermerger\"):\n",
|
212 |
-
" !rm -rf {webui_path}/extensions/supermerger\n",
|
213 |
-
" # --- Launch (Style) ---\n",
|
214 |
-
" !wget -O {webui_path}/modules/styles.py https://huggingface.co/NagisaNao/fast_repo/resolve/main/sagemaker/fixing/webui/styles.py\n",
|
215 |
-
" del cap\n",
|
216 |
-
"\n",
|
217 |
-
"\n",
|
218 |
-
"## Version switching\n",
|
219 |
-
"if commit_hash:\n",
|
220 |
-
" print('⏳ Активация машины времени...', end=\"\", flush=True)\n",
|
221 |
-
" with capture.capture_output() as cap:\n",
|
222 |
-
" %cd {webui_path}\n",
|
223 |
-
" !git config --global user.email \"[email protected]\"\n",
|
224 |
-
" !git config --global user.name \"Your Name\"\n",
|
225 |
-
" !git reset --hard {commit_hash}\n",
|
226 |
-
" del cap\n",
|
227 |
-
" print(f\"\\r⌛️ Машина времени активированна! Текущий коммит: \\033[34m{commit_hash}\\033[0m\")\n",
|
228 |
-
"\n",
|
229 |
-
"\n",
|
230 |
-
"## Downloading model and stuff | oh yeah~ I'm starting to misunderstand my own code ( almost my own ;3 )\n",
|
231 |
-
"print(\"📦 Скачивание моделей и прочего...\", end='')\n",
|
232 |
-
"model_list = {\n",
|
233 |
-
" \"1.Anime (by XpucT) + INP\": [\n",
|
234 |
-
" {\"url\": \"https://huggingface.co/XpucT/Anime/resolve/main/Anime_v2.safetensors\", \"name\": \"Anime_v2.safetensors\"},\n",
|
235 |
-
" {\"url\": \"https://huggingface.co/XpucT/Anime/resolve/main/Anime_v2-inpainting.safetensors\", \"name\": \"Anime_v2-inpainting.safetensors\"}\n",
|
236 |
-
" ],\n",
|
237 |
-
" \"2.BluMix [Anime] [V7]\": [\n",
|
238 |
-
" {\"url\": \"https://civitai.com/api/download/models/361779\", \"name\": \"BluMix_v7.safetensors\"}\n",
|
239 |
-
" ],\n",
|
240 |
-
" \"3.Cetus-Mix [Anime] [V4] + INP\": [\n",
|
241 |
-
" {\"url\": \"https://civitai.com/api/download/models/130298\", \"name\": \"CetusMix_V4.safetensors\"},\n",
|
242 |
-
" {\"url\": \"https://civitai.com/api/download/models/139882\", \"name\": \"CetusMix_V4-inpainting.safetensors\"}\n",
|
243 |
-
" ],\n",
|
244 |
-
" \"4.Counterfeit [Anime] [V3] + INP\": [\n",
|
245 |
-
" {\"url\": \"https://civitai.com/api/download/models/125050\", \"name\": \"Counterfeit_V3.safetensors\"},\n",
|
246 |
-
" {\"url\": \"https://civitai.com/api/download/models/137911\", \"name\": \"Counterfeit_V3-inpainting.safetensors\"}\n",
|
247 |
-
" ],\n",
|
248 |
-
" \"5.CuteColor [Anime] [V3]\": [\n",
|
249 |
-
" {\"url\": \"https://civitai.com/api/download/models/138754\", \"name\": \"CuteColor_V3.safetensors\"}\n",
|
250 |
-
" ],\n",
|
251 |
-
" \"6.Dark-Sushi-Mix [Anime]\": [\n",
|
252 |
-
" {\"url\": \"https://civitai.com/api/download/models/101640\", \"name\": \"DarkSushiMix_2_5D.safetensors\"},\n",
|
253 |
-
" {\"url\": \"https://civitai.com/api/download/models/56071\", \"name\": \"DarkSushiMix_colorful.safetensors\"}\n",
|
254 |
-
" ],\n",
|
255 |
-
" \"7.Deliberate [Realism] [V6] + INP\": [\n",
|
256 |
-
" {\"url\": \"https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v6.safetensors\", \"name\": \"Deliberate_v6.safetensors\"},\n",
|
257 |
-
" {\"url\": \"https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v6-inpainting.safetensors\", \"name\": \"Deliberate_v6-inpainting.safetensors\"}\n",
|
258 |
-
" ],\n",
|
259 |
-
" \"8.Meina-Mix [Anime] [V11] + INP\": [\n",
|
260 |
-
" {\"url\": \"https://civitai.com/api/download/models/119057\", \"name\": \"MeinaMix_V11.safetensors\"},\n",
|
261 |
-
" {\"url\": \"https://civitai.com/api/download/models/120702\", \"name\": \"MeinaMix_V11-inpainting.safetensors\"}\n",
|
262 |
-
" ],\n",
|
263 |
-
" \"9.Mix-Pro [Anime] [V4] + INP\": [\n",
|
264 |
-
" {\"url\": \"https://civitai.com/api/download/models/125668\", \"name\": \"MixPro_V4.safetensors\"},\n",
|
265 |
-
" {\"url\": \"https://civitai.com/api/download/models/139878\", \"name\": \"MixPro_V4-inpainting.safetensors\"}\n",
|
266 |
-
" ]\n",
|
267 |
-
"}\n",
|
268 |
-
"\n",
|
269 |
-
"# 1-4 (fp16/cleaned)\n",
|
270 |
-
"vae_list = {\n",
|
271 |
-
" \"1.Anime.vae\": [\n",
|
272 |
-
" {\"url\": \"https://civitai.com/api/download/models/131654\", \"name\": \"Anime.vae.safetensors\"},\n",
|
273 |
-
" {\"url\": \"https://civitai.com/api/download/models/131658\", \"name\": \"vae-ft-mse.vae.safetensors\"}\n",
|
274 |
-
" ],\n",
|
275 |
-
" \"2.Anything.vae\": [{\"url\": \"https://civitai.com/api/download/models/131656\", \"name\": \"Anything.vae.safetensors\"}],\n",
|
276 |
-
" \"3.Blessed2.vae\": [{\"url\": \"https://civitai.com/api/download/models/142467\", \"name\": \"Blessed2.vae.safetensors\"}],\n",
|
277 |
-
" \"4.ClearVae.vae\": [{\"url\": \"https://civitai.com/api/download/models/133362\", \"name\": \"ClearVae_23.vae.safetensors\"}],\n",
|
278 |
-
" \"5.WD.vae\": [{\"url\": \"https://huggingface.co/NoCrypt/resources/resolve/main/VAE/wd.vae.safetensors\", \"name\": \"WD.vae.safetensors\"}]\n",
|
279 |
-
"}\n",
|
280 |
-
"\n",
|
281 |
-
"controlnet_list = {\n",
|
282 |
-
" \"1.canny\": [\n",
|
283 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny_fp16.safetensors\", \"name\": \"control_v11p_sd15_canny_fp16.safetensors\"},\n",
|
284 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_canny_fp16.yaml\", \"name\": \"control_v11p_sd15_canny_fp16.yaml\"}\n",
|
285 |
-
" ],\n",
|
286 |
-
" \"2.openpose\": [\n",
|
287 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose_fp16.safetensors\", \"name\": \"control_v11p_sd15_openpose_fp16.safetensors\"},\n",
|
288 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_openpose_fp16.yaml\", \"name\": \"control_v11p_sd15_openpose_fp16.yaml\"}\n",
|
289 |
-
" ],\n",
|
290 |
-
" \"3.depth\": [\n",
|
291 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors\", \"name\": \"control_v11f1p_sd15_depth_fp16.safetensors\"},\n",
|
292 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1p_sd15_depth_fp16.yaml\", \"name\": \"control_v11f1p_sd15_depth_fp16.yaml\"},\n",
|
293 |
-
" {\"url\": \"https://huggingface.co/NagisaNao/models/resolve/main/ControlNet_v11/control_v11p_sd15_depth_anything_fp16.safetensors\", \"name\": \"control_v11p_sd15_depth_anything_fp16.safetensors\"}\n",
|
294 |
-
" ],\n",
|
295 |
-
" \"4.normal_map\": [\n",
|
296 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors\", \"name\": \"control_v11p_sd15_normalbae_fp16.safetensors\"},\n",
|
297 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_normalbae_fp16.yaml\", \"name\": \"control_v11p_sd15_normalbae_fp16.yaml\"}\n",
|
298 |
-
" ],\n",
|
299 |
-
" \"5.mlsd\": [\n",
|
300 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors\", \"name\": \"control_v11p_sd15_mlsd_fp16.safetensors\"},\n",
|
301 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_mlsd_fp16.yaml\", \"name\": \"control_v11p_sd15_mlsd_fp16.yaml\"}\n",
|
302 |
-
" ],\n",
|
303 |
-
" \"6.lineart\": [\n",
|
304 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart_fp16.safetensors\", \"name\": \"control_v11p_sd15_lineart_fp16.safetensors\"},\n",
|
305 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors\", \"name\": \"control_v11p_sd15s2_lineart_anime_fp16.safetensors\"},\n",
|
306 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_lineart_fp16.yaml\", \"name\": \"control_v11p_sd15_lineart_fp16.yaml\"},\n",
|
307 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15s2_lineart_anime_fp16.yaml\", \"name\": \"control_v11p_sd15s2_lineart_anime_fp16.yaml\"}\n",
|
308 |
-
" ],\n",
|
309 |
-
" \"7.soft_edge\": [\n",
|
310 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_softedge_fp16.safetensors\", \"name\": \"control_v11p_sd15_softedge_fp16.safetensors\"},\n",
|
311 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_softedge_fp16.yaml\", \"name\": \"control_v11p_sd15_softedge_fp16.yaml\"}\n",
|
312 |
-
" ],\n",
|
313 |
-
" \"8.scribble\": [\n",
|
314 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_scribble_fp16.safetensors\", \"name\": \"control_v11p_sd15_scribble_fp16.safetensors\"},\n",
|
315 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_scribble_fp16.yaml\", \"name\": \"control_v11p_sd15_scribble_fp16.yaml\"}\n",
|
316 |
-
" ],\n",
|
317 |
-
" \"9.segmentation\": [\n",
|
318 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_seg_fp16.safetensors\", \"name\": \"control_v11p_sd15_seg_fp16.safetensors\"},\n",
|
319 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_seg_fp16.yaml\", \"name\": \"control_v11p_sd15_seg_fp16.yaml\"}\n",
|
320 |
-
" ],\n",
|
321 |
-
" \"10.shuffle\": [\n",
|
322 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors\", \"name\": \"control_v11e_sd15_shuffle_fp16.safetensors\"},\n",
|
323 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_shuffle_fp16.yaml\", \"name\": \"control_v11e_sd15_shuffle_fp16.yaml\"}\n",
|
324 |
-
" ],\n",
|
325 |
-
" \"11.tile\": [\n",
|
326 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1e_sd15_tile_fp16.safetensors\", \"name\": \"control_v11f1e_sd15_tile_fp16.safetensors\"},\n",
|
327 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1e_sd15_tile_fp16.yaml\", \"name\": \"control_v11f1e_sd15_tile_fp16.yaml\"}\n",
|
328 |
-
" ],\n",
|
329 |
-
" \"12.inpaint\": [\n",
|
330 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors\", \"name\": \"control_v11p_sd15_inpaint_fp16.safetensors\"},\n",
|
331 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_inpaint_fp16.yaml\", \"name\": \"control_v11p_sd15_inpaint_fp16.yaml\"}\n",
|
332 |
-
" ],\n",
|
333 |
-
" \"13.instruct_p2p\": [\n",
|
334 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors\", \"name\": \"control_v11e_sd15_ip2p_fp16.safetensors\"},\n",
|
335 |
-
" {\"url\": \"https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_ip2p_fp16.yaml\", \"name\": \"control_v11e_sd15_ip2p_fp16.yaml\"}\n",
|
336 |
-
" ]\n",
|
337 |
-
"}\n",
|
338 |
-
"\n",
|
339 |
-
"extension_repo = []\n",
|
340 |
-
"prefixes = {\n",
|
341 |
-
" # It's complicated, but supplementing has become easier\n",
|
342 |
-
" \"model\": [models_dir, \"Model_url\"],\n",
|
343 |
-
" \"vae\": [vaes_dir, \"Vae_url\"],\n",
|
344 |
-
" \"lora\": [loras_dir, \"LoRA_url\"],\n",
|
345 |
-
" \"embed\": [embeddings_dir, \"Embedding_url\"],\n",
|
346 |
-
" \"extension\": [extensions_dir, \"Extensions_url\"],\n",
|
347 |
-
" \"control\": [control_dir, \"ControlNet_url\"]\n",
|
348 |
-
"}\n",
|
349 |
-
"\n",
|
350 |
-
"!mkdir -p {models_dir} {vaes_dir} {loras_dir} {embeddings_dir} {extensions_dir} {control_dir}\n",
|
351 |
-
"\n",
|
352 |
-
"url = \"\"\n",
|
353 |
-
"ControlNet_url = \"\"\n",
|
354 |
-
"hf_token = optional_huggingface_token if optional_huggingface_token else \"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\"\n",
|
355 |
-
"user_header = f\"\\\"Authorization: Bearer {hf_token}\\\"\"\n",
|
356 |
-
"\n",
|
357 |
-
"''' main download code '''\n",
|
358 |
-
"\n",
|
359 |
-
"def handle_manual(url):\n",
|
360 |
-
" original_url = url\n",
|
361 |
-
" url = url.split(':', 1)[1]\n",
|
362 |
-
" file_name = re.search(r'\\[(.*?)\\]', url)\n",
|
363 |
-
" file_name = file_name.group(1) if file_name else None\n",
|
364 |
-
" if file_name:\n",
|
365 |
-
" url = re.sub(r'\\[.*?\\]', '', url)\n",
|
366 |
-
"\n",
|
367 |
-
" for prefix, (dir, _) in prefixes.items():\n",
|
368 |
-
" if original_url.startswith(f\"{prefix}:\"):\n",
|
369 |
-
" if prefix != \"extension\":\n",
|
370 |
-
" manual_download(url, dir, file_name=file_name)\n",
|
371 |
-
" else:\n",
|
372 |
-
" extension_repo.append((url, file_name))\n",
|
373 |
-
"\n",
|
374 |
-
"def manual_download(url, dst_dir, file_name):\n",
|
375 |
-
" basename = url.split(\"/\")[-1] if file_name is None else file_name\n",
|
376 |
-
" header_option = f\"--header={user_header}\"\n",
|
377 |
-
"\n",
|
378 |
-
" print(\"\\033[32m---\"*45 + f\"\\n\\033[33mURL: \\033[34m{url}\\n\\033[33mSAVE DIR: \\033[34m{dst_dir}\\n\\033[33mFILE NAME: \\033[34m{file_name}\\033[32m\\n~~~\\033[0m\")\n",
|
379 |
-
"\n",
|
380 |
-
" # I do it at my own risk..... Fucking CivitAi >:(\n",
|
381 |
-
" civitai_token = \"62c0c5956b2f9defbd844d754000180b\"\n",
|
382 |
-
" if 'civitai' in url and civitai_token:\n",
|
383 |
-
" url = f\"{url}?token={civitai_token}\"\n",
|
384 |
-
"\n",
|
385 |
-
" # -- GDrive --\n",
|
386 |
-
" if 'drive.google' in url:\n",
|
387 |
-
" if 'folders' in url:\n",
|
388 |
-
" !gdown --folder \"{url}\" -O {dst_dir} --fuzzy -c\n",
|
389 |
-
" else:\n",
|
390 |
-
" if file_name:\n",
|
391 |
-
" !gdown \"{url}\" -O {dst_dir}/{file_name} --fuzzy -c\n",
|
392 |
-
" else:\n",
|
393 |
-
" !gdown \"{url}\" -O {dst_dir} --fuzzy -c\n",
|
394 |
-
" # -- Huggin Face --\n",
|
395 |
-
" elif 'huggingface' in url:\n",
|
396 |
-
" if '/blob/' in url:\n",
|
397 |
-
" url = url.replace('/blob/', '/resolve/')\n",
|
398 |
-
" if file_name:\n",
|
399 |
-
" !aria2c {header_option} --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -c -j5 -x16 -s16 -k1M -d {dst_dir} -o {basename} {url}\n",
|
400 |
-
" else:\n",
|
401 |
-
" parsed_link = f'\\n{url}\\n\\tout={unquote(url.split(\"/\")[-1])}'\n",
|
402 |
-
" !echo -e \"{parsed_link}\" | aria2c {header_option} --console-log-level=error --summary-interval=10 -i- -j5 -x16 -s16 -k1M -c -d \"{dst_dir}\" -o {basename}\n",
|
403 |
-
" # -- Other --\n",
|
404 |
-
" elif 'http' in url or 'magnet' in url:\n",
|
405 |
-
" if file_name:\n",
|
406 |
-
" !aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -o {file_name} {url}\n",
|
407 |
-
" else:\n",
|
408 |
-
" parsed_link = '\"{}\"'.format(url)\n",
|
409 |
-
" !aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -Z {parsed_link}\n",
|
410 |
-
"\n",
|
411 |
-
"def download(url):\n",
|
412 |
-
" links_and_paths = url.split(',')\n",
|
413 |
-
"\n",
|
414 |
-
" for link_or_path in links_and_paths:\n",
|
415 |
-
" link_or_path = link_or_path.strip()\n",
|
416 |
-
" if not link_or_path:\n",
|
417 |
-
" continue\n",
|
418 |
-
" if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):\n",
|
419 |
-
" handle_manual(link_or_path)\n",
|
420 |
-
" continue\n",
|
421 |
-
"\n",
|
422 |
-
" url, dst_dir, file_name = link_or_path.split()\n",
|
423 |
-
" manual_download(url, dst_dir, file_name)\n",
|
424 |
-
"\n",
|
425 |
-
"''' submodels - added urls '''\n",
|
426 |
-
"\n",
|
427 |
-
"submodels = []\n",
|
428 |
-
"\n",
|
429 |
-
"def add_submodels(selection, num_selection, model_dict, dst_dir):\n",
|
430 |
-
" if selection == \"none\":\n",
|
431 |
-
" return []\n",
|
432 |
-
" if selection == \"ALL\":\n",
|
433 |
-
" all_models = []\n",
|
434 |
-
" for models in model_dict.values():\n",
|
435 |
-
" all_models.extend(models)\n",
|
436 |
-
" selected_models = all_models\n",
|
437 |
-
" else:\n",
|
438 |
-
" selected_models = model_dict[selection]\n",
|
439 |
-
" selected_nums = map(int, num_selection.replace(',', '').split())\n",
|
440 |
-
"\n",
|
441 |
-
" for num in selected_nums:\n",
|
442 |
-
" if 1 <= num <= len(model_dict):\n",
|
443 |
-
" name = list(model_dict)[num - 1]\n",
|
444 |
-
" selected_models.extend(model_dict[name])\n",
|
445 |
-
"\n",
|
446 |
-
" unique_models = list({model['name']: model for model in selected_models}.values())\n",
|
447 |
-
"\n",
|
448 |
-
" for model in unique_models:\n",
|
449 |
-
" model['dst_dir'] = dst_dir\n",
|
450 |
-
"\n",
|
451 |
-
" return unique_models\n",
|
452 |
-
"\n",
|
453 |
-
"submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model\n",
|
454 |
-
"submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae\n",
|
455 |
-
"submodels += add_submodels(controlnet, \"\" if controlnet == \"ALL\" else controlnet_Num, controlnet_list, control_dir) # controlnet\n",
|
456 |
-
"\n",
|
457 |
-
"for submodel in submodels:\n",
|
458 |
-
" if not Inpainting_Model and \"inpainting\" in submodel['name']:\n",
|
459 |
-
" continue\n",
|
460 |
-
" url += f\"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, \"\n",
|
461 |
-
"\n",
|
462 |
-
"''' file.txt - added urls '''\n",
|
463 |
-
"\n",
|
464 |
-
"unique_urls = []\n",
|
465 |
-
"\n",
|
466 |
-
"def process_file_download(file_url):\n",
|
467 |
-
" if file_url.startswith(\"http\"):\n",
|
468 |
-
" if \"blob\" in file_url:\n",
|
469 |
-
" file_url = file_url.replace(\"blob\", \"raw\")\n",
|
470 |
-
" response = requests.get(file_url)\n",
|
471 |
-
" lines = response.text.split('\\n')\n",
|
472 |
-
" else:\n",
|
473 |
-
" with open(file_url, 'r') as file:\n",
|
474 |
-
" lines = file.readlines()\n",
|
475 |
-
"\n",
|
476 |
-
" current_tag = None\n",
|
477 |
-
" for line in lines:\n",
|
478 |
-
" if any(f'# {tag}' in line.lower() for tag in prefixes):\n",
|
479 |
-
" current_tag = next((tag for tag in prefixes if tag in line.lower()))\n",
|
480 |
-
"\n",
|
481 |
-
" urls = [url.strip() for url in line.split(',')]\n",
|
482 |
-
" for url in urls:\n",
|
483 |
-
" if url.startswith(\"http\") and url not in unique_urls:\n",
|
484 |
-
" globals()[prefixes[current_tag][1]] += \", \" + url\n",
|
485 |
-
" unique_urls.append(url)\n",
|
486 |
-
"\n",
|
487 |
-
"# fix all possible errors/options and function call\n",
|
488 |
-
"if custom_file_urls:\n",
|
489 |
-
" for custom_file_url in custom_file_urls.replace(',', '').split():\n",
|
490 |
-
" if not custom_file_url.endswith('.txt'):\n",
|
491 |
-
" custom_file_url += '.txt'\n",
|
492 |
-
" if not custom_file_url.startswith('http'):\n",
|
493 |
-
" if not custom_file_url.startswith(root_path):\n",
|
494 |
-
" custom_file_url = f'{root_path}/{custom_file_url}'\n",
|
495 |
-
"\n",
|
496 |
-
" try:\n",
|
497 |
-
" process_file_download(custom_file_url)\n",
|
498 |
-
" except FileNotFoundError:\n",
|
499 |
-
" pass\n",
|
500 |
-
"\n",
|
501 |
-
"# url prefixing\n",
|
502 |
-
"urls = [globals()[urls[1]] for urls in prefixes.values()]\n",
|
503 |
-
"for i, prefix in enumerate(prefixes):\n",
|
504 |
-
" if urls[i]:\n",
|
505 |
-
" prefixed_urls = [f\"{prefix}:{url}\" for url in urls[i].replace(',', '').split()]\n",
|
506 |
-
" if prefixed_urls:\n",
|
507 |
-
" url += \", \".join(prefixed_urls) + \", \"\n",
|
508 |
-
"\n",
|
509 |
-
"if detailed_download == \"on\":\n",
|
510 |
-
" print(\"\\n\\n\\033[33m# ====== Подробная Загрузка ====== #\\n\\033[0m\")\n",
|
511 |
-
" download(url)\n",
|
512 |
-
" print(\"\\n\\033[33m# =============================== #\\n\\033[0m\")\n",
|
513 |
-
"else:\n",
|
514 |
-
" with capture.capture_output() as cap:\n",
|
515 |
-
" download(url)\n",
|
516 |
-
" del cap\n",
|
517 |
-
"\n",
|
518 |
-
"print(\"\\r🏁 Скачивание Завершено!\" + \" \"*15)\n",
|
519 |
-
"\n",
|
520 |
-
"\n",
|
521 |
-
"# Cleaning shit after downloading...\n",
|
522 |
-
"!find {webui_path} \\( -type d \\( -name \".ipynb_checkpoints\" -o -name \".aria2\" \\) -o -type f -name \"*.aria2\" \\) -exec rm -r {{}} \\; >/dev/null 2>&1\n",
|
523 |
-
"\n",
|
524 |
-
"\n",
|
525 |
-
"## Install of Custom extensions\n",
|
526 |
-
"if len(extension_repo) > 0:\n",
|
527 |
-
" print(\"✨ Устанвока кастомных расширений...\", end='', flush=True)\n",
|
528 |
-
" with capture.capture_output() as cap:\n",
|
529 |
-
" for repo, repo_name in extension_repo:\n",
|
530 |
-
" if not repo_name:\n",
|
531 |
-
" repo_name = repo.split('/')[-1]\n",
|
532 |
-
" !cd {extensions_dir} \\\n",
|
533 |
-
" && git clone {repo} {repo_name} \\\n",
|
534 |
-
" && cd {repo_name} \\\n",
|
535 |
-
" && git fetch\n",
|
536 |
-
" del cap\n",
|
537 |
-
" print(f\"\\r📦 Установлено '{len(extension_repo)}', Кастомных расширений!\")\n",
|
538 |
-
"\n",
|
539 |
-
"\n",
|
540 |
-
"## List Models and stuff\n",
|
541 |
-
"if detailed_download == \"off\":\n",
|
542 |
-
" print(\"\\n\\n\\033[33mЕсли вы не видете каких-то скаченных файлов, включите в виджетах функцию 'Подробная Загрузка'.\")\n",
|
543 |
-
"\n",
|
544 |
-
"if any(not file.endswith('.txt') for file in os.listdir(models_dir)):\n",
|
545 |
-
" print(\"\\n\\033[33m➤ Models\\033[0m\")\n",
|
546 |
-
" !find {models_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'\n",
|
547 |
-
"if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):\n",
|
548 |
-
" print(\"\\n\\033[33m➤ VAEs\\033[0m\")\n",
|
549 |
-
" !find {vaes_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'\n",
|
550 |
-
"if any(not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file)) for file in os.listdir(embeddings_dir)):\n",
|
551 |
-
" print(\"\\n\\033[33m➤ Embeddings\\033[0m\")\n",
|
552 |
-
" !find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'\n",
|
553 |
-
"if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):\n",
|
554 |
-
" print(\"\\n\\033[33m➤ LoRAs\\033[0m\")\n",
|
555 |
-
" !find {loras_dir}/ -mindepth 1 ! -name '*.keep' -printf '%f\\n'\n",
|
556 |
-
"print(f\"\\n\\033[33m➤ Extensions\\033[0m\")\n",
|
557 |
-
"!find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'\n",
|
558 |
-
"if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):\n",
|
559 |
-
" print(\"\\n\\033[33m➤ ControlNet\\033[0m\")\n",
|
560 |
-
" !find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\(.*\\)_fp16\\.safetensors$/\\1/'\n",
|
561 |
-
"\n",
|
562 |
-
"\n",
|
563 |
-
"# === OTHER ===\n",
|
564 |
-
"# Downlaod discord tags UmiWildcards\n",
|
565 |
-
"files_umi = [\n",
|
566 |
-
" \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/200_pan_gen.txt\",\n",
|
567 |
-
" \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/150_bra_gen.txt\"\n",
|
568 |
-
"]\n",
|
569 |
-
"save_dir_path = f\"{webui_path}/extensions/Umi-AI-Wildcards/wildcards/discord\"\n",
|
570 |
-
"\n",
|
571 |
-
"with capture.capture_output() as cap:\n",
|
572 |
-
" for file in files_umi:\n",
|
573 |
-
" !aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {save_dir_path} {file}\n",
|
574 |
-
"del cap\n",
|
575 |
-
"\n",
|
576 |
-
"\n",
|
577 |
-
"# === ONLY SAGEMAKER ===\n",
|
578 |
-
"if env == \"SageMaker Studio Lab\":\n",
|
579 |
-
" with capture.capture_output() as cap:\n",
|
580 |
-
" !rm -rf /home/studio-lab-user/.conda/envs/studiolab-safemode\n",
|
581 |
-
" !rm -rf /home/studio-lab-user/.conda/envs/sagemaker-distribution\n",
|
582 |
-
" !rm -rf /home/studio-lab-user/.conda/pkgs/cache\n",
|
583 |
-
" !pip cache purge\n",
|
584 |
-
" !rm -rf ~/.cache\n",
|
585 |
-
" del cap"
|
586 |
-
],
|
587 |
-
"metadata": {
|
588 |
-
"id": "2lJmbqrs3Mu8"
|
589 |
-
},
|
590 |
-
"execution_count": null,
|
591 |
-
"outputs": []
|
592 |
-
}
|
593 |
-
]
|
594 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/notebooks/ru/launch_ru.ipynb
DELETED
@@ -1,134 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"nbformat": 4,
|
3 |
-
"nbformat_minor": 0,
|
4 |
-
"metadata": {
|
5 |
-
"colab": {
|
6 |
-
"provenance": []
|
7 |
-
},
|
8 |
-
"kernelspec": {
|
9 |
-
"name": "python3",
|
10 |
-
"display_name": "Python 3"
|
11 |
-
},
|
12 |
-
"language_info": {
|
13 |
-
"name": "python"
|
14 |
-
}
|
15 |
-
},
|
16 |
-
"cells": [
|
17 |
-
{
|
18 |
-
"cell_type": "code",
|
19 |
-
"execution_count": null,
|
20 |
-
"metadata": {
|
21 |
-
"id": "JKTCrY9LU7Oq"
|
22 |
-
},
|
23 |
-
"outputs": [],
|
24 |
-
"source": [
|
25 |
-
"##~ LAUNCH CODE | BY: ANXETY ~##\n",
|
26 |
-
"\n",
|
27 |
-
"import os\n",
|
28 |
-
"import re\n",
|
29 |
-
"import time\n",
|
30 |
-
"import json\n",
|
31 |
-
"import requests\n",
|
32 |
-
"from datetime import timedelta\n",
|
33 |
-
"\n",
|
34 |
-
"\n",
|
35 |
-
"# ================= DETECT ENV =================\n",
|
36 |
-
"def detect_environment():\n",
|
37 |
-
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
38 |
-
" environments = {\n",
|
39 |
-
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
40 |
-
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
41 |
-
" 'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', \"/home/studio-lab-user/content\")\n",
|
42 |
-
" }\n",
|
43 |
-
"\n",
|
44 |
-
" for env_var, (environment, path) in environments.items():\n",
|
45 |
-
" if env_var in os.environ:\n",
|
46 |
-
" return environment, path, free_plan\n",
|
47 |
-
"\n",
|
48 |
-
"env, root_path, free_plan = detect_environment()\n",
|
49 |
-
"webui_path = f\"{root_path}/sdw\"\n",
|
50 |
-
"# ----------------------------------------------\n",
|
51 |
-
"\n",
|
52 |
-
"def load_settings():\n",
|
53 |
-
" SETTINGS_FILE = f'{root_path}/settings.json'\n",
|
54 |
-
" if os.path.exists(SETTINGS_FILE):\n",
|
55 |
-
" with open(SETTINGS_FILE, 'r') as f:\n",
|
56 |
-
" settings = json.load(f)\n",
|
57 |
-
" return settings\n",
|
58 |
-
"\n",
|
59 |
-
"settings = load_settings()\n",
|
60 |
-
"ngrok_token = settings['ngrok_token']\n",
|
61 |
-
"zrok_token = settings['zrok_token']\n",
|
62 |
-
"commandline_arguments = settings['commandline_arguments']\n",
|
63 |
-
"\n",
|
64 |
-
"\n",
|
65 |
-
"# ======================== TUNNEL ========================\n",
|
66 |
-
"if env != \"SageMaker Studio Lab\":\n",
|
67 |
-
" import cloudpickle as pickle\n",
|
68 |
-
"\n",
|
69 |
-
" def get_public_ip(version='ipv4'):\n",
|
70 |
-
" try:\n",
|
71 |
-
" url = f'https://api64.ipify.org?format=json&{version}=true'\n",
|
72 |
-
" response = requests.get(url)\n",
|
73 |
-
" data = response.json()\n",
|
74 |
-
" public_ip = data['ip']\n",
|
75 |
-
" return public_ip\n",
|
76 |
-
" except Exception as e:\n",
|
77 |
-
" print(f\"Error getting public {version} address:\", e)\n",
|
78 |
-
"\n",
|
79 |
-
" public_ipv4 = get_public_ip(version='ipv4')\n",
|
80 |
-
"\n",
|
81 |
-
" tunnel_class = pickle.load(open(f\"{root_path}/new_tunnel\", \"rb\"), encoding=\"utf-8\")\n",
|
82 |
-
" tunnel_port= 1769\n",
|
83 |
-
" tunnel = tunnel_class(tunnel_port)\n",
|
84 |
-
" tunnel.add_tunnel(command=\"cl tunnel --url localhost:{port}\", name=\"cl\", pattern=re.compile(r\"[\\w-]+\\.trycloudflare\\.com\"))\n",
|
85 |
-
" tunnel.add_tunnel(command=\"lt --port {port}\", name=\"lt\", pattern=re.compile(r\"[\\w-]+\\.loca\\.lt\"), note=\"Password : \" + \"\\033[32m\" + public_ipv4 + \"\\033[0m\" + \" rerun cell if 404 error.\")\n",
|
86 |
-
"\n",
|
87 |
-
" ''' add zrok tunnel '''\n",
|
88 |
-
" if zrok_token:\n",
|
89 |
-
" get_ipython().system('zrok enable {zrok_token} &> /dev/null')\n",
|
90 |
-
" tunnel.add_tunnel(command=\"zrok share public http://localhost:{port}/ --headless\", name=\"zrok\", pattern=re.compile(r\"[\\w-]+\\.share\\.zrok\\.io\"))\n",
|
91 |
-
"# ======================== TUNNEL ========================\n",
|
92 |
-
"\n",
|
93 |
-
"\n",
|
94 |
-
"# automatic fixing path V2\n",
|
95 |
-
"!sed -i 's#\"tagger_hf_cache_dir\": \".*models/interrogators\"#\"tagger_hf_cache_dir\": \"{root_path}/sdw/models/interrogators\"#' {webui_path}/config.json\n",
|
96 |
-
"!sed -i 's#\"additional_networks_extra_lora_path\": \".*models/Lora/\"#\"additional_networks_extra_lora_path\": \"{root_path}/sdw/models/Lora/\"#' {webui_path}/config.json\n",
|
97 |
-
"# ---\n",
|
98 |
-
"!sed -i 's/\"sd_checkpoint_hash\": \".*\"/\"sd_checkpoint_hash\": \"\"/g; s/\"sd_model_checkpoint\": \".*\"/\"sd_model_checkpoint\": \"\"/g; s/\"sd_vae\": \".*\"/\"sd_vae\": \"None\"/g' {webui_path}/config.json\n",
|
99 |
-
"\n",
|
100 |
-
"\n",
|
101 |
-
"if env != \"SageMaker Studio Lab\":\n",
|
102 |
-
" with tunnel:\n",
|
103 |
-
" %cd {webui_path}\n",
|
104 |
-
" commandline_arguments += f\" --port=1769\"\n",
|
105 |
-
"\n",
|
106 |
-
" if ngrok_token:\n",
|
107 |
-
" commandline_arguments += ' --ngrok ' + ngrok_token\n",
|
108 |
-
" if env != \"Google Colab\":\n",
|
109 |
-
" commandline_arguments += f\" --encrypt-pass=1769\"\n",
|
110 |
-
"\n",
|
111 |
-
" !COMMANDLINE_ARGS=\"{commandline_arguments}\" python launch.py\n",
|
112 |
-
"\n",
|
113 |
-
" start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
|
114 |
-
" time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
|
115 |
-
" print(f\"\\n⌚️ \\033[0mВы проводите эту сессию в течение - \\033[33m{time_since_start}\\033[0m\\n\\n\")\n",
|
116 |
-
"\n",
|
117 |
-
"else:\n",
|
118 |
-
" if ngrok_token:\n",
|
119 |
-
" %cd {webui_path}\n",
|
120 |
-
"\n",
|
121 |
-
" commandline_arguments += ' --ngrok ' + ngrok_token\n",
|
122 |
-
"\n",
|
123 |
-
" !COMMANDLINE_ARGS=\"{commandline_arguments}\" python launch.py\n",
|
124 |
-
"\n",
|
125 |
-
" start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())\n",
|
126 |
-
" time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]\n",
|
127 |
-
" print(f\"\\n⌚️ \\033[0mВы проводите эту сессию в течение - \\033[33m{time_since_start}\\033[0m\\n\\n\")\n",
|
128 |
-
"\n",
|
129 |
-
" else:\n",
|
130 |
-
" print(\"Упс... Я думаю, вы забыли вставить токен `ngrok`..... вернитесь к виджетам и вставьте его, чтобы запустить webui... без него никак :/\\nВы можете получить токен здесь:\\n\\nhttps://dashboard.ngrok.com/get-started/your-authtoken\")"
|
131 |
-
]
|
132 |
-
}
|
133 |
-
]
|
134 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/notebooks/ru/widgets_ru.ipynb
DELETED
@@ -1,619 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"nbformat": 4,
|
3 |
-
"nbformat_minor": 0,
|
4 |
-
"metadata": {
|
5 |
-
"colab": {
|
6 |
-
"provenance": []
|
7 |
-
},
|
8 |
-
"kernelspec": {
|
9 |
-
"name": "python3",
|
10 |
-
"display_name": "Python 3"
|
11 |
-
},
|
12 |
-
"language_info": {
|
13 |
-
"name": "python"
|
14 |
-
}
|
15 |
-
},
|
16 |
-
"cells": [
|
17 |
-
{
|
18 |
-
"cell_type": "code",
|
19 |
-
"source": [
|
20 |
-
"##~ WIDGET CODE | BY: ANXETY ~##\n",
|
21 |
-
"\n",
|
22 |
-
"import os\n",
|
23 |
-
"import json\n",
|
24 |
-
"import time\n",
|
25 |
-
"import ipywidgets as widgets\n",
|
26 |
-
"from ipywidgets import widgets, Layout, Label, Button, VBox, HBox\n",
|
27 |
-
"from IPython.display import display, HTML, Javascript, clear_output\n",
|
28 |
-
"\n",
|
29 |
-
"\n",
|
30 |
-
"# ================= DETECT ENV =================\n",
|
31 |
-
"def detect_environment():\n",
|
32 |
-
" free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)\n",
|
33 |
-
" environments = {\n",
|
34 |
-
" 'COLAB_GPU': ('Google Colab', \"/root\" if free_plan else \"/content\"),\n",
|
35 |
-
" 'KAGGLE_URL_BASE': ('Kaggle', \"/kaggle/working/content\"),\n",
|
36 |
-
" 'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', \"/home/studio-lab-user/content\")\n",
|
37 |
-
" }\n",
|
38 |
-
"\n",
|
39 |
-
" for env_var, (environment, path) in environments.items():\n",
|
40 |
-
" if env_var in os.environ:\n",
|
41 |
-
" return environment, path, free_plan\n",
|
42 |
-
"\n",
|
43 |
-
"env, root_path, free_plan = detect_environment()\n",
|
44 |
-
"webui_path = f\"{root_path}/sdw\"\n",
|
45 |
-
"\n",
|
46 |
-
"!mkdir -p {root_path}\n",
|
47 |
-
"# ----------------------------------------------\n",
|
48 |
-
"\n",
|
49 |
-
"\n",
|
50 |
-
"# ==================== CSS JS ====================\n",
|
51 |
-
"# custom background images (test)\n",
|
52 |
-
"import argparse\n",
|
53 |
-
"parser = argparse.ArgumentParser(description='This script processes an background image.')\n",
|
54 |
-
"parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')\n",
|
55 |
-
"parser.add_argument('-o', '--opacity', type=float, help='Opacity level for the image, between 0 and 1', metavar='', default=0.3)\n",
|
56 |
-
"parser.add_argument('-b', '--blur', type=str, help='Blur level for the image', metavar='', default=0)\n",
|
57 |
-
"parser.add_argument('-y', type=int, help='Y coordinate for the image in px', metavar='', default=0)\n",
|
58 |
-
"parser.add_argument('-x', type=int, help='X coordinate for the image in px', metavar='', default=0)\n",
|
59 |
-
"parser.add_argument('-s', '--scale', type=int, help='Scale image in %%', metavar='', default=100)\n",
|
60 |
-
"parser.add_argument('-m', '--mode', type=str, help='Specify \"no-repeat\" so that the image pattern is not repeated.', metavar='', default='repeat')\n",
|
61 |
-
"parser.add_argument('-t', '--transparent', action='store_true', help='Flag to exclude z-index from CSS. Makes fields transparent')\n",
|
62 |
-
"args = parser.parse_args()\n",
|
63 |
-
"# ---\n",
|
64 |
-
"url_img, opacity_img, blur_img, y_img, x_img, scale_img, mode_img = args.image, args.opacity, args.blur, args.y, args.x, args.scale, args.mode\n",
|
65 |
-
"\n",
|
66 |
-
"# WTF COLAB - WHAT THE FUCK IS THE DIFFERENCE OF 40 PIXELS!?!?!?\n",
|
67 |
-
"fix_heigh_img = \"-780px\"\n",
|
68 |
-
"if env == \"Google Colab\": # betrayal..\n",
|
69 |
-
" fix_heigh_img = \"-740px\"\n",
|
70 |
-
"\n",
|
71 |
-
"container_background = f'''\n",
|
72 |
-
"<style>\n",
|
73 |
-
":root {{\n",
|
74 |
-
" --img_background: url({url_img});\n",
|
75 |
-
" --img_opacity: {opacity_img};\n",
|
76 |
-
" --img_blur: {blur_img}px;\n",
|
77 |
-
" --image_y: {y_img}px;\n",
|
78 |
-
" --image_x: {x_img}px;\n",
|
79 |
-
" --img_scale: {scale_img}%;\n",
|
80 |
-
" --img_mode: {mode_img};\n",
|
81 |
-
" --img_height_dif: {fix_heigh_img}\n",
|
82 |
-
"}}\n",
|
83 |
-
"\n",
|
84 |
-
".widget-dropdown select,\n",
|
85 |
-
".widget-text input[type=\"text\"] {{\n",
|
86 |
-
" height: 30px;\n",
|
87 |
-
" background-color: #1c1c1c;\n",
|
88 |
-
" border: 1px solid #262626;\n",
|
89 |
-
" border-radius: 10px;\n",
|
90 |
-
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
91 |
-
" transition: all 0.3s ease-in-out;\n",
|
92 |
-
"'''\n",
|
93 |
-
"\n",
|
94 |
-
"if not args.transparent:\n",
|
95 |
-
" container_background += \" z-index: 1;\\n</style>\\n\"\n",
|
96 |
-
"\n",
|
97 |
-
"display(HTML(container_background))\n",
|
98 |
-
"# ---\n",
|
99 |
-
"\n",
|
100 |
-
"CSS = '''\n",
|
101 |
-
"<style>\n",
|
102 |
-
"/* General Styles */\n",
|
103 |
-
".header {\n",
|
104 |
-
" font-family: cursive;\n",
|
105 |
-
" font-size: 20px;\n",
|
106 |
-
" font-weight: bold;\n",
|
107 |
-
" color: #ff8cee;\n",
|
108 |
-
" margin-bottom: 15px;\n",
|
109 |
-
" user-select: none;\n",
|
110 |
-
" cursor: default;\n",
|
111 |
-
" display: inline-block;\n",
|
112 |
-
"}\n",
|
113 |
-
"\n",
|
114 |
-
"hr {\n",
|
115 |
-
" border-color: grey;\n",
|
116 |
-
" background-color: grey;\n",
|
117 |
-
" opacity: 0.25;\n",
|
118 |
-
"}\n",
|
119 |
-
"\n",
|
120 |
-
"a {\n",
|
121 |
-
" text-decoration: none;\n",
|
122 |
-
" color: inherit;\n",
|
123 |
-
"}\n",
|
124 |
-
"\n",
|
125 |
-
"\n",
|
126 |
-
"/* Container style */\n",
|
127 |
-
"\n",
|
128 |
-
".container {\n",
|
129 |
-
" position: relative;\n",
|
130 |
-
" background-color: #232323;\n",
|
131 |
-
" width: 1080px;\n",
|
132 |
-
" padding: 10px 15px;\n",
|
133 |
-
" border-radius: 15px;\n",
|
134 |
-
" box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);\n",
|
135 |
-
" margin-bottom: 5px;\n",
|
136 |
-
" overflow: hidden;\n",
|
137 |
-
"}\n",
|
138 |
-
"\n",
|
139 |
-
".container::after {\n",
|
140 |
-
" position: absolute;\n",
|
141 |
-
" top: 5px;\n",
|
142 |
-
" right: 10px;\n",
|
143 |
-
" content: \"ANXETY\";\n",
|
144 |
-
" font-weight: bold;\n",
|
145 |
-
" font-size: 24px;\n",
|
146 |
-
" color: rgba(0, 0, 0, 0.2);\n",
|
147 |
-
"}\n",
|
148 |
-
"\n",
|
149 |
-
"/* background img */\n",
|
150 |
-
".container::before {\n",
|
151 |
-
" content: \"\";\n",
|
152 |
-
" position: absolute;\n",
|
153 |
-
" top: 0;\n",
|
154 |
-
" left: 0;\n",
|
155 |
-
" right: 0;\n",
|
156 |
-
" bottom: 0;\n",
|
157 |
-
" background-image: var(--img_background);\n",
|
158 |
-
" background-size: var(--img_scale);\n",
|
159 |
-
" background-repeat: var(--img_mode);\n",
|
160 |
-
" opacity: var(--img_opacity);\n",
|
161 |
-
" mix-blend-mode: screen;\n",
|
162 |
-
" pointer-events: none;\n",
|
163 |
-
" filter: blur(var(--img_blur));\n",
|
164 |
-
"}\n",
|
165 |
-
"\n",
|
166 |
-
".image_1::before {\n",
|
167 |
-
" background-position: var(--image_x) calc(-120px - var(--image_y));\n",
|
168 |
-
"}\n",
|
169 |
-
".image_2::before {\n",
|
170 |
-
" background-position: var(--image_x) calc(-290px - var(--image_y));\n",
|
171 |
-
"}\n",
|
172 |
-
".image_3::before {\n",
|
173 |
-
" background-position: var(--image_x) calc(-430px - var(--image_y));\n",
|
174 |
-
"}\n",
|
175 |
-
".image_4::before {\n",
|
176 |
-
" background-position: var(--image_x) calc(var(--img_height_dif) - var(--image_y));\n",
|
177 |
-
"}\n",
|
178 |
-
"\n",
|
179 |
-
".container_custom_downlad {\n",
|
180 |
-
" height: 55px;\n",
|
181 |
-
" transition: all 0.5s;\n",
|
182 |
-
"}\n",
|
183 |
-
"\n",
|
184 |
-
".container_custom_downlad.expanded {\n",
|
185 |
-
" height: 270px;\n",
|
186 |
-
"}\n",
|
187 |
-
"\n",
|
188 |
-
"\n",
|
189 |
-
"/* Element text style */\n",
|
190 |
-
"\n",
|
191 |
-
".widget-html,\n",
|
192 |
-
".widget-button,\n",
|
193 |
-
".widget-text label,\n",
|
194 |
-
".widget-checkbox label,\n",
|
195 |
-
".widget-dropdown label,\n",
|
196 |
-
".widget-dropdown select,\n",
|
197 |
-
".widget-text input[type=\"text\"] {\n",
|
198 |
-
" font-family: cursive;\n",
|
199 |
-
" font-size: 14px;\n",
|
200 |
-
" color: white !important;\n",
|
201 |
-
" user-select: none;\n",
|
202 |
-
"}\n",
|
203 |
-
"\n",
|
204 |
-
".widget-text input[type=\"text\"]::placeholder {\n",
|
205 |
-
" color: grey;\n",
|
206 |
-
"}\n",
|
207 |
-
"\n",
|
208 |
-
"\n",
|
209 |
-
"/* Input field styles */\n",
|
210 |
-
"/*\n",
|
211 |
-
".widget-dropdown select,\n",
|
212 |
-
".widget-text input[type=\"text\"] {\n",
|
213 |
-
" height: 30px;\n",
|
214 |
-
" background-color: #1c1c1c;\n",
|
215 |
-
" border: 1px solid #262626;\n",
|
216 |
-
" border-radius: 10px;\n",
|
217 |
-
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
218 |
-
" transition: all 0.3s ease-in-out;\n",
|
219 |
-
"}\n",
|
220 |
-
"*/\n",
|
221 |
-
"\n",
|
222 |
-
".widget-dropdown select:focus,\n",
|
223 |
-
".widget-text input[type=\"text\"]:focus {\n",
|
224 |
-
" border-color: #006ee5;\n",
|
225 |
-
"}\n",
|
226 |
-
"\n",
|
227 |
-
".widget-dropdown select:hover,\n",
|
228 |
-
".widget-text input[type=\"text\"]:hover {\n",
|
229 |
-
" transform: scale(1.003);\n",
|
230 |
-
" background-color: #262626;\n",
|
231 |
-
" box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);\n",
|
232 |
-
"}\n",
|
233 |
-
"\n",
|
234 |
-
"\n",
|
235 |
-
"/* Slider Checkbox style */\n",
|
236 |
-
"\n",
|
237 |
-
".widget-checkbox input[type=\"checkbox\"] {\n",
|
238 |
-
" appearance: none;\n",
|
239 |
-
" position: relative;\n",
|
240 |
-
" top: 4px; /* Why is he taller?! */\n",
|
241 |
-
" width: 40px;\n",
|
242 |
-
" height: 20px;\n",
|
243 |
-
" border: none;\n",
|
244 |
-
" border-radius: 10px;\n",
|
245 |
-
" background-color: #20b2aa;\n",
|
246 |
-
" cursor: pointer;\n",
|
247 |
-
" box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);\n",
|
248 |
-
" transition: background-color 0.3s ease;\n",
|
249 |
-
"}\n",
|
250 |
-
".widget-checkbox input[type=\"checkbox\"]:checked {\n",
|
251 |
-
" background-color: #2196F3;\n",
|
252 |
-
"}\n",
|
253 |
-
"\n",
|
254 |
-
".widget-checkbox input[type=\"checkbox\"]:before {\n",
|
255 |
-
" content: '';\n",
|
256 |
-
" position: absolute;\n",
|
257 |
-
" top: 50%;\n",
|
258 |
-
" left: 3px;\n",
|
259 |
-
" width: 16px;\n",
|
260 |
-
" height: 16px;\n",
|
261 |
-
" border-radius: inherit;\n",
|
262 |
-
" background-color: white;\n",
|
263 |
-
" box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);\n",
|
264 |
-
" transform: translateY(-50%);\n",
|
265 |
-
" transition: left 0.3s ease;\n",
|
266 |
-
"}\n",
|
267 |
-
".widget-checkbox input[type=\"checkbox\"]:checked:before {\n",
|
268 |
-
" left: 21px;\n",
|
269 |
-
"}\n",
|
270 |
-
"\n",
|
271 |
-
"\n",
|
272 |
-
"/* Button styles */\n",
|
273 |
-
"\n",
|
274 |
-
".button_save {\n",
|
275 |
-
" font-size: 15px;\n",
|
276 |
-
" font-weight: bold;\n",
|
277 |
-
" width: 120px;\n",
|
278 |
-
" height: 35px;\n",
|
279 |
-
" border-radius: 15px;\n",
|
280 |
-
" background-image: radial-gradient(circle at top left, purple 10%, violet 90%);\n",
|
281 |
-
" background-size: 200% 200%;\n",
|
282 |
-
" background-position: left bottom;\n",
|
283 |
-
" transition: background 0.5s ease-in-out, transform 0.3s ease;\n",
|
284 |
-
"}\n",
|
285 |
-
"\n",
|
286 |
-
".button_save:hover {\n",
|
287 |
-
" cursor: pointer;\n",
|
288 |
-
" background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);\n",
|
289 |
-
" background-size: 200% 200%;\n",
|
290 |
-
" background-position: right bottom;\n",
|
291 |
-
" transform: translateY(1px);\n",
|
292 |
-
"}\n",
|
293 |
-
"\n",
|
294 |
-
".button_ngrok {\n",
|
295 |
-
" font-size: 12px;\n",
|
296 |
-
" height: 30px;\n",
|
297 |
-
" border-radius: 10px;\n",
|
298 |
-
" padding: 1px 12px;\n",
|
299 |
-
" background-image: radial-gradient(circle at top left, purple 10%, violet 90%);\n",
|
300 |
-
" background-size: 200% 200%;\n",
|
301 |
-
" background-position: left bottom;\n",
|
302 |
-
" transition: background 0.5s ease-in-out, transform 0.3s ease;\n",
|
303 |
-
" white-space: nowrap;\n",
|
304 |
-
"}\n",
|
305 |
-
"\n",
|
306 |
-
".button_ngrok:hover {\n",
|
307 |
-
" cursor: pointer;\n",
|
308 |
-
" background-image: radial-gradient(circle at top left, purple 10%, #1D94BB 90%);\n",
|
309 |
-
" background-size: 200% 200%;\n",
|
310 |
-
" background-position: right bottom;\n",
|
311 |
-
" transform: translateY(1px);\n",
|
312 |
-
"}\n",
|
313 |
-
"\n",
|
314 |
-
".button_save:active,\n",
|
315 |
-
".button_ngrok:active {\n",
|
316 |
-
" filter: brightness(0.75) !important;\n",
|
317 |
-
"}\n",
|
318 |
-
"\n",
|
319 |
-
"/* Removes ugly stroke from widget buttons. */\n",
|
320 |
-
".jupyter-widgets.lm-Widget:focus {\n",
|
321 |
-
" outline: none;\n",
|
322 |
-
"}\n",
|
323 |
-
"\n",
|
324 |
-
"\n",
|
325 |
-
"/* Popup style of `FAQ` window */\n",
|
326 |
-
"\n",
|
327 |
-
".info {\n",
|
328 |
-
" position: absolute;\n",
|
329 |
-
" top: -5px;\n",
|
330 |
-
" right: 95px;\n",
|
331 |
-
" color: grey;\n",
|
332 |
-
" font-family: cursive;\n",
|
333 |
-
" font-size: 14px;\n",
|
334 |
-
" font-weight: normal;\n",
|
335 |
-
" user-select: none;\n",
|
336 |
-
" pointer-events: none;\n",
|
337 |
-
" opacity: 0;\n",
|
338 |
-
" transition: opacity 0.3s ease-in-out;\n",
|
339 |
-
" display: inline-block;\n",
|
340 |
-
"}\n",
|
341 |
-
"\n",
|
342 |
-
".popup {\n",
|
343 |
-
" position: absolute;\n",
|
344 |
-
" top: 120px;\n",
|
345 |
-
" z-index: 999;\n",
|
346 |
-
" width: auto;\n",
|
347 |
-
" padding: 10px;\n",
|
348 |
-
" text-align: center;\n",
|
349 |
-
" background-color: rgba(255, 255, 255, 0.05);\n",
|
350 |
-
" backdrop-filter: blur(20px);\n",
|
351 |
-
" border: 1px solid rgba(255, 255, 255, 0.45);\n",
|
352 |
-
" border-radius: 8px;\n",
|
353 |
-
" box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);\n",
|
354 |
-
" opacity: 0;\n",
|
355 |
-
" color: #fff;\n",
|
356 |
-
" font-size: 16px;\n",
|
357 |
-
" font-family: cursive;\n",
|
358 |
-
" user-select: none;\n",
|
359 |
-
" cursor: default;\n",
|
360 |
-
" pointer-events: none;\n",
|
361 |
-
" transform: rotate(-5deg);\n",
|
362 |
-
" transition: top 0.3s ease-in-out, opacity 0.3s ease-in-out, transform 0.3s ease-in-out;\n",
|
363 |
-
"}\n",
|
364 |
-
"\n",
|
365 |
-
".sample {\n",
|
366 |
-
" display: inline-block;\n",
|
367 |
-
" margin-top: 25px;\n",
|
368 |
-
" padding: 10px 100px;\n",
|
369 |
-
" background-color: rgba(255, 255, 255, 0.2);\n",
|
370 |
-
" color: #c6e2ff;\n",
|
371 |
-
" border: 2px solid rgba(255, 255, 255, 0.2);\n",
|
372 |
-
" border-radius: 8px;\n",
|
373 |
-
" box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), inset 0 0 25px rgba(255, 255, 255, 0.2);\n",
|
374 |
-
"}\n",
|
375 |
-
"\n",
|
376 |
-
".info.showed {\n",
|
377 |
-
" opacity: 1;\n",
|
378 |
-
" pointer-events: auto;\n",
|
379 |
-
"}\n",
|
380 |
-
"\n",
|
381 |
-
".info:hover + .popup {\n",
|
382 |
-
" top: 35px;\n",
|
383 |
-
" opacity: 1;\n",
|
384 |
-
" pointer-events: initial;\n",
|
385 |
-
" transform: rotate(0deg);\n",
|
386 |
-
"}\n",
|
387 |
-
"\n",
|
388 |
-
"\n",
|
389 |
-
"/* Animation of elements */\n",
|
390 |
-
"\n",
|
391 |
-
".container,\n",
|
392 |
-
".button_save {\n",
|
393 |
-
" animation-name: showedWidgets;\n",
|
394 |
-
" animation-duration: 1s;\n",
|
395 |
-
" animation-fill-mode: forwards;\n",
|
396 |
-
"}\n",
|
397 |
-
"\n",
|
398 |
-
".container.hide,\n",
|
399 |
-
".button_save.hide {\n",
|
400 |
-
" animation-name: hideWidgets;\n",
|
401 |
-
" animation-duration: 0.5s;\n",
|
402 |
-
" animation-fill-mode: forwards;\n",
|
403 |
-
"}\n",
|
404 |
-
"\n",
|
405 |
-
"@keyframes showedWidgets {\n",
|
406 |
-
" 0% {\n",
|
407 |
-
" transform: translate3d(-65%, 15%, 0) scale(0) rotate(15deg);\n",
|
408 |
-
" filter: blur(25px) grayscale(1) brightness(0.3);\n",
|
409 |
-
" opacity: 0;\n",
|
410 |
-
" }\n",
|
411 |
-
" 100% {\n",
|
412 |
-
" transform: translate3d(0, 0, 0) scale(1) rotate(0deg);\n",
|
413 |
-
" filter: blur(0) grayscale(0) brightness(1);\n",
|
414 |
-
" opacity: 1;\n",
|
415 |
-
" }\n",
|
416 |
-
"}\n",
|
417 |
-
"\n",
|
418 |
-
"@keyframes hideWidgets {\n",
|
419 |
-
" 0% {\n",
|
420 |
-
" transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);\n",
|
421 |
-
" filter: blur(0) grayscale(0) brightness(1);\n",
|
422 |
-
" opacity: 1;\n",
|
423 |
-
" }\n",
|
424 |
-
" 100% {\n",
|
425 |
-
" transform: translate3d(0, 5%, 0) scale(0.9) rotate3d(1, 0, 0, 90deg);\n",
|
426 |
-
" filter: blur(15px) grayscale(1) brightness(0.5);\n",
|
427 |
-
" opacity: 0;\n",
|
428 |
-
" }\n",
|
429 |
-
"}\n",
|
430 |
-
"</style>\n",
|
431 |
-
"\n",
|
432 |
-
"<!-- TOGGLE 'CustomDL' SCRIPT -->\n",
|
433 |
-
"<script>\n",
|
434 |
-
"function toggleContainer() {\n",
|
435 |
-
" let downloadContainer = document.querySelector('.container_custom_downlad');\n",
|
436 |
-
" let info = document.querySelector('.info');\n",
|
437 |
-
"\n",
|
438 |
-
" downloadContainer.classList.toggle('expanded');\n",
|
439 |
-
" info.classList.toggle('showed');\n",
|
440 |
-
"}\n",
|
441 |
-
"</script>\n",
|
442 |
-
"'''\n",
|
443 |
-
"\n",
|
444 |
-
"display(HTML(CSS))\n",
|
445 |
-
"# ==================== CSS JS ====================\n",
|
446 |
-
"\n",
|
447 |
-
"\n",
|
448 |
-
"# ==================== WIDGETS ====================\n",
|
449 |
-
"# --- global widgets ---\n",
|
450 |
-
"style = {'description_width': 'initial'}\n",
|
451 |
-
"layout = widgets.Layout(min_width='1047px')\n",
|
452 |
-
"\n",
|
453 |
-
"HR = widgets.HTML('<hr>')\n",
|
454 |
-
"\n",
|
455 |
-
"# --- MODEL ---\n",
|
456 |
-
"model_header = widgets.HTML('<div class=\"header\">Выбор Модели<div>')\n",
|
457 |
-
"model_options = ['none',\n",
|
458 |
-
" '1.Anime (by XpucT) + INP',\n",
|
459 |
-
" '2.BluMix [Anime] [V7]',\n",
|
460 |
-
" '3.Cetus-Mix [Anime] [V4] + INP',\n",
|
461 |
-
" '4.Counterfeit [Anime] [V3] + INP',\n",
|
462 |
-
" '5.CuteColor [Anime] [V3]',\n",
|
463 |
-
" '6.Dark-Sushi-Mix [Anime]',\n",
|
464 |
-
" '7.Deliberate [Realism] [V6] + INP',\n",
|
465 |
-
" '8.Meina-Mix [Anime] [V11] + INP',\n",
|
466 |
-
" '9.Mix-Pro [Anime] [V4] + INP']\n",
|
467 |
-
"# ---\n",
|
468 |
-
"Model_widget = widgets.Dropdown(options=model_options, value='4.Counterfeit [Anime] [V3] + INP', description='Модель:', style=style, layout=layout)\n",
|
469 |
-
"Model_Num_widget = widgets.Text(description='Номер Модели:', placeholder='Введите номера моделей для скачивания через запятую/пробел.', style=style, layout=layout)\n",
|
470 |
-
"Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Модели', style=style)\n",
|
471 |
-
"\n",
|
472 |
-
"''' Display Model'''\n",
|
473 |
-
"all_model_box = widgets.VBox([model_header, Model_widget, Model_Num_widget, Inpainting_Model_widget]).add_class(\"container\").add_class(\"image_1\")\n",
|
474 |
-
"display(all_model_box)\n",
|
475 |
-
"\n",
|
476 |
-
"# --- VAE ---\n",
|
477 |
-
"vae_header = widgets.HTML('<div class=\"header\" >Выбор VAE</div>')\n",
|
478 |
-
"vae_options = ['none',\n",
|
479 |
-
" '1.Anime.vae',\n",
|
480 |
-
" '2.Anything.vae',\n",
|
481 |
-
" '3.Blessed2.vae',\n",
|
482 |
-
" '4.ClearVae.vae',\n",
|
483 |
-
" '5.WD.vae']\n",
|
484 |
-
"Vae_widget = widgets.Dropdown(options=vae_options, value='3.Blessed2.vae', description='Vae:', style=style, layout=layout)\n",
|
485 |
-
"Vae_Num_widget = widgets.Text(description='Номер Vae:', placeholder='Введите номера vae для скачивания через запятую/пробел.', style=style, layout=layout)\n",
|
486 |
-
"\n",
|
487 |
-
"''' Display Vae'''\n",
|
488 |
-
"all_vae_box= widgets.VBox([vae_header, Vae_widget, Vae_Num_widget]).add_class(\"container\").add_class(\"image_2\")\n",
|
489 |
-
"display(all_vae_box)\n",
|
490 |
-
"\n",
|
491 |
-
"# --- ADDITIONAL ---\n",
|
492 |
-
"additional_header = widgets.HTML('<div class=\"header\">Дополнительно</div>')\n",
|
493 |
-
"latest_webui_widget = widgets.Checkbox(value=True, description='Обновить WebUI', style=style)\n",
|
494 |
-
"latest_exstensions_widget = widgets.Checkbox(value=True, description='Обновить Расширения', style=style)\n",
|
495 |
-
"detailed_download_widget = widgets.Dropdown(options=['off', 'on'], value='off', description='Подробная Загрузка:', style=style)\n",
|
496 |
-
"latest_changes_widget = HBox([latest_webui_widget, latest_exstensions_widget, detailed_download_widget], layout=widgets.Layout(justify_content='space-between'))\n",
|
497 |
-
"controlnet_options = ['none', 'ALL', '1.canny',\n",
|
498 |
-
" '2.openpose', '3.depth',\n",
|
499 |
-
" '4.normal_map', '5.mlsd',\n",
|
500 |
-
" '6.lineart', '7.soft_edge',\n",
|
501 |
-
" '8.scribble', '9.segmentation',\n",
|
502 |
-
" '10.shuffle', '11.tile',\n",
|
503 |
-
" '12.inpaint', '13.instruct_p2p']\n",
|
504 |
-
"# ---\n",
|
505 |
-
"controlnet_widget = widgets.Dropdown(options=controlnet_options, value='none', description='ControlNet:', style=style, layout=layout)\n",
|
506 |
-
"controlnet_Num_widget = widgets.Text(description='Номер ControlNet:', placeholder='Введите номера моделей ControlNet для скачивания через запятую/пробел.', style=style, layout=layout)\n",
|
507 |
-
"commit_hash_widget = widgets.Text(description='Commit Hash:', style=style, layout=layout)\n",
|
508 |
-
"optional_huggingface_token_widget = widgets.Text(description='Токен HuggingFace:', style=style, layout=layout)\n",
|
509 |
-
"ngrok_token_widget = widgets.Text(description='Токен Ngrok:', style=style, layout=widgets.Layout(width='1047px'))\n",
|
510 |
-
"ngrock_button = widgets.HTML('<a href=\"https://dashboard.ngrok.com/get-started/your-authtoken\" target=\"_blank\">Получить Ngrok Токен</a>').add_class(\"button_ngrok\")\n",
|
511 |
-
"ngrok_widget = widgets.HBox([ngrok_token_widget, ngrock_button], style=style, layout=layout)\n",
|
512 |
-
"zrok_token_widget = widgets.Text(description='Zrok Token:', style=style, layout=widgets.Layout(width='1047px'))\n",
|
513 |
-
"zrok_button = widgets.HTML('<a href=\"https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU\" target=\"_blank\">Зарегать Zrok Токен</a>').add_class(\"button_ngrok\")\n",
|
514 |
-
"zrok_widget = widgets.HBox([zrok_token_widget, zrok_button], style=style, layout=layout)\n",
|
515 |
-
"# ---\n",
|
516 |
-
"commandline_arguments_options = \"--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers\"\n",
|
517 |
-
"commandline_arguments_widget = widgets.Text(description='Аргументы:', value=commandline_arguments_options, style=style, layout=layout)\n",
|
518 |
-
"\n",
|
519 |
-
"''' Display Additional'''\n",
|
520 |
-
"additional_widget_list = [additional_header, latest_changes_widget, HR, controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, zrok_widget, HR, commandline_arguments_widget]\n",
|
521 |
-
"if free_plan and env == \"Google Colab\": # remove ngrok from colab\n",
|
522 |
-
" additional_widget_list.remove(ngrok_widget)\n",
|
523 |
-
"if env == \"SageMaker Studio Lab\": # remove zrok from sagemaker\n",
|
524 |
-
" additional_widget_list.remove(zrok_widget)\n",
|
525 |
-
"# ```\n",
|
526 |
-
"all_additional_box = widgets.VBox(additional_widget_list).add_class(\"container\").add_class(\"image_3\")\n",
|
527 |
-
"display(all_additional_box)\n",
|
528 |
-
"\n",
|
529 |
-
"# --- CUSTOM DOWNLOAD ---\n",
|
530 |
-
"custom_download_header_popup = widgets.HTML('''\n",
|
531 |
-
"<style>\n",
|
532 |
-
"/* Color */\n",
|
533 |
-
".sample_label {color: #dbafff;}\n",
|
534 |
-
".braces {color: #ffff00;}\n",
|
535 |
-
".extension {color: #eb934b;}\n",
|
536 |
-
".file_name {color: #ffffd8;}\n",
|
537 |
-
"</style>\n",
|
538 |
-
"\n",
|
539 |
-
"<div class=\"header\" style=\"cursor: pointer;\" onclick=\"toggleContainer()\">Кастомная Загрузка</div>\n",
|
540 |
-
"<!-- PopUp window -->\n",
|
541 |
-
"<div class=\"info\" id=\"info_dl\">INFO</div>\n",
|
542 |
-
"<div class=\"popup\">\n",
|
543 |
-
" Разделите несколько URL-адресов запятой/пробелом. Для <span class=\"file_name\">пользовательского имени</span> файла/расширения укажите его через <span class=\"braces\">[]</span>\n",
|
544 |
-
" после URL без пробелов.\n",
|
545 |
-
" <span style=\"color: #ff9999\">Для файлов обязательно укажите</span> - <span class=\"extension\">Расширение Файла.</span>\n",
|
546 |
-
" <div class=\"sample\">\n",
|
547 |
-
" <span class=\"sample_label\">Пример для Файла:</span>\n",
|
548 |
-
" https://civitai.com/api/download/models/229782<span class=\"braces\">[</span><span class=\"file_name\">Detailer</span><span class=\"extension\">.safetensors</span><span class=\"braces\">]</span>\n",
|
549 |
-
" <br>\n",
|
550 |
-
" <span class=\"sample_label\">Пример для Расширения:</span>\n",
|
551 |
-
" https://github.com/hako-mikan/sd-webui-regional-prompter<span class=\"braces\">[</span><span class=\"file_name\">Regional-Prompter</span><span class=\"braces\">]</span>\n",
|
552 |
-
" </div>\n",
|
553 |
-
"</div>\n",
|
554 |
-
"''')\n",
|
555 |
-
"# ---\n",
|
556 |
-
"Model_url_widget = widgets.Text(description='Model:', style=style, layout=layout)\n",
|
557 |
-
"Vae_url_widget = widgets.Text(description='Vae:', style=style, layout=layout)\n",
|
558 |
-
"LoRA_url_widget = widgets.Text(description='LoRa:', style=style, layout=layout)\n",
|
559 |
-
"Embedding_url_widget = widgets.Text(description='Embedding:', style=style, layout=layout)\n",
|
560 |
-
"Extensions_url_widget = widgets.Text(description='Extensions:', style=style, layout=layout)\n",
|
561 |
-
"custom_file_urls_widget = widgets.Text(description='Файл (txt):', style=style, layout=layout)\n",
|
562 |
-
"\n",
|
563 |
-
"''' Display CustomDl'''\n",
|
564 |
-
"all_custom_box = widgets.VBox([\n",
|
565 |
-
" custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget\n",
|
566 |
-
" ]).add_class(\"container\").add_class(\"image_4\").add_class(\"container_custom_downlad\")\n",
|
567 |
-
"display(all_custom_box)\n",
|
568 |
-
"\n",
|
569 |
-
"# --- Save Button ---\n",
|
570 |
-
"save_button = widgets.Button(description='Сохранить').add_class(\"button_save\")\n",
|
571 |
-
"display(save_button)\n",
|
572 |
-
"\n",
|
573 |
-
"\n",
|
574 |
-
"# ============ Load / Save - Settings V2 ============\n",
|
575 |
-
"SETTINGS_FILE = f'{root_path}/settings.json'\n",
|
576 |
-
"\n",
|
577 |
-
"settings_keys = [\n",
|
578 |
-
" 'Model', 'Model_Num', 'Inpainting_Model',\n",
|
579 |
-
" 'Vae', 'Vae_Num',\n",
|
580 |
-
" 'latest_webui', 'latest_exstensions', 'detailed_download',\n",
|
581 |
-
" 'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',\n",
|
582 |
-
" 'ngrok_token', 'zrok_token', 'commandline_arguments',\n",
|
583 |
-
" 'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'\n",
|
584 |
-
"]\n",
|
585 |
-
"\n",
|
586 |
-
"def save_settings():\n",
|
587 |
-
" settings = {key: globals()[f\"{key}_widget\"].value for key in settings_keys}\n",
|
588 |
-
" with open(SETTINGS_FILE, 'w') as f:\n",
|
589 |
-
" json.dump(settings, f)\n",
|
590 |
-
"\n",
|
591 |
-
"def load_settings():\n",
|
592 |
-
" if os.path.exists(SETTINGS_FILE):\n",
|
593 |
-
" with open(SETTINGS_FILE, 'r') as f:\n",
|
594 |
-
" settings = json.load(f)\n",
|
595 |
-
" for key in settings_keys:\n",
|
596 |
-
" globals()[f\"{key}_widget\"].value = settings.get(key)\n",
|
597 |
-
"\n",
|
598 |
-
"def save_data(button):\n",
|
599 |
-
" save_settings()\n",
|
600 |
-
"\n",
|
601 |
-
" # --- uhh - hide... ---\n",
|
602 |
-
" widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]\n",
|
603 |
-
" for widget in widgets_list:\n",
|
604 |
-
" widget.add_class(\"hide\")\n",
|
605 |
-
" time.sleep(0.5)\n",
|
606 |
-
"\n",
|
607 |
-
" widgets.Widget.close_all()\n",
|
608 |
-
"\n",
|
609 |
-
"settings = load_settings()\n",
|
610 |
-
"save_button.on_click(save_data)"
|
611 |
-
],
|
612 |
-
"metadata": {
|
613 |
-
"id": "2lJmbqrs3Mu8"
|
614 |
-
},
|
615 |
-
"execution_count": null,
|
616 |
-
"outputs": []
|
617 |
-
}
|
618 |
-
]
|
619 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/python/en/auto-cleaner_en.py
DELETED
@@ -1,353 +0,0 @@
|
|
1 |
-
##~ AutoCleaner V3.6 CODE | BY: ANXETY ~##
|
2 |
-
|
3 |
-
# --change log--
|
4 |
-
"""
|
5 |
-
V3.6 | 13.03.24
|
6 |
-
Fixed selection window
|
7 |
-
Dynamic update of memory display
|
8 |
-
"""
|
9 |
-
|
10 |
-
|
11 |
-
import os
|
12 |
-
import time
|
13 |
-
import ipywidgets as widgets
|
14 |
-
from ipywidgets import Label, Button, VBox, HBox
|
15 |
-
from IPython.display import display, HTML, Javascript
|
16 |
-
|
17 |
-
|
18 |
-
# ================= DETECT ENV =================
|
19 |
-
def detect_environment():
|
20 |
-
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
21 |
-
environments = {
|
22 |
-
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
23 |
-
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
24 |
-
'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', "/home/studio-lab-user/content")
|
25 |
-
}
|
26 |
-
|
27 |
-
for env_var, (environment, path) in environments.items():
|
28 |
-
if env_var in os.environ:
|
29 |
-
return environment, path, free_plan
|
30 |
-
|
31 |
-
env, root_path, free_plan = detect_environment()
|
32 |
-
webui_path = f"{root_path}/sdw"
|
33 |
-
# ----------------------------------------------
|
34 |
-
|
35 |
-
|
36 |
-
directories = {
|
37 |
-
"Images": f"{webui_path}/outputs",
|
38 |
-
"Models": f"{webui_path}/models/Stable-diffusion/",
|
39 |
-
"Vae": f"{webui_path}/models/VAE/",
|
40 |
-
"LoRa": f"{webui_path}/models/Lora/",
|
41 |
-
"ControlNet Models": f"{webui_path}/models/ControlNet/"
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
# ==================== CSS ====================
|
46 |
-
CSS = """
|
47 |
-
<style>
|
48 |
-
/* General Styles */
|
49 |
-
|
50 |
-
hr {
|
51 |
-
border-color: grey;
|
52 |
-
background-color: grey;
|
53 |
-
opacity: 0.25;
|
54 |
-
}
|
55 |
-
|
56 |
-
.instruction_AC {
|
57 |
-
font-family: cursive;
|
58 |
-
font-size: 18px;
|
59 |
-
color: grey;
|
60 |
-
user-select: none;
|
61 |
-
cursor: default;
|
62 |
-
}
|
63 |
-
|
64 |
-
|
65 |
-
/* Container style */
|
66 |
-
|
67 |
-
.container_AC {
|
68 |
-
position: relative;
|
69 |
-
background-color: #232323;
|
70 |
-
width: 800px;
|
71 |
-
height: auto;
|
72 |
-
padding: 15px;
|
73 |
-
border-radius: 15px;
|
74 |
-
box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
|
75 |
-
margin-bottom: 5px;
|
76 |
-
overflow: visible;
|
77 |
-
}
|
78 |
-
|
79 |
-
.container_AC::before {
|
80 |
-
position: absolute;
|
81 |
-
top: 5px;
|
82 |
-
right: 10px;
|
83 |
-
content: "AutoCleanerV3.6";
|
84 |
-
font-weight: bold;
|
85 |
-
font-size: 24px;
|
86 |
-
color: rgba(0, 0, 0, 0.2);
|
87 |
-
}
|
88 |
-
|
89 |
-
.container_AC::after {
|
90 |
-
position: absolute;
|
91 |
-
top: 30px;
|
92 |
-
right: 10px;
|
93 |
-
content: "ANXETY";
|
94 |
-
font-weight: bold;
|
95 |
-
font-size: 18px;
|
96 |
-
color: rgba(0, 0, 0, 0.2);
|
97 |
-
}
|
98 |
-
|
99 |
-
.custom-select-multiple_AC select {
|
100 |
-
padding: 10px;
|
101 |
-
font-family: cursive;
|
102 |
-
border: 1px solid #262626 !important;
|
103 |
-
border-radius: 10px;
|
104 |
-
color: white;
|
105 |
-
background-color: #1c1c1c;
|
106 |
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
107 |
-
}
|
108 |
-
|
109 |
-
.output_AC {
|
110 |
-
padding: 10px;
|
111 |
-
height: auto;
|
112 |
-
border: 1px solid #262626;
|
113 |
-
border-radius: 10px;
|
114 |
-
background-color: #1c1c1c;
|
115 |
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
116 |
-
width: auto;
|
117 |
-
box-sizing: border-box;
|
118 |
-
}
|
119 |
-
|
120 |
-
.output_message_AC {
|
121 |
-
font-family: cursive;
|
122 |
-
color: white !important;
|
123 |
-
font-size: 14px;
|
124 |
-
user-select: none;
|
125 |
-
cursor: default
|
126 |
-
}
|
127 |
-
|
128 |
-
|
129 |
-
.storage_info_AC {
|
130 |
-
padding: 5px 20px;
|
131 |
-
height: auto;
|
132 |
-
border: 1px solid #262626;
|
133 |
-
border-radius: 10px;
|
134 |
-
background-color: #1c1c1c;
|
135 |
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
136 |
-
width: auto;
|
137 |
-
font-family: cursive;
|
138 |
-
color: #B2B2B2 !important;
|
139 |
-
font-size: 14px;
|
140 |
-
user-select: none;
|
141 |
-
cursor: default
|
142 |
-
}
|
143 |
-
|
144 |
-
|
145 |
-
/* Button and storage info layout */
|
146 |
-
.lower_information_panel_AC {
|
147 |
-
display: flex;
|
148 |
-
align-items: center;
|
149 |
-
justify-content: space-between;
|
150 |
-
}
|
151 |
-
|
152 |
-
|
153 |
-
/* Button style */
|
154 |
-
|
155 |
-
.button_AC {
|
156 |
-
width: auto;
|
157 |
-
font-family: cursive;
|
158 |
-
color: white !important;
|
159 |
-
font-size: 14px;
|
160 |
-
font-weight: bold;
|
161 |
-
height: 35px;
|
162 |
-
border-radius: 15px;
|
163 |
-
background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
|
164 |
-
background-size: 200% 200%;
|
165 |
-
background-position: left bottom;
|
166 |
-
transition: background 0.5s ease-in-out, transform 0.3s ease;
|
167 |
-
}
|
168 |
-
|
169 |
-
.button_AC:hover {
|
170 |
-
cursor: pointer;
|
171 |
-
background-size: 200% 200%;
|
172 |
-
background-position: right bottom;
|
173 |
-
transform: translateY(1px);
|
174 |
-
}
|
175 |
-
|
176 |
-
.button_execute_AC:hover {
|
177 |
-
background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);
|
178 |
-
}
|
179 |
-
|
180 |
-
.button_clear_AC:hover {
|
181 |
-
background-image: radial-gradient(circle at top left, purple 10%, #fc3468 90%);
|
182 |
-
}
|
183 |
-
|
184 |
-
.button_execute_AC:active,
|
185 |
-
.button_clear_AC:active {
|
186 |
-
filter: brightness(0.75);
|
187 |
-
}
|
188 |
-
|
189 |
-
.jupyter-widgets.lm-Widget:focus {
|
190 |
-
outline: none;
|
191 |
-
}
|
192 |
-
|
193 |
-
|
194 |
-
/* Animation of elements */
|
195 |
-
|
196 |
-
/* Emergence */
|
197 |
-
.container_AC {
|
198 |
-
animation-name: slideInTopBlur;
|
199 |
-
animation-duration: 0.7s;
|
200 |
-
animation-fill-mode: forwards;
|
201 |
-
}
|
202 |
-
|
203 |
-
@keyframes slideInTopBlur {
|
204 |
-
0% {
|
205 |
-
transform: translate3d(0, 50%, 0) scale(0.85) rotate3d(1, 0, 0, -85deg);
|
206 |
-
filter: blur(5px) grayscale(1) brightness(0.5);
|
207 |
-
opacity: 0;
|
208 |
-
}
|
209 |
-
100% {
|
210 |
-
transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);
|
211 |
-
filter: blur(0) grayscale(0) brightness(1);
|
212 |
-
opacity: 1;
|
213 |
-
}
|
214 |
-
}
|
215 |
-
|
216 |
-
/* Leaving */
|
217 |
-
.container_AC.hide {
|
218 |
-
animation-name: slideOutTopBlur;
|
219 |
-
animation-duration: 0.5s;
|
220 |
-
animation-fill-mode: forwards;
|
221 |
-
}
|
222 |
-
|
223 |
-
@keyframes slideOutTopBlur {
|
224 |
-
0% {
|
225 |
-
transform: translate3d(0, 0, 0) scale(1);
|
226 |
-
filter: blur(0) grayscale(0) brightness(1);
|
227 |
-
opacity: 1;
|
228 |
-
}
|
229 |
-
100% {
|
230 |
-
transform: translate3d(0, -100%, 0);
|
231 |
-
filter: blur(5px) grayscale(1) brightness(0);
|
232 |
-
opacity: 0;
|
233 |
-
}
|
234 |
-
}
|
235 |
-
</style>
|
236 |
-
"""
|
237 |
-
|
238 |
-
display(HTML(CSS))
|
239 |
-
# ==================== CSS ====================
|
240 |
-
|
241 |
-
|
242 |
-
# ================ AutoCleaner function ================
|
243 |
-
def clean_directory(directory):
|
244 |
-
deleted_files = 0
|
245 |
-
for root, dirs, files in os.walk(directory):
|
246 |
-
for file in files:
|
247 |
-
if file.endswith(".txt"):
|
248 |
-
continue
|
249 |
-
os.remove(os.path.join(root, file))
|
250 |
-
if not file.endswith(".yaml"):
|
251 |
-
deleted_files += 1
|
252 |
-
return deleted_files
|
253 |
-
|
254 |
-
|
255 |
-
def get_word_variant(n, variants):
|
256 |
-
unit = abs(n) % 10
|
257 |
-
tens = abs(n) % 100
|
258 |
-
if tens in range(11, 15):
|
259 |
-
return variants[2]
|
260 |
-
elif unit == 1:
|
261 |
-
return variants[0]
|
262 |
-
elif unit in range(2, 5):
|
263 |
-
return variants[1]
|
264 |
-
else:
|
265 |
-
return variants[2]
|
266 |
-
|
267 |
-
|
268 |
-
def update_memory_info():
|
269 |
-
disk_space = psutil.disk_usage(os.getcwd())
|
270 |
-
total = disk_space.total / (1024 ** 3)
|
271 |
-
used = disk_space.used / (1024 ** 3)
|
272 |
-
free = disk_space.free / (1024 ** 3)
|
273 |
-
|
274 |
-
storage_info.value = f'''
|
275 |
-
<div class="storage_info_AC">Total storage: {total:.2f} GB <span style="color: #555">|</span> Used: {used:.2f} GB <span style="color: #555">|</span> Free: {free:.2f} GB</div>
|
276 |
-
'''
|
277 |
-
|
278 |
-
|
279 |
-
def on_execute_button_press(button):
|
280 |
-
selected_cleaners = auto_cleaner_widget.value
|
281 |
-
deleted_files_dict = {}
|
282 |
-
|
283 |
-
for option in selected_cleaners:
|
284 |
-
if option in directories:
|
285 |
-
deleted_files_dict[option] = clean_directory(directories[option])
|
286 |
-
|
287 |
-
output.clear_output()
|
288 |
-
|
289 |
-
with output:
|
290 |
-
for message in generate_messages(deleted_files_dict):
|
291 |
-
message_widget = HTML(f'<p class="output_message_AC">{message}</p>')
|
292 |
-
display(message_widget)
|
293 |
-
|
294 |
-
update_memory_info()
|
295 |
-
|
296 |
-
|
297 |
-
def on_clear_button_press(button):
|
298 |
-
container.add_class("hide")
|
299 |
-
time.sleep(0.5)
|
300 |
-
widgets.Widget.close_all()
|
301 |
-
|
302 |
-
|
303 |
-
def generate_messages(deleted_files_dict):
|
304 |
-
messages = []
|
305 |
-
word_variants = {
|
306 |
-
"Images": ["Image", "Images", "Images"],
|
307 |
-
"Models": ["Model", "Models", "Models"],
|
308 |
-
"Vae": ["VAE", "VAE", "VAE"],
|
309 |
-
"LoRa": ["LoRa", "LoRa", "LoRa"],
|
310 |
-
"ControlNet Models": ["ControlNet Model", "ControlNet Models", "ControlNet Models"]
|
311 |
-
}
|
312 |
-
deleted_word_variants = ["Deleted", "Deleted", "Deleted"]
|
313 |
-
for key, value in deleted_files_dict.items():
|
314 |
-
word_variant = word_variants.get(key, ["", "", ""])
|
315 |
-
deleted_word = get_word_variant(value, deleted_word_variants)
|
316 |
-
object_word = get_word_variant(value, word_variant)
|
317 |
-
messages.append(f"{deleted_word} {value} {object_word}")
|
318 |
-
return messages
|
319 |
-
# ================ AutoCleaner function ================
|
320 |
-
|
321 |
-
|
322 |
-
# --- storage memory ---
|
323 |
-
import psutil
|
324 |
-
disk_space = psutil.disk_usage(os.getcwd())
|
325 |
-
total = disk_space.total / (1024 ** 3)
|
326 |
-
used = disk_space.used / (1024 ** 3)
|
327 |
-
free = disk_space.free / (1024 ** 3)
|
328 |
-
|
329 |
-
|
330 |
-
# UI Code
|
331 |
-
AutoCleaner_options = AutoCleaner_options = list(directories.keys())
|
332 |
-
instruction_label = widgets.HTML('''
|
333 |
-
<span class="instruction_AC">Use <span style="color: #B2B2B2;">ctrl</span> or <span style="color: #B2B2B2;">shift</span> for multiple selections.</span>
|
334 |
-
''')
|
335 |
-
auto_cleaner_widget = widgets.SelectMultiple(options=AutoCleaner_options, layout=widgets.Layout(width='auto')).add_class("custom-select-multiple_AC")
|
336 |
-
output = widgets.Output().add_class("output_AC")
|
337 |
-
# ---
|
338 |
-
execute_button = Button(description='Execute Cleaning').add_class("button_execute_AC").add_class("button_AC")
|
339 |
-
execute_button.on_click(on_execute_button_press)
|
340 |
-
clear_button = Button(description='Hide Widget').add_class("button_clear_AC").add_class("button_AC")
|
341 |
-
clear_button.on_click(on_clear_button_press)
|
342 |
-
# ---
|
343 |
-
storage_info = widgets.HTML(f'''
|
344 |
-
<div class="storage_info_AC">Total storage: {total:.2f} GB <span style="color: #555">|</span> Used: {used:.2f} GB <span style="color: #555">|</span> Free: {free:.2f} GB</div>
|
345 |
-
''')
|
346 |
-
# ---
|
347 |
-
buttons = widgets.HBox([execute_button, clear_button])
|
348 |
-
lower_information_panel = widgets.HBox([buttons, storage_info]).add_class("lower_information_panel_AC")
|
349 |
-
|
350 |
-
container = VBox([instruction_label, widgets.HTML('<hr>'), auto_cleaner_widget, output, widgets.HTML('<hr>'), lower_information_panel]).add_class("container_AC")
|
351 |
-
|
352 |
-
display(container)
|
353 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/python/en/downloading_en.py
DELETED
@@ -1,564 +0,0 @@
|
|
1 |
-
##~ DOWNLOADING CODE | BY: ANXETY ~##
|
2 |
-
|
3 |
-
import os
|
4 |
-
import re
|
5 |
-
import time
|
6 |
-
import json
|
7 |
-
import requests
|
8 |
-
import subprocess
|
9 |
-
from datetime import timedelta
|
10 |
-
from subprocess import getoutput
|
11 |
-
from urllib.parse import unquote
|
12 |
-
from IPython.utils import capture
|
13 |
-
from IPython.display import clear_output
|
14 |
-
|
15 |
-
|
16 |
-
# ================= DETECT ENV =================
|
17 |
-
def detect_environment():
|
18 |
-
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
19 |
-
environments = {
|
20 |
-
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
21 |
-
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
22 |
-
'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', "/home/studio-lab-user/content")
|
23 |
-
}
|
24 |
-
|
25 |
-
for env_var, (environment, path) in environments.items():
|
26 |
-
if env_var in os.environ:
|
27 |
-
return environment, path, free_plan
|
28 |
-
|
29 |
-
env, root_path, free_plan = detect_environment()
|
30 |
-
webui_path = f"{root_path}/sdw"
|
31 |
-
# ----------------------------------------------
|
32 |
-
|
33 |
-
|
34 |
-
# === ONLY SAGEMAKER ===
|
35 |
-
if env == "SageMaker Studio Lab":
|
36 |
-
print("Updating dependencies, may take some time...")
|
37 |
-
get_ipython().system('pip install -q --upgrade torchsde')
|
38 |
-
get_ipython().system('pip install -q --upgrade pip')
|
39 |
-
get_ipython().system('pip install -q --upgrade psutil')
|
40 |
-
|
41 |
-
clear_output()
|
42 |
-
|
43 |
-
|
44 |
-
# ================ LIBRARIES ================
|
45 |
-
flag_file = f"{root_path}/libraries_installed.txt"
|
46 |
-
|
47 |
-
if not os.path.exists(flag_file):
|
48 |
-
# automatic1111 update webui to 1.8.0
|
49 |
-
xformers = "xformers==0.0.23.post1 triton==2.1.0"
|
50 |
-
torch = "torch==2.1.2+cu121 torchvision==0.16.2+cu121 torchaudio==2.1.2 --extra-index-url https://download.pytorch.org/whl/cu121"
|
51 |
-
|
52 |
-
print("💿 Installing the libraries, it's going to take a while...", end='')
|
53 |
-
with capture.capture_output() as cap:
|
54 |
-
get_ipython().system('pip install -U gdown')
|
55 |
-
get_ipython().system('apt-get update && apt -y install aria2')
|
56 |
-
get_ipython().system('npm install -g localtunnel &> /dev/null')
|
57 |
-
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
58 |
-
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')
|
59 |
-
get_ipython().system('pip install insightface')
|
60 |
-
get_ipython().system('curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.23/zrok_0.4.23_linux_amd64.tar.gz && tar -xzf zrok_0.4.23_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.23_linux_amd64.tar.gz')
|
61 |
-
|
62 |
-
if env == "SageMaker Studio Lab":
|
63 |
-
get_ipython().run_line_magic('pip', 'install -q opencv-python-headless huggingface-hub')
|
64 |
-
get_ipython().run_line_magic('conda', 'update -q -n base conda')
|
65 |
-
get_ipython().run_line_magic('conda', 'install -q -y aria2')
|
66 |
-
get_ipython().run_line_magic('conda', 'install -q -y glib')
|
67 |
-
get_ipython().system('pip install tensorflow')
|
68 |
-
|
69 |
-
get_ipython().system('wget -P /home/studio-lab-user https://huggingface.co/NagisaNao/fast_repo/resolve/main/sagemaker/FULL_DELETED_NOTEBOOK.ipynb')
|
70 |
-
|
71 |
-
if env == "Google Colab":
|
72 |
-
get_ipython().system('pip install xformers==0.0.25 --no-deps')
|
73 |
-
else:
|
74 |
-
get_ipython().system('pip install -q {torch} -U')
|
75 |
-
get_ipython().system('pip install -q {xformers} -U')
|
76 |
-
|
77 |
-
with open(flag_file, "w") as f:
|
78 |
-
f.write("hey ;3")
|
79 |
-
del cap
|
80 |
-
print("\r🍪 Libraries are installed!" + " "*35)
|
81 |
-
time.sleep(2)
|
82 |
-
clear_output()
|
83 |
-
|
84 |
-
|
85 |
-
# ================= loading settings V4 =================
|
86 |
-
def load_settings(path):
|
87 |
-
if os.path.exists(path):
|
88 |
-
with open(path, 'r') as file:
|
89 |
-
return json.load(file)
|
90 |
-
return {}
|
91 |
-
|
92 |
-
settings = load_settings(f'{root_path}/settings.json')
|
93 |
-
|
94 |
-
variables = [
|
95 |
-
'Model', 'Model_Num', 'Inpainting_Model',
|
96 |
-
'Vae', 'Vae_Num',
|
97 |
-
'latest_webui', 'latest_exstensions', 'detailed_download',
|
98 |
-
'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
|
99 |
-
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
100 |
-
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'
|
101 |
-
]
|
102 |
-
|
103 |
-
locals().update({key: settings.get(key) for key in variables})
|
104 |
-
|
105 |
-
|
106 |
-
# ================= OTHER =================
|
107 |
-
try:
|
108 |
-
start_colab
|
109 |
-
except:
|
110 |
-
start_colab = int(time.time())-5
|
111 |
-
|
112 |
-
# CONFIG DIR
|
113 |
-
models_dir = f"{webui_path}/models/Stable-diffusion"
|
114 |
-
vaes_dir = f"{webui_path}/models/VAE"
|
115 |
-
embeddings_dir = f"{webui_path}/embeddings"
|
116 |
-
loras_dir = f"{webui_path}/models/Lora"
|
117 |
-
extensions_dir = f"{webui_path}/extensions"
|
118 |
-
control_dir = f"{webui_path}/models/ControlNet"
|
119 |
-
|
120 |
-
|
121 |
-
# ================= MAIN CODE =================
|
122 |
-
# --- Obsolescence warning ---
|
123 |
-
if env == "SageMaker Studio Lab":
|
124 |
-
print("You are using the 'SageMaker' environment - this environment is outdated so many bugs will not be fixed and it will be cut in functionality. To save memory and/or to avoid bugs.\n\n")
|
125 |
-
|
126 |
-
|
127 |
-
if not os.path.exists(webui_path):
|
128 |
-
start_install = int(time.time())
|
129 |
-
print("⌚ Unpacking Stable Diffusion...", end='')
|
130 |
-
with capture.capture_output() as cap:
|
131 |
-
get_ipython().system('aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip -o repo.zip')
|
132 |
-
get_ipython().system('unzip -q -o repo.zip -d {webui_path}')
|
133 |
-
get_ipython().system('rm -rf repo.zip')
|
134 |
-
|
135 |
-
get_ipython().run_line_magic('cd', '{root_path}')
|
136 |
-
os.environ["SAFETENSORS_FAST_GPU"]='1'
|
137 |
-
os.environ["CUDA_MODULE_LOADING"]="LAZY"
|
138 |
-
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
|
139 |
-
os.environ["PYTHONWARNINGS"] = "ignore"
|
140 |
-
|
141 |
-
get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
142 |
-
del cap
|
143 |
-
install_time = timedelta(seconds=time.time()-start_install)
|
144 |
-
print("\r🚀 Unpacking is complete! For","%02d:%02d:%02d ⚡\n" % (install_time.seconds / 3600, (install_time.seconds / 60) % 60, install_time.seconds % 60), end='', flush=True)
|
145 |
-
else:
|
146 |
-
if env == "SageMaker Studio Lab":
|
147 |
-
get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
148 |
-
print("🚀 All unpacked... Skip. ⚡")
|
149 |
-
start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
|
150 |
-
time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
|
151 |
-
print(f"⌚️ You have been conducting this session for - \033[33m{time_since_start}\033[0m")
|
152 |
-
|
153 |
-
|
154 |
-
## Changes extensions and WebUi
|
155 |
-
if latest_webui or latest_exstensions:
|
156 |
-
action = "Updating WebUI and Extensions" if latest_webui and latest_exstensions else ("WebUI Update" if latest_webui else "Update Extensions")
|
157 |
-
print(f"⌚️ {action}...", end='', flush=True)
|
158 |
-
with capture.capture_output() as cap:
|
159 |
-
get_ipython().system('git config --global user.email "[email protected]"')
|
160 |
-
get_ipython().system('git config --global user.name "Your Name"')
|
161 |
-
|
162 |
-
## Update Webui
|
163 |
-
if latest_webui:
|
164 |
-
get_ipython().run_line_magic('cd', '{webui_path}')
|
165 |
-
get_ipython().system('git restore .')
|
166 |
-
get_ipython().system('git pull -X theirs --rebase --autostash')
|
167 |
-
|
168 |
-
## Update extensions
|
169 |
-
if latest_exstensions:
|
170 |
-
if env != "SageMaker Studio Lab":
|
171 |
-
get_ipython().system('{\'for dir in \' + webui_path + \'/extensions/*/; do cd \\"$dir\\" && git reset --hard && git pull; done\'}')
|
172 |
-
else:
|
173 |
-
get_ipython().system('{\'for dir in /home/studio-lab-user/content/sdw/extensions/*/; do cd \\"$dir\\" && git fetch origin && git pull; done\'}')
|
174 |
-
|
175 |
-
# My Chinese friend, you broke the images again in the latest update... >W<'
|
176 |
-
get_ipython().run_line_magic('cd', '{webui_path}/extensions/Encrypt-Image')
|
177 |
-
get_ipython().system('git reset --hard 376358d8854472b9ea50e9fc8800367d1ca51137 # stable commit :3')
|
178 |
-
|
179 |
-
get_ipython().system('cd {webui_path}/repositories/stable-diffusion-stability-ai && git restore .')
|
180 |
-
del cap
|
181 |
-
print(f"\r✨ {action} Completed!")
|
182 |
-
|
183 |
-
|
184 |
-
# === FIXING ERRORS ===
|
185 |
-
# --- Encrypt-Image ---
|
186 |
-
get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js")
|
187 |
-
|
188 |
-
# --- SageMaker ---
|
189 |
-
if env == "SageMaker Studio Lab":
|
190 |
-
with capture.capture_output() as cap:
|
191 |
-
# --- SuperMerger Remove ---
|
192 |
-
if os.path.exists(f"{webui_path}/extensions/supermerger"):
|
193 |
-
get_ipython().system('rm -rf {webui_path}/extensions/supermerger')
|
194 |
-
# --- Launch (Style) ---
|
195 |
-
get_ipython().system('wget -O {webui_path}/modules/styles.py https://huggingface.co/NagisaNao/fast_repo/resolve/main/sagemaker/fixing/webui/styles.py')
|
196 |
-
del cap
|
197 |
-
|
198 |
-
|
199 |
-
## Version switching
|
200 |
-
if commit_hash:
|
201 |
-
print('⏳ Time machine activation...', end="", flush=True)
|
202 |
-
with capture.capture_output() as cap:
|
203 |
-
get_ipython().run_line_magic('cd', '{webui_path}')
|
204 |
-
get_ipython().system('git config --global user.email "[email protected]"')
|
205 |
-
get_ipython().system('git config --global user.name "Your Name"')
|
206 |
-
get_ipython().system('git reset --hard {commit_hash}')
|
207 |
-
del cap
|
208 |
-
print(f"\r⌛️ The time machine has been activated! Current commit: \033[34m{commit_hash}\033[0m")
|
209 |
-
|
210 |
-
|
211 |
-
## Downloading model and stuff | oh yeah~ I'm starting to misunderstand my own code ( almost my own ;3 )
|
212 |
-
print("📦 Downloading models and stuff...", end='')
|
213 |
-
model_list = {
|
214 |
-
"1.Anime (by XpucT) + INP": [
|
215 |
-
{"url": "https://huggingface.co/XpucT/Anime/resolve/main/Anime_v2.safetensors", "name": "Anime_v2.safetensors"},
|
216 |
-
{"url": "https://huggingface.co/XpucT/Anime/resolve/main/Anime_v2-inpainting.safetensors", "name": "Anime_v2-inpainting.safetensors"}
|
217 |
-
],
|
218 |
-
"2.BluMix [Anime] [V7]": [
|
219 |
-
{"url": "https://civitai.com/api/download/models/361779", "name": "BluMix_v7.safetensors"}
|
220 |
-
],
|
221 |
-
"3.Cetus-Mix [Anime] [V4] + INP": [
|
222 |
-
{"url": "https://civitai.com/api/download/models/130298", "name": "CetusMix_V4.safetensors"},
|
223 |
-
{"url": "https://civitai.com/api/download/models/139882", "name": "CetusMix_V4-inpainting.safetensors"}
|
224 |
-
],
|
225 |
-
"4.Counterfeit [Anime] [V3] + INP": [
|
226 |
-
{"url": "https://civitai.com/api/download/models/125050", "name": "Counterfeit_V3.safetensors"},
|
227 |
-
{"url": "https://civitai.com/api/download/models/137911", "name": "Counterfeit_V3-inpainting.safetensors"}
|
228 |
-
],
|
229 |
-
"5.CuteColor [Anime] [V3]": [
|
230 |
-
{"url": "https://civitai.com/api/download/models/138754", "name": "CuteColor_V3.safetensors"}
|
231 |
-
],
|
232 |
-
"6.Dark-Sushi-Mix [Anime]": [
|
233 |
-
{"url": "https://civitai.com/api/download/models/101640", "name": "DarkSushiMix_2_5D.safetensors"},
|
234 |
-
{"url": "https://civitai.com/api/download/models/56071", "name": "DarkSushiMix_colorful.safetensors"}
|
235 |
-
],
|
236 |
-
"7.Deliberate [Realism] [V6] + INP": [
|
237 |
-
{"url": "https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v6.safetensors", "name": "Deliberate_v6.safetensors"},
|
238 |
-
{"url": "https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v6-inpainting.safetensors", "name": "Deliberate_v6-inpainting.safetensors"}
|
239 |
-
],
|
240 |
-
"8.Meina-Mix [Anime] [V11] + INP": [
|
241 |
-
{"url": "https://civitai.com/api/download/models/119057", "name": "MeinaMix_V11.safetensors"},
|
242 |
-
{"url": "https://civitai.com/api/download/models/120702", "name": "MeinaMix_V11-inpainting.safetensors"}
|
243 |
-
],
|
244 |
-
"9.Mix-Pro [Anime] [V4] + INP": [
|
245 |
-
{"url": "https://civitai.com/api/download/models/125668", "name": "MixPro_V4.safetensors"},
|
246 |
-
{"url": "https://civitai.com/api/download/models/139878", "name": "MixPro_V4-inpainting.safetensors"}
|
247 |
-
]
|
248 |
-
}
|
249 |
-
|
250 |
-
# 1-4 (fp16/cleaned)
|
251 |
-
vae_list = {
|
252 |
-
"1.Anime.vae": [
|
253 |
-
{"url": "https://civitai.com/api/download/models/131654", "name": "Anime.vae.safetensors"},
|
254 |
-
{"url": "https://civitai.com/api/download/models/131658", "name": "vae-ft-mse.vae.safetensors"}
|
255 |
-
],
|
256 |
-
"2.Anything.vae": [{"url": "https://civitai.com/api/download/models/131656", "name": "Anything.vae.safetensors"}],
|
257 |
-
"3.Blessed2.vae": [{"url": "https://civitai.com/api/download/models/142467", "name": "Blessed2.vae.safetensors"}],
|
258 |
-
"4.ClearVae.vae": [{"url": "https://civitai.com/api/download/models/133362", "name": "ClearVae_23.vae.safetensors"}],
|
259 |
-
"5.WD.vae": [{"url": "https://huggingface.co/NoCrypt/resources/resolve/main/VAE/wd.vae.safetensors", "name": "WD.vae.safetensors"}]
|
260 |
-
}
|
261 |
-
|
262 |
-
controlnet_list = {
|
263 |
-
"1.canny": [
|
264 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny_fp16.safetensors", "name": "control_v11p_sd15_canny_fp16.safetensors"},
|
265 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_canny_fp16.yaml", "name": "control_v11p_sd15_canny_fp16.yaml"}
|
266 |
-
],
|
267 |
-
"2.openpose": [
|
268 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose_fp16.safetensors", "name": "control_v11p_sd15_openpose_fp16.safetensors"},
|
269 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_openpose_fp16.yaml", "name": "control_v11p_sd15_openpose_fp16.yaml"}
|
270 |
-
],
|
271 |
-
"3.depth": [
|
272 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors", "name": "control_v11f1p_sd15_depth_fp16.safetensors"},
|
273 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1p_sd15_depth_fp16.yaml", "name": "control_v11f1p_sd15_depth_fp16.yaml"},
|
274 |
-
{"url": "https://huggingface.co/NagisaNao/models/resolve/main/ControlNet_v11/control_v11p_sd15_depth_anything_fp16.safetensors", "name": "control_v11p_sd15_depth_anything_fp16.safetensors"}
|
275 |
-
],
|
276 |
-
"4.normal_map": [
|
277 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors", "name": "control_v11p_sd15_normalbae_fp16.safetensors"},
|
278 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_normalbae_fp16.yaml", "name": "control_v11p_sd15_normalbae_fp16.yaml"}
|
279 |
-
],
|
280 |
-
"5.mlsd": [
|
281 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors", "name": "control_v11p_sd15_mlsd_fp16.safetensors"},
|
282 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_mlsd_fp16.yaml", "name": "control_v11p_sd15_mlsd_fp16.yaml"}
|
283 |
-
],
|
284 |
-
"6.lineart": [
|
285 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart_fp16.safetensors", "name": "control_v11p_sd15_lineart_fp16.safetensors"},
|
286 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors", "name": "control_v11p_sd15s2_lineart_anime_fp16.safetensors"},
|
287 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_lineart_fp16.yaml", "name": "control_v11p_sd15_lineart_fp16.yaml"},
|
288 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15s2_lineart_anime_fp16.yaml", "name": "control_v11p_sd15s2_lineart_anime_fp16.yaml"}
|
289 |
-
],
|
290 |
-
"7.soft_edge": [
|
291 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_softedge_fp16.safetensors", "name": "control_v11p_sd15_softedge_fp16.safetensors"},
|
292 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_softedge_fp16.yaml", "name": "control_v11p_sd15_softedge_fp16.yaml"}
|
293 |
-
],
|
294 |
-
"8.scribble": [
|
295 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_scribble_fp16.safetensors", "name": "control_v11p_sd15_scribble_fp16.safetensors"},
|
296 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_scribble_fp16.yaml", "name": "control_v11p_sd15_scribble_fp16.yaml"}
|
297 |
-
],
|
298 |
-
"9.segmentation": [
|
299 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_seg_fp16.safetensors", "name": "control_v11p_sd15_seg_fp16.safetensors"},
|
300 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_seg_fp16.yaml", "name": "control_v11p_sd15_seg_fp16.yaml"}
|
301 |
-
],
|
302 |
-
"10.shuffle": [
|
303 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors", "name": "control_v11e_sd15_shuffle_fp16.safetensors"},
|
304 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_shuffle_fp16.yaml", "name": "control_v11e_sd15_shuffle_fp16.yaml"}
|
305 |
-
],
|
306 |
-
"11.tile": [
|
307 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1e_sd15_tile_fp16.safetensors", "name": "control_v11f1e_sd15_tile_fp16.safetensors"},
|
308 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1e_sd15_tile_fp16.yaml", "name": "control_v11f1e_sd15_tile_fp16.yaml"}
|
309 |
-
],
|
310 |
-
"12.inpaint": [
|
311 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors", "name": "control_v11p_sd15_inpaint_fp16.safetensors"},
|
312 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_inpaint_fp16.yaml", "name": "control_v11p_sd15_inpaint_fp16.yaml"}
|
313 |
-
],
|
314 |
-
"13.instruct_p2p": [
|
315 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors", "name": "control_v11e_sd15_ip2p_fp16.safetensors"},
|
316 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_ip2p_fp16.yaml", "name": "control_v11e_sd15_ip2p_fp16.yaml"}
|
317 |
-
]
|
318 |
-
}
|
319 |
-
|
320 |
-
extension_repo = []
|
321 |
-
prefixes = {
|
322 |
-
# It's complicated, but supplementing has become easier
|
323 |
-
"model": [models_dir, "Model_url"],
|
324 |
-
"vae": [vaes_dir, "Vae_url"],
|
325 |
-
"lora": [loras_dir, "LoRA_url"],
|
326 |
-
"embed": [embeddings_dir, "Embedding_url"],
|
327 |
-
"extension": [extensions_dir, "Extensions_url"],
|
328 |
-
"control": [control_dir, "ControlNet_url"]
|
329 |
-
}
|
330 |
-
|
331 |
-
get_ipython().system('mkdir -p {models_dir} {vaes_dir} {loras_dir} {embeddings_dir} {extensions_dir} {control_dir}')
|
332 |
-
|
333 |
-
url = ""
|
334 |
-
ControlNet_url = ""
|
335 |
-
hf_token = optional_huggingface_token if optional_huggingface_token else "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"
|
336 |
-
user_header = f"\"Authorization: Bearer {hf_token}\""
|
337 |
-
|
338 |
-
''' main download code '''
|
339 |
-
|
340 |
-
def handle_manual(url):
|
341 |
-
original_url = url
|
342 |
-
url = url.split(':', 1)[1]
|
343 |
-
file_name = re.search(r'\[(.*?)\]', url)
|
344 |
-
file_name = file_name.group(1) if file_name else None
|
345 |
-
if file_name:
|
346 |
-
url = re.sub(r'\[.*?\]', '', url)
|
347 |
-
|
348 |
-
for prefix, (dir, _) in prefixes.items():
|
349 |
-
if original_url.startswith(f"{prefix}:"):
|
350 |
-
if prefix != "extension":
|
351 |
-
manual_download(url, dir, file_name=file_name)
|
352 |
-
else:
|
353 |
-
extension_repo.append((url, file_name))
|
354 |
-
|
355 |
-
def manual_download(url, dst_dir, file_name):
|
356 |
-
basename = url.split("/")[-1] if file_name is None else file_name
|
357 |
-
header_option = f"--header={user_header}"
|
358 |
-
|
359 |
-
print("\033[32m---"*45 + f"\n\033[33mURL: \033[34m{url}\n\033[33mSAVE DIR: \033[34m{dst_dir}\n\033[33mFILE NAME: \033[34m{file_name}\033[32m\n~~~\033[0m")
|
360 |
-
|
361 |
-
# I do it at my own risk..... Fucking CivitAi >:(
|
362 |
-
civitai_token = "62c0c5956b2f9defbd844d754000180b"
|
363 |
-
if 'civitai' in url and civitai_token:
|
364 |
-
url = f"{url}?token={civitai_token}"
|
365 |
-
|
366 |
-
# -- GDrive --
|
367 |
-
if 'drive.google' in url:
|
368 |
-
if 'folders' in url:
|
369 |
-
get_ipython().system('gdown --folder "{url}" -O {dst_dir} --fuzzy -c')
|
370 |
-
else:
|
371 |
-
if file_name:
|
372 |
-
get_ipython().system('gdown "{url}" -O {dst_dir}/{file_name} --fuzzy -c')
|
373 |
-
else:
|
374 |
-
get_ipython().system('gdown "{url}" -O {dst_dir} --fuzzy -c')
|
375 |
-
# -- Huggin Face --
|
376 |
-
elif 'huggingface' in url:
|
377 |
-
if '/blob/' in url:
|
378 |
-
url = url.replace('/blob/', '/resolve/')
|
379 |
-
if file_name:
|
380 |
-
get_ipython().system('aria2c {header_option} --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -c -j5 -x16 -s16 -k1M -d {dst_dir} -o {basename} {url}')
|
381 |
-
else:
|
382 |
-
parsed_link = f'\n{url}\n\tout={unquote(url.split("/")[-1])}'
|
383 |
-
get_ipython().system('echo -e "{parsed_link}" | aria2c {header_option} --console-log-level=error --summary-interval=10 -i- -j5 -x16 -s16 -k1M -c -d "{dst_dir}" -o {basename}')
|
384 |
-
# -- Other --
|
385 |
-
elif 'http' in url or 'magnet' in url:
|
386 |
-
if file_name:
|
387 |
-
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -o {file_name} {url}')
|
388 |
-
else:
|
389 |
-
parsed_link = '"{}"'.format(url)
|
390 |
-
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -Z {parsed_link}')
|
391 |
-
|
392 |
-
def download(url):
|
393 |
-
links_and_paths = url.split(',')
|
394 |
-
|
395 |
-
for link_or_path in links_and_paths:
|
396 |
-
link_or_path = link_or_path.strip()
|
397 |
-
if not link_or_path:
|
398 |
-
continue
|
399 |
-
if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):
|
400 |
-
handle_manual(link_or_path)
|
401 |
-
continue
|
402 |
-
|
403 |
-
url, dst_dir, file_name = link_or_path.split()
|
404 |
-
manual_download(url, dst_dir, file_name)
|
405 |
-
|
406 |
-
''' submodels - added urls '''
|
407 |
-
|
408 |
-
submodels = []
|
409 |
-
|
410 |
-
def add_submodels(selection, num_selection, model_dict, dst_dir):
|
411 |
-
if selection == "none":
|
412 |
-
return []
|
413 |
-
if selection == "ALL":
|
414 |
-
all_models = []
|
415 |
-
for models in model_dict.values():
|
416 |
-
all_models.extend(models)
|
417 |
-
selected_models = all_models
|
418 |
-
else:
|
419 |
-
selected_models = model_dict[selection]
|
420 |
-
selected_nums = map(int, num_selection.replace(',', '').split())
|
421 |
-
|
422 |
-
for num in selected_nums:
|
423 |
-
if 1 <= num <= len(model_dict):
|
424 |
-
name = list(model_dict)[num - 1]
|
425 |
-
selected_models.extend(model_dict[name])
|
426 |
-
|
427 |
-
unique_models = list({model['name']: model for model in selected_models}.values())
|
428 |
-
|
429 |
-
for model in unique_models:
|
430 |
-
model['dst_dir'] = dst_dir
|
431 |
-
|
432 |
-
return unique_models
|
433 |
-
|
434 |
-
submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model
|
435 |
-
submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae
|
436 |
-
submodels += add_submodels(controlnet, "" if controlnet == "ALL" else controlnet_Num, controlnet_list, control_dir) # controlnet
|
437 |
-
|
438 |
-
for submodel in submodels:
|
439 |
-
if not Inpainting_Model and "inpainting" in submodel['name']:
|
440 |
-
continue
|
441 |
-
url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
|
442 |
-
|
443 |
-
''' file.txt - added urls '''
|
444 |
-
|
445 |
-
unique_urls = []
|
446 |
-
|
447 |
-
def process_file_download(file_url):
|
448 |
-
if file_url.startswith("http"):
|
449 |
-
if "blob" in file_url:
|
450 |
-
file_url = file_url.replace("blob", "raw")
|
451 |
-
response = requests.get(file_url)
|
452 |
-
lines = response.text.split('\n')
|
453 |
-
else:
|
454 |
-
with open(file_url, 'r') as file:
|
455 |
-
lines = file.readlines()
|
456 |
-
|
457 |
-
current_tag = None
|
458 |
-
for line in lines:
|
459 |
-
if any(f'# {tag}' in line.lower() for tag in prefixes):
|
460 |
-
current_tag = next((tag for tag in prefixes if tag in line.lower()))
|
461 |
-
|
462 |
-
urls = [url.strip() for url in line.split(',')]
|
463 |
-
for url in urls:
|
464 |
-
if url.startswith("http") and url not in unique_urls:
|
465 |
-
globals()[prefixes[current_tag][1]] += ", " + url
|
466 |
-
unique_urls.append(url)
|
467 |
-
|
468 |
-
# fix all possible errors/options and function call
|
469 |
-
if custom_file_urls:
|
470 |
-
for custom_file_url in custom_file_urls.replace(',', '').split():
|
471 |
-
if not custom_file_url.endswith('.txt'):
|
472 |
-
custom_file_url += '.txt'
|
473 |
-
if not custom_file_url.startswith('http'):
|
474 |
-
if not custom_file_url.startswith(root_path):
|
475 |
-
custom_file_url = f'{root_path}/{custom_file_url}'
|
476 |
-
|
477 |
-
try:
|
478 |
-
process_file_download(custom_file_url)
|
479 |
-
except FileNotFoundError:
|
480 |
-
pass
|
481 |
-
|
482 |
-
# url prefixing
|
483 |
-
urls = [globals()[urls[1]] for urls in prefixes.values()]
|
484 |
-
for i, prefix in enumerate(prefixes):
|
485 |
-
if urls[i]:
|
486 |
-
prefixed_urls = [f"{prefix}:{url}" for url in urls[i].replace(',', '').split()]
|
487 |
-
if prefixed_urls:
|
488 |
-
url += ", ".join(prefixed_urls) + ", "
|
489 |
-
|
490 |
-
if detailed_download == "on":
|
491 |
-
print("\n\n\033[33m# ====== Detailed Download ====== #\n\033[0m")
|
492 |
-
download(url)
|
493 |
-
print("\n\033[33m# =============================== #\n\033[0m")
|
494 |
-
else:
|
495 |
-
with capture.capture_output() as cap:
|
496 |
-
download(url)
|
497 |
-
del cap
|
498 |
-
|
499 |
-
print("\r🏁 Download Complete!" + " "*15)
|
500 |
-
|
501 |
-
|
502 |
-
# Cleaning shit after downloading...
|
503 |
-
get_ipython().system('find {webui_path} \\( -type d \\( -name ".ipynb_checkpoints" -o -name ".aria2" \\) -o -type f -name "*.aria2" \\) -exec rm -r {{}} \\; >/dev/null 2>&1')
|
504 |
-
|
505 |
-
|
506 |
-
## Install of Custom extensions
|
507 |
-
if len(extension_repo) > 0:
|
508 |
-
print("✨ Installing custom extensions...", end='', flush=True)
|
509 |
-
with capture.capture_output() as cap:
|
510 |
-
for repo, repo_name in extension_repo:
|
511 |
-
if not repo_name:
|
512 |
-
repo_name = repo.split('/')[-1]
|
513 |
-
get_ipython().system('cd {extensions_dir} && git clone {repo} {repo_name} && cd {repo_name} && git fetch')
|
514 |
-
del cap
|
515 |
-
print(f"\r📦 Installed '{len(extension_repo)}', Custom extensions!")
|
516 |
-
|
517 |
-
|
518 |
-
## List Models and stuff
|
519 |
-
if detailed_download == "off":
|
520 |
-
print("\n\n\033[33mIf you don't see any downloaded files, enable the 'Detailed Downloads' feature in the widget.")
|
521 |
-
|
522 |
-
if any(not file.endswith('.txt') for file in os.listdir(models_dir)):
|
523 |
-
print("\n\033[33m➤ Models\033[0m")
|
524 |
-
get_ipython().system("find {models_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'")
|
525 |
-
if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):
|
526 |
-
print("\n\033[33m➤ VAEs\033[0m")
|
527 |
-
get_ipython().system("find {vaes_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'")
|
528 |
-
if any(not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file)) for file in os.listdir(embeddings_dir)):
|
529 |
-
print("\n\033[33m➤ Embeddings\033[0m")
|
530 |
-
get_ipython().system("find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'")
|
531 |
-
if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):
|
532 |
-
print("\n\033[33m➤ LoRAs\033[0m")
|
533 |
-
get_ipython().system("find {loras_dir}/ -mindepth 1 ! -name '*.keep' -printf '%f\\n'")
|
534 |
-
print(f"\n\033[33m➤ Extensions\033[0m")
|
535 |
-
get_ipython().system("find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'")
|
536 |
-
if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):
|
537 |
-
print("\n\033[33m➤ ControlNet\033[0m")
|
538 |
-
get_ipython().system("find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\(.*\\)_fp16\\.safetensors$/\\1/'")
|
539 |
-
|
540 |
-
|
541 |
-
# === OTHER ===
|
542 |
-
# Downlaod discord tags UmiWildcards
|
543 |
-
files_umi = [
|
544 |
-
"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/200_pan_gen.txt",
|
545 |
-
"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/150_bra_gen.txt"
|
546 |
-
]
|
547 |
-
save_dir_path = f"{webui_path}/extensions/Umi-AI-Wildcards/wildcards/discord"
|
548 |
-
|
549 |
-
with capture.capture_output() as cap:
|
550 |
-
for file in files_umi:
|
551 |
-
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {save_dir_path} {file}')
|
552 |
-
del cap
|
553 |
-
|
554 |
-
|
555 |
-
# === ONLY SAGEMAKER ===
|
556 |
-
if env == "SageMaker Studio Lab":
|
557 |
-
with capture.capture_output() as cap:
|
558 |
-
get_ipython().system('rm -rf /home/studio-lab-user/.conda/envs/studiolab-safemode')
|
559 |
-
get_ipython().system('rm -rf /home/studio-lab-user/.conda/envs/sagemaker-distribution')
|
560 |
-
get_ipython().system('rm -rf /home/studio-lab-user/.conda/pkgs/cache')
|
561 |
-
get_ipython().system('pip cache purge')
|
562 |
-
get_ipython().system('rm -rf ~/.cache')
|
563 |
-
del cap
|
564 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/python/en/launch_en.py
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
##~ LAUNCH CODE | BY: ANXETY ~##
|
2 |
-
|
3 |
-
import os
|
4 |
-
import re
|
5 |
-
import time
|
6 |
-
import json
|
7 |
-
import requests
|
8 |
-
from datetime import timedelta
|
9 |
-
|
10 |
-
|
11 |
-
# ================= DETECT ENV =================
|
12 |
-
def detect_environment():
|
13 |
-
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
14 |
-
environments = {
|
15 |
-
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
16 |
-
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
17 |
-
'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', "/home/studio-lab-user/content")
|
18 |
-
}
|
19 |
-
|
20 |
-
for env_var, (environment, path) in environments.items():
|
21 |
-
if env_var in os.environ:
|
22 |
-
return environment, path, free_plan
|
23 |
-
|
24 |
-
env, root_path, free_plan = detect_environment()
|
25 |
-
webui_path = f"{root_path}/sdw"
|
26 |
-
# ----------------------------------------------
|
27 |
-
|
28 |
-
def load_settings():
|
29 |
-
SETTINGS_FILE = f'{root_path}/settings.json'
|
30 |
-
if os.path.exists(SETTINGS_FILE):
|
31 |
-
with open(SETTINGS_FILE, 'r') as f:
|
32 |
-
settings = json.load(f)
|
33 |
-
return settings
|
34 |
-
|
35 |
-
settings = load_settings()
|
36 |
-
ngrok_token = settings['ngrok_token']
|
37 |
-
zrok_token = settings['zrok_token']
|
38 |
-
commandline_arguments = settings['commandline_arguments']
|
39 |
-
|
40 |
-
|
41 |
-
# ======================== TUNNEL ========================
|
42 |
-
if env != "SageMaker Studio Lab":
|
43 |
-
import cloudpickle as pickle
|
44 |
-
|
45 |
-
def get_public_ip(version='ipv4'):
|
46 |
-
try:
|
47 |
-
url = f'https://api64.ipify.org?format=json&{version}=true'
|
48 |
-
response = requests.get(url)
|
49 |
-
data = response.json()
|
50 |
-
public_ip = data['ip']
|
51 |
-
return public_ip
|
52 |
-
except Exception as e:
|
53 |
-
print(f"Error getting public {version} address:", e)
|
54 |
-
|
55 |
-
public_ipv4 = get_public_ip(version='ipv4')
|
56 |
-
|
57 |
-
tunnel_class = pickle.load(open(f"{root_path}/new_tunnel", "rb"), encoding="utf-8")
|
58 |
-
tunnel_port= 1769
|
59 |
-
tunnel = tunnel_class(tunnel_port)
|
60 |
-
tunnel.add_tunnel(command="cl tunnel --url localhost:{port}", name="cl", pattern=re.compile(r"[\w-]+\.trycloudflare\.com"))
|
61 |
-
tunnel.add_tunnel(command="lt --port {port}", name="lt", pattern=re.compile(r"[\w-]+\.loca\.lt"), note="Password : " + "\033[32m" + public_ipv4 + "\033[0m" + " rerun cell if 404 error.")
|
62 |
-
|
63 |
-
''' add zrok tunnel '''
|
64 |
-
if zrok_token:
|
65 |
-
get_ipython().system('zrok enable {zrok_token} &> /dev/null')
|
66 |
-
tunnel.add_tunnel(command="zrok share public http://localhost:{port}/ --headless", name="zrok", pattern=re.compile(r"[\w-]+\.share\.zrok\.io"))
|
67 |
-
# ======================== TUNNEL ========================
|
68 |
-
|
69 |
-
|
70 |
-
# automatic fixing path V2
|
71 |
-
get_ipython().system('sed -i \'s#"tagger_hf_cache_dir": ".*models/interrogators"#"tagger_hf_cache_dir": "{root_path}/sdw/models/interrogators"#\' {webui_path}/config.json')
|
72 |
-
get_ipython().system('sed -i \'s#"additional_networks_extra_lora_path": ".*models/Lora/"#"additional_networks_extra_lora_path": "{root_path}/sdw/models/Lora/"#\' {webui_path}/config.json')
|
73 |
-
# ---
|
74 |
-
get_ipython().system('sed -i \'s/"sd_checkpoint_hash": ".*"/"sd_checkpoint_hash": ""/g; s/"sd_model_checkpoint": ".*"/"sd_model_checkpoint": ""/g; s/"sd_vae": ".*"/"sd_vae": "None"/g\' {webui_path}/config.json')
|
75 |
-
|
76 |
-
|
77 |
-
if env != "SageMaker Studio Lab":
|
78 |
-
with tunnel:
|
79 |
-
get_ipython().run_line_magic('cd', '{webui_path}')
|
80 |
-
commandline_arguments += f" --port=1769"
|
81 |
-
|
82 |
-
if ngrok_token:
|
83 |
-
commandline_arguments += ' --ngrok ' + ngrok_token
|
84 |
-
if env != "Google Colab":
|
85 |
-
commandline_arguments += f" --encrypt-pass=1769"
|
86 |
-
|
87 |
-
get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
|
88 |
-
|
89 |
-
start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
|
90 |
-
time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
|
91 |
-
print(f"\n⌚️ \033[0mYou have been conducting this session for - \033[33m{time_since_start}\033[0m\n\n")
|
92 |
-
|
93 |
-
else:
|
94 |
-
if ngrok_token:
|
95 |
-
get_ipython().run_line_magic('cd', '{webui_path}')
|
96 |
-
|
97 |
-
commandline_arguments += ' --ngrok ' + ngrok_token
|
98 |
-
|
99 |
-
get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
|
100 |
-
|
101 |
-
start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
|
102 |
-
time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
|
103 |
-
print(f"\n⌚️ \033[0mYou have been conducting this session for - \033[33m{time_since_start}\033[0m\n\n")
|
104 |
-
|
105 |
-
else:
|
106 |
-
print("Oops... I think you forgot to insert the token `ngrok`..... go back to widgets and insert it to start webui... no way without it :/\nYou can get the token here:\n\nhttps://dashboard.ngrok.com/get-started/your-authtoken")
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/python/en/widgets_en.py
DELETED
@@ -1,592 +0,0 @@
|
|
1 |
-
##~ WIDGET CODE | BY: ANXETY ~##
|
2 |
-
|
3 |
-
import os
|
4 |
-
import json
|
5 |
-
import time
|
6 |
-
import ipywidgets as widgets
|
7 |
-
from ipywidgets import widgets, Layout, Label, Button, VBox, HBox
|
8 |
-
from IPython.display import display, HTML, Javascript, clear_output
|
9 |
-
|
10 |
-
|
11 |
-
# ================= DETECT ENV =================
|
12 |
-
def detect_environment():
|
13 |
-
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
14 |
-
environments = {
|
15 |
-
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
16 |
-
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
17 |
-
'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', "/home/studio-lab-user/content")
|
18 |
-
}
|
19 |
-
|
20 |
-
for env_var, (environment, path) in environments.items():
|
21 |
-
if env_var in os.environ:
|
22 |
-
return environment, path, free_plan
|
23 |
-
|
24 |
-
env, root_path, free_plan = detect_environment()
|
25 |
-
webui_path = f"{root_path}/sdw"
|
26 |
-
|
27 |
-
get_ipython().system('mkdir -p {root_path}')
|
28 |
-
# ----------------------------------------------
|
29 |
-
|
30 |
-
|
31 |
-
# ==================== CSS JS ====================
|
32 |
-
# custom background images (test)
|
33 |
-
import argparse
|
34 |
-
parser = argparse.ArgumentParser(description='This script processes an background image.')
|
35 |
-
parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')
|
36 |
-
parser.add_argument('-o', '--opacity', type=float, help='Opacity level for the image, between 0 and 1', metavar='', default=0.3)
|
37 |
-
parser.add_argument('-b', '--blur', type=str, help='Blur level for the image', metavar='', default=0)
|
38 |
-
parser.add_argument('-y', type=int, help='Y coordinate for the image in px', metavar='', default=0)
|
39 |
-
parser.add_argument('-x', type=int, help='X coordinate for the image in px', metavar='', default=0)
|
40 |
-
parser.add_argument('-s', '--scale', type=int, help='Scale image in %%', metavar='', default=100)
|
41 |
-
parser.add_argument('-m', '--mode', type=str, help='Specify "no-repeat" so that the image pattern is not repeated.', metavar='', default='repeat')
|
42 |
-
parser.add_argument('-t', '--transparent', action='store_true', help='Flag to exclude z-index from CSS. Makes fields transparent')
|
43 |
-
args = parser.parse_args()
|
44 |
-
# ---
|
45 |
-
url_img, opacity_img, blur_img, y_img, x_img, scale_img, mode_img = args.image, args.opacity, args.blur, args.y, args.x, args.scale, args.mode
|
46 |
-
|
47 |
-
# WTF COLAB - WHAT THE FUCK IS THE DIFFERENCE OF 40 PIXELS!?!?!?
|
48 |
-
fix_heigh_img = "-780px"
|
49 |
-
if env == "Google Colab": # betrayal..
|
50 |
-
fix_heigh_img = "-740px"
|
51 |
-
|
52 |
-
container_background = f'''
|
53 |
-
<style>
|
54 |
-
:root {{
|
55 |
-
--img_background: url({url_img});
|
56 |
-
--img_opacity: {opacity_img};
|
57 |
-
--img_blur: {blur_img}px;
|
58 |
-
--image_y: {y_img}px;
|
59 |
-
--image_x: {x_img}px;
|
60 |
-
--img_scale: {scale_img}%;
|
61 |
-
--img_mode: {mode_img};
|
62 |
-
--img_height_dif: {fix_heigh_img}
|
63 |
-
}}
|
64 |
-
|
65 |
-
.widget-dropdown select,
|
66 |
-
.widget-text input[type="text"] {{
|
67 |
-
height: 30px;
|
68 |
-
background-color: #1c1c1c;
|
69 |
-
border: 1px solid #262626;
|
70 |
-
border-radius: 10px;
|
71 |
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
72 |
-
transition: all 0.3s ease-in-out;
|
73 |
-
'''
|
74 |
-
|
75 |
-
if not args.transparent:
|
76 |
-
container_background += " z-index: 1;\n</style>\n"
|
77 |
-
|
78 |
-
display(HTML(container_background))
|
79 |
-
# ---
|
80 |
-
|
81 |
-
CSS = '''
|
82 |
-
<style>
|
83 |
-
/* General Styles */
|
84 |
-
.header {
|
85 |
-
font-family: cursive;
|
86 |
-
font-size: 20px;
|
87 |
-
font-weight: bold;
|
88 |
-
color: #ff8cee;
|
89 |
-
margin-bottom: 15px;
|
90 |
-
user-select: none;
|
91 |
-
cursor: default;
|
92 |
-
display: inline-block;
|
93 |
-
}
|
94 |
-
|
95 |
-
hr {
|
96 |
-
border-color: grey;
|
97 |
-
background-color: grey;
|
98 |
-
opacity: 0.25;
|
99 |
-
}
|
100 |
-
|
101 |
-
a {
|
102 |
-
text-decoration: none;
|
103 |
-
color: inherit;
|
104 |
-
}
|
105 |
-
|
106 |
-
|
107 |
-
/* Container style */
|
108 |
-
|
109 |
-
.container {
|
110 |
-
position: relative;
|
111 |
-
background-color: #232323;
|
112 |
-
width: 1080px;
|
113 |
-
padding: 10px 15px;
|
114 |
-
border-radius: 15px;
|
115 |
-
box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
|
116 |
-
margin-bottom: 5px;
|
117 |
-
overflow: hidden;
|
118 |
-
}
|
119 |
-
|
120 |
-
.container::after {
|
121 |
-
position: absolute;
|
122 |
-
top: 5px;
|
123 |
-
right: 10px;
|
124 |
-
content: "ANXETY";
|
125 |
-
font-weight: bold;
|
126 |
-
font-size: 24px;
|
127 |
-
color: rgba(0, 0, 0, 0.2);
|
128 |
-
}
|
129 |
-
|
130 |
-
/* background img */
|
131 |
-
.container::before {
|
132 |
-
content: "";
|
133 |
-
position: absolute;
|
134 |
-
top: 0;
|
135 |
-
left: 0;
|
136 |
-
right: 0;
|
137 |
-
bottom: 0;
|
138 |
-
background-image: var(--img_background);
|
139 |
-
background-size: var(--img_scale);
|
140 |
-
background-repeat: var(--img_mode);
|
141 |
-
opacity: var(--img_opacity);
|
142 |
-
mix-blend-mode: screen;
|
143 |
-
pointer-events: none;
|
144 |
-
filter: blur(var(--img_blur));
|
145 |
-
}
|
146 |
-
|
147 |
-
.image_1::before {
|
148 |
-
background-position: var(--image_x) calc(-120px - var(--image_y));
|
149 |
-
}
|
150 |
-
.image_2::before {
|
151 |
-
background-position: var(--image_x) calc(-290px - var(--image_y));
|
152 |
-
}
|
153 |
-
.image_3::before {
|
154 |
-
background-position: var(--image_x) calc(-430px - var(--image_y));
|
155 |
-
}
|
156 |
-
.image_4::before {
|
157 |
-
background-position: var(--image_x) calc(var(--img_height_dif) - var(--image_y));
|
158 |
-
}
|
159 |
-
|
160 |
-
.container_custom_downlad {
|
161 |
-
height: 55px;
|
162 |
-
transition: all 0.5s;
|
163 |
-
}
|
164 |
-
|
165 |
-
.container_custom_downlad.expanded {
|
166 |
-
height: 270px;
|
167 |
-
}
|
168 |
-
|
169 |
-
|
170 |
-
/* Element text style */
|
171 |
-
|
172 |
-
.widget-html,
|
173 |
-
.widget-button,
|
174 |
-
.widget-text label,
|
175 |
-
.widget-checkbox label,
|
176 |
-
.widget-dropdown label,
|
177 |
-
.widget-dropdown select,
|
178 |
-
.widget-text input[type="text"] {
|
179 |
-
font-family: cursive;
|
180 |
-
font-size: 14px;
|
181 |
-
color: white !important;
|
182 |
-
user-select: none;
|
183 |
-
}
|
184 |
-
|
185 |
-
.widget-text input[type="text"]::placeholder {
|
186 |
-
color: grey;
|
187 |
-
}
|
188 |
-
|
189 |
-
|
190 |
-
/* Input field styles */
|
191 |
-
/*
|
192 |
-
.widget-dropdown select,
|
193 |
-
.widget-text input[type="text"] {
|
194 |
-
height: 30px;
|
195 |
-
background-color: #1c1c1c;
|
196 |
-
border: 1px solid #262626;
|
197 |
-
border-radius: 10px;
|
198 |
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
199 |
-
transition: all 0.3s ease-in-out;
|
200 |
-
}
|
201 |
-
*/
|
202 |
-
|
203 |
-
.widget-dropdown select:focus,
|
204 |
-
.widget-text input[type="text"]:focus {
|
205 |
-
border-color: #006ee5;
|
206 |
-
}
|
207 |
-
|
208 |
-
.widget-dropdown select:hover,
|
209 |
-
.widget-text input[type="text"]:hover {
|
210 |
-
transform: scale(1.003);
|
211 |
-
background-color: #262626;
|
212 |
-
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
|
213 |
-
}
|
214 |
-
|
215 |
-
|
216 |
-
/* Slider Checkbox style */
|
217 |
-
|
218 |
-
.widget-checkbox input[type="checkbox"] {
|
219 |
-
appearance: none;
|
220 |
-
position: relative;
|
221 |
-
top: 4px; /* Why is he taller?! */
|
222 |
-
width: 40px;
|
223 |
-
height: 20px;
|
224 |
-
border: none;
|
225 |
-
border-radius: 10px;
|
226 |
-
background-color: #20b2aa;
|
227 |
-
cursor: pointer;
|
228 |
-
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
|
229 |
-
transition: background-color 0.3s ease;
|
230 |
-
}
|
231 |
-
.widget-checkbox input[type="checkbox"]:checked {
|
232 |
-
background-color: #2196F3;
|
233 |
-
}
|
234 |
-
|
235 |
-
.widget-checkbox input[type="checkbox"]:before {
|
236 |
-
content: '';
|
237 |
-
position: absolute;
|
238 |
-
top: 50%;
|
239 |
-
left: 3px;
|
240 |
-
width: 16px;
|
241 |
-
height: 16px;
|
242 |
-
border-radius: inherit;
|
243 |
-
background-color: white;
|
244 |
-
box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
|
245 |
-
transform: translateY(-50%);
|
246 |
-
transition: left 0.3s ease;
|
247 |
-
}
|
248 |
-
.widget-checkbox input[type="checkbox"]:checked:before {
|
249 |
-
left: 21px;
|
250 |
-
}
|
251 |
-
|
252 |
-
|
253 |
-
/* Button styles */
|
254 |
-
|
255 |
-
.button_save {
|
256 |
-
font-size: 15px;
|
257 |
-
font-weight: bold;
|
258 |
-
width: 120px;
|
259 |
-
height: 35px;
|
260 |
-
border-radius: 15px;
|
261 |
-
background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
|
262 |
-
background-size: 200% 200%;
|
263 |
-
background-position: left bottom;
|
264 |
-
transition: background 0.5s ease-in-out, transform 0.3s ease;
|
265 |
-
}
|
266 |
-
|
267 |
-
.button_save:hover {
|
268 |
-
cursor: pointer;
|
269 |
-
background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);
|
270 |
-
background-size: 200% 200%;
|
271 |
-
background-position: right bottom;
|
272 |
-
transform: translateY(1px);
|
273 |
-
}
|
274 |
-
|
275 |
-
.button_ngrok {
|
276 |
-
font-size: 12px;
|
277 |
-
height: 30px;
|
278 |
-
border-radius: 10px;
|
279 |
-
padding: 1px 12px;
|
280 |
-
background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
|
281 |
-
background-size: 200% 200%;
|
282 |
-
background-position: left bottom;
|
283 |
-
transition: background 0.5s ease-in-out, transform 0.3s ease;
|
284 |
-
white-space: nowrap;
|
285 |
-
}
|
286 |
-
|
287 |
-
.button_ngrok:hover {
|
288 |
-
cursor: pointer;
|
289 |
-
background-image: radial-gradient(circle at top left, purple 10%, #1D94BB 90%);
|
290 |
-
background-size: 200% 200%;
|
291 |
-
background-position: right bottom;
|
292 |
-
transform: translateY(1px);
|
293 |
-
}
|
294 |
-
|
295 |
-
.button_save:active,
|
296 |
-
.button_ngrok:active {
|
297 |
-
filter: brightness(0.75) !important;
|
298 |
-
}
|
299 |
-
|
300 |
-
/* Removes ugly stroke from widget buttons. */
|
301 |
-
.jupyter-widgets.lm-Widget:focus {
|
302 |
-
outline: none;
|
303 |
-
}
|
304 |
-
|
305 |
-
|
306 |
-
/* Popup style of `FAQ` window */
|
307 |
-
|
308 |
-
.info {
|
309 |
-
position: absolute;
|
310 |
-
top: -5px;
|
311 |
-
right: 95px;
|
312 |
-
color: grey;
|
313 |
-
font-family: cursive;
|
314 |
-
font-size: 14px;
|
315 |
-
font-weight: normal;
|
316 |
-
user-select: none;
|
317 |
-
pointer-events: none;
|
318 |
-
opacity: 0;
|
319 |
-
transition: opacity 0.3s ease-in-out;
|
320 |
-
display: inline-block;
|
321 |
-
}
|
322 |
-
|
323 |
-
.popup {
|
324 |
-
position: absolute;
|
325 |
-
top: 120px;
|
326 |
-
z-index: 999;
|
327 |
-
width: auto;
|
328 |
-
padding: 10px;
|
329 |
-
text-align: center;
|
330 |
-
background-color: rgba(255, 255, 255, 0.05);
|
331 |
-
backdrop-filter: blur(20px);
|
332 |
-
border: 1px solid rgba(255, 255, 255, 0.45);
|
333 |
-
border-radius: 8px;
|
334 |
-
box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
|
335 |
-
opacity: 0;
|
336 |
-
color: #fff;
|
337 |
-
font-size: 16px;
|
338 |
-
font-family: cursive;
|
339 |
-
user-select: none;
|
340 |
-
cursor: default;
|
341 |
-
pointer-events: none;
|
342 |
-
transform: rotate(-5deg);
|
343 |
-
transition: top 0.3s ease-in-out, opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
|
344 |
-
}
|
345 |
-
|
346 |
-
.sample {
|
347 |
-
display: inline-block;
|
348 |
-
margin-top: 25px;
|
349 |
-
padding: 10px 100px;
|
350 |
-
background-color: rgba(255, 255, 255, 0.2);
|
351 |
-
color: #c6e2ff;
|
352 |
-
border: 2px solid rgba(255, 255, 255, 0.2);
|
353 |
-
border-radius: 8px;
|
354 |
-
box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), inset 0 0 25px rgba(255, 255, 255, 0.2);
|
355 |
-
}
|
356 |
-
|
357 |
-
.info.showed {
|
358 |
-
opacity: 1;
|
359 |
-
pointer-events: auto;
|
360 |
-
}
|
361 |
-
|
362 |
-
.info:hover + .popup {
|
363 |
-
top: 35px;
|
364 |
-
opacity: 1;
|
365 |
-
pointer-events: initial;
|
366 |
-
transform: rotate(0deg);
|
367 |
-
}
|
368 |
-
|
369 |
-
|
370 |
-
/* Animation of elements */
|
371 |
-
|
372 |
-
.container,
|
373 |
-
.button_save {
|
374 |
-
animation-name: showedWidgets;
|
375 |
-
animation-duration: 1s;
|
376 |
-
animation-fill-mode: forwards;
|
377 |
-
}
|
378 |
-
|
379 |
-
.container.hide,
|
380 |
-
.button_save.hide {
|
381 |
-
animation-name: hideWidgets;
|
382 |
-
animation-duration: 0.5s;
|
383 |
-
animation-fill-mode: forwards;
|
384 |
-
}
|
385 |
-
|
386 |
-
@keyframes showedWidgets {
|
387 |
-
0% {
|
388 |
-
transform: translate3d(-65%, 15%, 0) scale(0) rotate(15deg);
|
389 |
-
filter: blur(25px) grayscale(1) brightness(0.3);
|
390 |
-
opacity: 0;
|
391 |
-
}
|
392 |
-
100% {
|
393 |
-
transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
|
394 |
-
filter: blur(0) grayscale(0) brightness(1);
|
395 |
-
opacity: 1;
|
396 |
-
}
|
397 |
-
}
|
398 |
-
|
399 |
-
@keyframes hideWidgets {
|
400 |
-
0% {
|
401 |
-
transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);
|
402 |
-
filter: blur(0) grayscale(0) brightness(1);
|
403 |
-
opacity: 1;
|
404 |
-
}
|
405 |
-
100% {
|
406 |
-
transform: translate3d(0, 5%, 0) scale(0.9) rotate3d(1, 0, 0, 90deg);
|
407 |
-
filter: blur(15px) grayscale(1) brightness(0.5);
|
408 |
-
opacity: 0;
|
409 |
-
}
|
410 |
-
}
|
411 |
-
</style>
|
412 |
-
|
413 |
-
<!-- TOGGLE 'CustomDL' SCRIPT -->
|
414 |
-
<script>
|
415 |
-
function toggleContainer() {
|
416 |
-
let downloadContainer = document.querySelector('.container_custom_downlad');
|
417 |
-
let info = document.querySelector('.info');
|
418 |
-
|
419 |
-
downloadContainer.classList.toggle('expanded');
|
420 |
-
info.classList.toggle('showed');
|
421 |
-
}
|
422 |
-
</script>
|
423 |
-
'''
|
424 |
-
|
425 |
-
display(HTML(CSS))
|
426 |
-
# ==================== CSS JS ====================
|
427 |
-
|
428 |
-
|
429 |
-
# ==================== WIDGETS ====================
|
430 |
-
# --- global widgets ---
|
431 |
-
style = {'description_width': 'initial'}
|
432 |
-
layout = widgets.Layout(min_width='1047px')
|
433 |
-
|
434 |
-
HR = widgets.HTML('<hr>')
|
435 |
-
|
436 |
-
# --- MODEL ---
|
437 |
-
model_header = widgets.HTML('<div class="header">Model Selection<div>')
|
438 |
-
model_options = ['none',
|
439 |
-
'1.Anime (by XpucT) + INP',
|
440 |
-
'2.BluMix [Anime] [V7]',
|
441 |
-
'3.Cetus-Mix [Anime] [V4] + INP',
|
442 |
-
'4.Counterfeit [Anime] [V3] + INP',
|
443 |
-
'5.CuteColor [Anime] [V3]',
|
444 |
-
'6.Dark-Sushi-Mix [Anime]',
|
445 |
-
'7.Deliberate [Realism] [V6] + INP',
|
446 |
-
'8.Meina-Mix [Anime] [V11] + INP',
|
447 |
-
'9.Mix-Pro [Anime] [V4] + INP']
|
448 |
-
# ---
|
449 |
-
Model_widget = widgets.Dropdown(options=model_options, value='4.Counterfeit [Anime] [V3] + INP', description='Model:', style=style, layout=layout)
|
450 |
-
Model_Num_widget = widgets.Text(description='Model Number:', placeholder='Enter the model numbers to be downloaded using comma/space.', style=style, layout=layout)
|
451 |
-
Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Models', style=style)
|
452 |
-
|
453 |
-
''' Display Model'''
|
454 |
-
all_model_box = widgets.VBox([model_header, Model_widget, Model_Num_widget, Inpainting_Model_widget]).add_class("container").add_class("image_1")
|
455 |
-
display(all_model_box)
|
456 |
-
|
457 |
-
# --- VAE ---
|
458 |
-
vae_header = widgets.HTML('<div class="header" >VAE Selection</div>')
|
459 |
-
vae_options = ['none',
|
460 |
-
'1.Anime.vae',
|
461 |
-
'2.Anything.vae',
|
462 |
-
'3.Blessed2.vae',
|
463 |
-
'4.ClearVae.vae',
|
464 |
-
'5.WD.vae']
|
465 |
-
Vae_widget = widgets.Dropdown(options=vae_options, value='3.Blessed2.vae', description='Vae:', style=style, layout=layout)
|
466 |
-
Vae_Num_widget = widgets.Text(description='Vae Number:', placeholder='Enter the vae numbers to be downloaded using comma/space.', style=style, layout=layout)
|
467 |
-
|
468 |
-
''' Display Vae'''
|
469 |
-
all_vae_box= widgets.VBox([vae_header, Vae_widget, Vae_Num_widget]).add_class("container").add_class("image_2")
|
470 |
-
display(all_vae_box)
|
471 |
-
|
472 |
-
# --- ADDITIONAL ---
|
473 |
-
additional_header = widgets.HTML('<div class="header">Additional</div>')
|
474 |
-
latest_webui_widget = widgets.Checkbox(value=True, description='Update WebUI', style=style)
|
475 |
-
latest_exstensions_widget = widgets.Checkbox(value=True, description='Update Extensions', style=style)
|
476 |
-
detailed_download_widget = widgets.Dropdown(options=['off', 'on'], value='off', description='Detailed Download:', style=style)
|
477 |
-
latest_changes_widget = HBox([latest_webui_widget, latest_exstensions_widget, detailed_download_widget], layout=widgets.Layout(justify_content='space-between'))
|
478 |
-
controlnet_options = ['none', 'ALL', '1.canny',
|
479 |
-
'2.openpose', '3.depth',
|
480 |
-
'4.normal_map', '5.mlsd',
|
481 |
-
'6.lineart', '7.soft_edge',
|
482 |
-
'8.scribble', '9.segmentation',
|
483 |
-
'10.shuffle', '11.tile',
|
484 |
-
'12.inpaint', '13.instruct_p2p']
|
485 |
-
# ---
|
486 |
-
controlnet_widget = widgets.Dropdown(options=controlnet_options, value='none', description='ControlNet:', style=style, layout=layout)
|
487 |
-
controlnet_Num_widget = widgets.Text(description='ControlNet Number:', placeholder='Enter the ControlNet model numbers to be downloaded using comma/space.', style=style, layout=layout)
|
488 |
-
commit_hash_widget = widgets.Text(description='Commit Hash:', style=style, layout=layout)
|
489 |
-
optional_huggingface_token_widget = widgets.Text(description='HuggingFace Token:', style=style, layout=layout)
|
490 |
-
ngrok_token_widget = widgets.Text(description='Ngrok Token:', style=style, layout=widgets.Layout(width='1047px'))
|
491 |
-
ngrock_button = widgets.HTML('<a href="https://dashboard.ngrok.com/get-started/your-authtoken" target="_blank">Get Ngrok Token</a>').add_class("button_ngrok")
|
492 |
-
ngrok_widget = widgets.HBox([ngrok_token_widget, ngrock_button], style=style, layout=layout)
|
493 |
-
zrok_token_widget = widgets.Text(description='Zrok Token:', style=style, layout=widgets.Layout(width='1047px'))
|
494 |
-
zrok_button = widgets.HTML('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Reg Zrok Token</a>').add_class("button_ngrok")
|
495 |
-
zrok_widget = widgets.HBox([zrok_token_widget, zrok_button], style=style, layout=layout)
|
496 |
-
# ---
|
497 |
-
commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
|
498 |
-
commandline_arguments_widget = widgets.Text(description='Arguments:', value=commandline_arguments_options, style=style, layout=layout)
|
499 |
-
|
500 |
-
''' Display Additional'''
|
501 |
-
additional_widget_list = [additional_header, latest_changes_widget, HR, controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, zrok_widget, HR, commandline_arguments_widget]
|
502 |
-
if free_plan and env == "Google Colab": # remove ngrok from colab
|
503 |
-
additional_widget_list.remove(ngrok_widget)
|
504 |
-
if env == "SageMaker Studio Lab": # remove zrok from sagemaker
|
505 |
-
additional_widget_list.remove(zrok_widget)
|
506 |
-
# ```
|
507 |
-
all_additional_box = widgets.VBox(additional_widget_list).add_class("container").add_class("image_3")
|
508 |
-
display(all_additional_box)
|
509 |
-
|
510 |
-
# --- CUSTOM DOWNLOAD ---
|
511 |
-
custom_download_header_popup = widgets.HTML('''
|
512 |
-
<style>
|
513 |
-
/* Term Colors */
|
514 |
-
.sample_label {color: #dbafff;}
|
515 |
-
.braces {color: #ffff00;}
|
516 |
-
.extension {color: #eb934b;}
|
517 |
-
.file_name {color: #ffffd8;}
|
518 |
-
</style>
|
519 |
-
|
520 |
-
<div class="header" style="cursor: pointer;" onclick="toggleContainer()">Custom Download</div>
|
521 |
-
<!-- PopUp Window -->
|
522 |
-
<div class="info">INFO</div>
|
523 |
-
<div class="popup">
|
524 |
-
Separate multiple URLs with a comma/space. For a <span class="file_name">custom name</span> file/extension, specify it with <span class="braces">[]</span>
|
525 |
-
after the URL without spaces.
|
526 |
-
<span style="color: #ff9999">For files, be sure to specify</span> - <span class="extension">Filename Extension.</span>
|
527 |
-
<div class="sample">
|
528 |
-
<span class="sample_label">Example for File:</span>
|
529 |
-
https://civitai.com/api/download/models/229782<span class="braces">[</span><span class="file_name">Detailer</span><span class="extension">.safetensors</span><span class="braces">]</span>
|
530 |
-
<br>
|
531 |
-
<span class="sample_label">Example for Extension:</span>
|
532 |
-
https://github.com/hako-mikan/sd-webui-regional-prompter<span class="braces">[</span><span class="file_name">Regional-Prompter</span><span class="braces">]</span>
|
533 |
-
</div>
|
534 |
-
</div>
|
535 |
-
''')
|
536 |
-
# ---
|
537 |
-
Model_url_widget = widgets.Text(description='Model:', style=style, layout=layout)
|
538 |
-
Vae_url_widget = widgets.Text(description='Vae:', style=style, layout=layout)
|
539 |
-
LoRA_url_widget = widgets.Text(description='LoRa:', style=style, layout=layout)
|
540 |
-
Embedding_url_widget = widgets.Text(description='Embedding:', style=style, layout=layout)
|
541 |
-
Extensions_url_widget = widgets.Text(description='Extensions:', style=style, layout=layout)
|
542 |
-
custom_file_urls_widget = widgets.Text(description='File (txt):', style=style, layout=layout)
|
543 |
-
|
544 |
-
''' Display CustomDl'''
|
545 |
-
all_custom_box = widgets.VBox([
|
546 |
-
custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget
|
547 |
-
]).add_class("container").add_class("image_4").add_class("container_custom_downlad")
|
548 |
-
display(all_custom_box)
|
549 |
-
|
550 |
-
# --- Save Button ---
|
551 |
-
save_button = widgets.Button(description='Save').add_class("button_save")
|
552 |
-
display(save_button)
|
553 |
-
|
554 |
-
|
555 |
-
# ============ Load / Save - Settings V2 ============
|
556 |
-
SETTINGS_FILE = f'{root_path}/settings.json'
|
557 |
-
|
558 |
-
settings_keys = [
|
559 |
-
'Model', 'Model_Num', 'Inpainting_Model',
|
560 |
-
'Vae', 'Vae_Num',
|
561 |
-
'latest_webui', 'latest_exstensions', 'detailed_download',
|
562 |
-
'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
|
563 |
-
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
564 |
-
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'
|
565 |
-
]
|
566 |
-
|
567 |
-
def save_settings():
|
568 |
-
settings = {key: globals()[f"{key}_widget"].value for key in settings_keys}
|
569 |
-
with open(SETTINGS_FILE, 'w') as f:
|
570 |
-
json.dump(settings, f)
|
571 |
-
|
572 |
-
def load_settings():
|
573 |
-
if os.path.exists(SETTINGS_FILE):
|
574 |
-
with open(SETTINGS_FILE, 'r') as f:
|
575 |
-
settings = json.load(f)
|
576 |
-
for key in settings_keys:
|
577 |
-
globals()[f"{key}_widget"].value = settings.get(key)
|
578 |
-
|
579 |
-
def save_data(button):
|
580 |
-
save_settings()
|
581 |
-
|
582 |
-
# --- uhh - hide... ---
|
583 |
-
widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]
|
584 |
-
for widget in widgets_list:
|
585 |
-
widget.add_class("hide")
|
586 |
-
time.sleep(0.5)
|
587 |
-
|
588 |
-
widgets.Widget.close_all()
|
589 |
-
|
590 |
-
settings = load_settings()
|
591 |
-
save_button.on_click(save_data)
|
592 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/python/ru/auto-cleaner_ru.py
DELETED
@@ -1,353 +0,0 @@
|
|
1 |
-
##~ AutoCleaner V3.6 CODE | BY: ANXETY ~##
|
2 |
-
|
3 |
-
# --change log--
|
4 |
-
"""
|
5 |
-
V3.6 | 13.03.24
|
6 |
-
Fixed selection window
|
7 |
-
Dynamic update of memory display
|
8 |
-
"""
|
9 |
-
|
10 |
-
|
11 |
-
import os
|
12 |
-
import time
|
13 |
-
import ipywidgets as widgets
|
14 |
-
from ipywidgets import Label, Button, VBox, HBox
|
15 |
-
from IPython.display import display, HTML
|
16 |
-
|
17 |
-
|
18 |
-
# ================= DETECT ENV =================
|
19 |
-
def detect_environment():
|
20 |
-
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
21 |
-
environments = {
|
22 |
-
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
23 |
-
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
24 |
-
'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', "/home/studio-lab-user/content")
|
25 |
-
}
|
26 |
-
|
27 |
-
for env_var, (environment, path) in environments.items():
|
28 |
-
if env_var in os.environ:
|
29 |
-
return environment, path, free_plan
|
30 |
-
|
31 |
-
env, root_path, free_plan = detect_environment()
|
32 |
-
webui_path = f"{root_path}/sdw"
|
33 |
-
# ----------------------------------------------
|
34 |
-
|
35 |
-
|
36 |
-
directories = {
|
37 |
-
"Изображения": f"{webui_path}/outputs",
|
38 |
-
"Модели": f"{webui_path}/models/Stable-diffusion/",
|
39 |
-
"Vae": f"{webui_path}/models/VAE/",
|
40 |
-
"LoRa": f"{webui_path}/models/Lora/",
|
41 |
-
"ControlNet Модели": f"{webui_path}/models/ControlNet/"
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
# ==================== CSS ====================
|
46 |
-
CSS_AC = """
|
47 |
-
<style>
|
48 |
-
/* General Styles */
|
49 |
-
|
50 |
-
hr {
|
51 |
-
border-color: grey;
|
52 |
-
background-color: grey;
|
53 |
-
opacity: 0.25;
|
54 |
-
}
|
55 |
-
|
56 |
-
.instruction_AC {
|
57 |
-
font-family: cursive;
|
58 |
-
font-size: 18px;
|
59 |
-
color: grey;
|
60 |
-
user-select: none;
|
61 |
-
cursor: default;
|
62 |
-
}
|
63 |
-
|
64 |
-
|
65 |
-
/* Container style */
|
66 |
-
|
67 |
-
.container_AC {
|
68 |
-
position: relative;
|
69 |
-
background-color: #232323;
|
70 |
-
width: 800px;
|
71 |
-
height: auto;
|
72 |
-
padding: 15px;
|
73 |
-
border-radius: 15px;
|
74 |
-
box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
|
75 |
-
margin-bottom: 5px;
|
76 |
-
overflow: visible;
|
77 |
-
}
|
78 |
-
|
79 |
-
.container_AC::before {
|
80 |
-
position: absolute;
|
81 |
-
top: 5px;
|
82 |
-
right: 10px;
|
83 |
-
content: "AutoCleanerV3.6";
|
84 |
-
font-weight: bold;
|
85 |
-
font-size: 24px;
|
86 |
-
color: rgba(0, 0, 0, 0.2);
|
87 |
-
}
|
88 |
-
|
89 |
-
.container_AC::after {
|
90 |
-
position: absolute;
|
91 |
-
top: 30px;
|
92 |
-
right: 10px;
|
93 |
-
content: "ANXETY";
|
94 |
-
font-weight: bold;
|
95 |
-
font-size: 18px;
|
96 |
-
color: rgba(0, 0, 0, 0.2);
|
97 |
-
}
|
98 |
-
|
99 |
-
.custom-select-multiple_AC select {
|
100 |
-
padding: 10px;
|
101 |
-
font-family: cursive;
|
102 |
-
border: 1px solid #262626 !important;
|
103 |
-
border-radius: 10px;
|
104 |
-
color: white;
|
105 |
-
background-color: #1c1c1c;
|
106 |
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
107 |
-
}
|
108 |
-
|
109 |
-
.output_AC {
|
110 |
-
padding: 10px;
|
111 |
-
height: auto;
|
112 |
-
border: 1px solid #262626;
|
113 |
-
border-radius: 10px;
|
114 |
-
background-color: #1c1c1c;
|
115 |
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
116 |
-
width: auto;
|
117 |
-
box-sizing: border-box;
|
118 |
-
}
|
119 |
-
|
120 |
-
.output_message_AC {
|
121 |
-
font-family: cursive;
|
122 |
-
color: white !important;
|
123 |
-
font-size: 14px;
|
124 |
-
user-select: none;
|
125 |
-
cursor: default
|
126 |
-
}
|
127 |
-
|
128 |
-
|
129 |
-
.storage_info_AC {
|
130 |
-
padding: 5px 20px;
|
131 |
-
height: auto;
|
132 |
-
border: 1px solid #262626;
|
133 |
-
border-radius: 10px;
|
134 |
-
background-color: #1c1c1c;
|
135 |
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
136 |
-
width: auto;
|
137 |
-
font-family: cursive;
|
138 |
-
color: #B2B2B2 !important;
|
139 |
-
font-size: 14px;
|
140 |
-
user-select: none;
|
141 |
-
cursor: default
|
142 |
-
}
|
143 |
-
|
144 |
-
|
145 |
-
/* Button and storage info layout */
|
146 |
-
.lower_information_panel_AC {
|
147 |
-
display: flex;
|
148 |
-
align-items: center;
|
149 |
-
justify-content: space-between;
|
150 |
-
}
|
151 |
-
|
152 |
-
|
153 |
-
/* Button style */
|
154 |
-
|
155 |
-
.button_AC {
|
156 |
-
width: auto;
|
157 |
-
font-family: cursive;
|
158 |
-
color: white !important;
|
159 |
-
font-size: 14px;
|
160 |
-
font-weight: bold;
|
161 |
-
height: 35px;
|
162 |
-
border-radius: 15px;
|
163 |
-
background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
|
164 |
-
background-size: 200% 200%;
|
165 |
-
background-position: left bottom;
|
166 |
-
transition: background 0.5s ease-in-out, transform 0.3s ease;
|
167 |
-
}
|
168 |
-
|
169 |
-
.button_AC:hover {
|
170 |
-
cursor: pointer;
|
171 |
-
background-size: 200% 200%;
|
172 |
-
background-position: right bottom;
|
173 |
-
transform: translateY(1px);
|
174 |
-
}
|
175 |
-
|
176 |
-
.button_execute_AC:hover {
|
177 |
-
background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);
|
178 |
-
}
|
179 |
-
|
180 |
-
.button_clear_AC:hover {
|
181 |
-
background-image: radial-gradient(circle at top left, purple 10%, #fc3468 90%);
|
182 |
-
}
|
183 |
-
|
184 |
-
.button_execute_AC:active,
|
185 |
-
.button_clear_AC:active {
|
186 |
-
filter: brightness(0.75);
|
187 |
-
}
|
188 |
-
|
189 |
-
.jupyter-widgets.lm-Widget:focus {
|
190 |
-
outline: none;
|
191 |
-
}
|
192 |
-
|
193 |
-
|
194 |
-
/* Animation of elements */
|
195 |
-
|
196 |
-
/* Emergence */
|
197 |
-
.container_AC {
|
198 |
-
animation-name: slideInTopBlur;
|
199 |
-
animation-duration: 0.7s;
|
200 |
-
animation-fill-mode: forwards;
|
201 |
-
}
|
202 |
-
|
203 |
-
@keyframes slideInTopBlur {
|
204 |
-
0% {
|
205 |
-
transform: translate3d(0, 50%, 0) scale(0.85) rotate3d(1, 0, 0, -85deg);
|
206 |
-
filter: blur(5px) grayscale(1) brightness(0.5);
|
207 |
-
opacity: 0;
|
208 |
-
}
|
209 |
-
100% {
|
210 |
-
transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);
|
211 |
-
filter: blur(0) grayscale(0) brightness(1);
|
212 |
-
opacity: 1;
|
213 |
-
}
|
214 |
-
}
|
215 |
-
|
216 |
-
/* Leaving */
|
217 |
-
.container_AC.hide {
|
218 |
-
animation-name: slideOutTopBlur;
|
219 |
-
animation-duration: 0.3s;
|
220 |
-
animation-fill-mode: forwards;
|
221 |
-
}
|
222 |
-
|
223 |
-
@keyframes slideOutTopBlur {
|
224 |
-
0% {
|
225 |
-
transform: translate3d(0, 0, 0) scale(1);
|
226 |
-
filter: blur(0) grayscale(0) brightness(1);
|
227 |
-
opacity: 1;
|
228 |
-
}
|
229 |
-
100% {
|
230 |
-
transform: translate3d(0, -100%, 0);
|
231 |
-
filter: blur(5px) grayscale(1) brightness(0);
|
232 |
-
opacity: 0;
|
233 |
-
}
|
234 |
-
}
|
235 |
-
</style>
|
236 |
-
"""
|
237 |
-
|
238 |
-
display(HTML(CSS_AC))
|
239 |
-
# ==================== CSS ====================
|
240 |
-
|
241 |
-
|
242 |
-
# ================ AutoCleaner function ================
|
243 |
-
def clean_directory(directory):
|
244 |
-
deleted_files = 0
|
245 |
-
for root, dirs, files in os.walk(directory):
|
246 |
-
for file in files:
|
247 |
-
if file.endswith(".txt"):
|
248 |
-
continue
|
249 |
-
os.remove(os.path.join(root, file))
|
250 |
-
if not file.endswith(".yaml"):
|
251 |
-
deleted_files += 1
|
252 |
-
return deleted_files
|
253 |
-
|
254 |
-
|
255 |
-
def get_word_variant(n, variants):
|
256 |
-
unit = abs(n) % 10
|
257 |
-
tens = abs(n) % 100
|
258 |
-
if tens in range(11, 15):
|
259 |
-
return variants[2]
|
260 |
-
elif unit == 1:
|
261 |
-
return variants[0]
|
262 |
-
elif unit in range(2, 5):
|
263 |
-
return variants[1]
|
264 |
-
else:
|
265 |
-
return variants[2]
|
266 |
-
|
267 |
-
|
268 |
-
def update_memory_info():
|
269 |
-
disk_space = psutil.disk_usage(os.getcwd())
|
270 |
-
total = disk_space.total / (1024 ** 3)
|
271 |
-
used = disk_space.used / (1024 ** 3)
|
272 |
-
free = disk_space.free / (1024 ** 3)
|
273 |
-
|
274 |
-
storage_info.value = f'''
|
275 |
-
<div class="storage_info_AC">Всего: {total:.2f} GB <span style="color: #555">|</span> Используется: {used:.2f} GB <span style="color: #555">|</span> Свободно: {free:.2f} GB</div>
|
276 |
-
'''
|
277 |
-
|
278 |
-
|
279 |
-
def on_execute_button_press(button):
|
280 |
-
selected_cleaners = auto_cleaner_widget.value
|
281 |
-
deleted_files_dict = {}
|
282 |
-
|
283 |
-
for option in selected_cleaners:
|
284 |
-
if option in directories:
|
285 |
-
deleted_files_dict[option] = clean_directory(directories[option])
|
286 |
-
|
287 |
-
output.clear_output()
|
288 |
-
|
289 |
-
with output:
|
290 |
-
for message in generate_messages(deleted_files_dict):
|
291 |
-
message_widget = HTML(f'<p class="output_message_AC">{message}</p>')
|
292 |
-
display(message_widget)
|
293 |
-
|
294 |
-
update_memory_info()
|
295 |
-
|
296 |
-
|
297 |
-
def on_clear_button_press(button):
|
298 |
-
container.add_class("hide")
|
299 |
-
time.sleep(0.5)
|
300 |
-
widgets.Widget.close_all()
|
301 |
-
|
302 |
-
|
303 |
-
def generate_messages(deleted_files_dict):
|
304 |
-
messages = []
|
305 |
-
word_variants = {
|
306 |
-
"Изображения": ["Изображение", "Изображения", "Изображений"],
|
307 |
-
"Модели": ["Модель", "Модели", "Моделей"],
|
308 |
-
"Vae": ["VAE", "VAE", "VAE"],
|
309 |
-
"LoRa": ["LoRa", "LoRa", "LoRa"],
|
310 |
-
"ControlNet Модели": ["ControlNet Модель", "ControlNet Модели", "ControlNet Моделей"]
|
311 |
-
}
|
312 |
-
deleted_word_variants = ["Удалена", "Удалены", "Удалено"]
|
313 |
-
for key, value in deleted_files_dict.items():
|
314 |
-
word_variant = word_variants.get(key, ["", "", ""])
|
315 |
-
deleted_word = get_word_variant(value, deleted_word_variants)
|
316 |
-
object_word = get_word_variant(value, word_variant)
|
317 |
-
messages.append(f"{deleted_word} {value} {object_word}")
|
318 |
-
return messages
|
319 |
-
# ================ AutoCleaner function ================
|
320 |
-
|
321 |
-
|
322 |
-
# --- storage memory ---
|
323 |
-
import psutil
|
324 |
-
disk_space = psutil.disk_usage(os.getcwd())
|
325 |
-
total = disk_space.total / (1024 ** 3)
|
326 |
-
used = disk_space.used / (1024 ** 3)
|
327 |
-
free = disk_space.free / (1024 ** 3)
|
328 |
-
|
329 |
-
|
330 |
-
# UI Code
|
331 |
-
AutoCleaner_options = AutoCleaner_options = list(directories.keys())
|
332 |
-
instruction_label = widgets.HTML('''
|
333 |
-
<span class="instruction_AC">Используйте <span style="color: #B2B2B2;">ctrl</span> или <span style="color: #B2B2B2;">shift</span> для множественного выбора.</span>
|
334 |
-
''')
|
335 |
-
auto_cleaner_widget = widgets.SelectMultiple(options=AutoCleaner_options, layout=widgets.Layout(width="auto")).add_class("custom-select-multiple_AC")
|
336 |
-
output = widgets.Output().add_class("output_AC")
|
337 |
-
# ---
|
338 |
-
execute_button = Button(description='Выполнить Очистку').add_class("button_execute_AC").add_class("button_AC")
|
339 |
-
execute_button.on_click(on_execute_button_press)
|
340 |
-
clear_button = Button(description='Скрыть Виджет').add_class("button_clear_AC").add_class("button_AC")
|
341 |
-
clear_button.on_click(on_clear_button_press)
|
342 |
-
# ---
|
343 |
-
storage_info = widgets.HTML(f'''
|
344 |
-
<div class="storage_info_AC">Всего: {total:.2f} GB <span style="color: #555">|</span> Используется: {used:.2f} GB <span style="color: #555">|</span> Свободно: {free:.2f} GB</div>
|
345 |
-
''')
|
346 |
-
# ---
|
347 |
-
buttons = widgets.HBox([execute_button, clear_button])
|
348 |
-
lower_information_panel = widgets.HBox([buttons, storage_info]).add_class("lower_information_panel_AC")
|
349 |
-
|
350 |
-
container = VBox([instruction_label, widgets.HTML('<hr>'), auto_cleaner_widget, output, widgets.HTML('<hr>'), lower_information_panel]).add_class("container_AC")
|
351 |
-
|
352 |
-
display(container)
|
353 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/python/ru/downloading_ru.py
DELETED
@@ -1,564 +0,0 @@
|
|
1 |
-
##~ DOWNLOADING CODE | BY: ANXETY ~##
|
2 |
-
|
3 |
-
import os
|
4 |
-
import re
|
5 |
-
import time
|
6 |
-
import json
|
7 |
-
import requests
|
8 |
-
import subprocess
|
9 |
-
from datetime import timedelta
|
10 |
-
from subprocess import getoutput
|
11 |
-
from urllib.parse import unquote
|
12 |
-
from IPython.utils import capture
|
13 |
-
from IPython.display import clear_output
|
14 |
-
|
15 |
-
|
16 |
-
# ================= DETECT ENV =================
|
17 |
-
def detect_environment():
|
18 |
-
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
19 |
-
environments = {
|
20 |
-
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
21 |
-
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
22 |
-
'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', "/home/studio-lab-user/content")
|
23 |
-
}
|
24 |
-
|
25 |
-
for env_var, (environment, path) in environments.items():
|
26 |
-
if env_var in os.environ:
|
27 |
-
return environment, path, free_plan
|
28 |
-
|
29 |
-
env, root_path, free_plan = detect_environment()
|
30 |
-
webui_path = f"{root_path}/sdw"
|
31 |
-
# ----------------------------------------------
|
32 |
-
|
33 |
-
|
34 |
-
# === ONLY SAGEMAKER ===
|
35 |
-
if env == "SageMaker Studio Lab":
|
36 |
-
print("Обновление зависимостей, может занять некоторое время...")
|
37 |
-
get_ipython().system('pip install -q --upgrade torchsde')
|
38 |
-
get_ipython().system('pip install -q --upgrade pip')
|
39 |
-
get_ipython().system('pip install -q --upgrade psutil')
|
40 |
-
|
41 |
-
clear_output()
|
42 |
-
|
43 |
-
|
44 |
-
# ================ LIBRARIES ================
|
45 |
-
flag_file = f"{root_path}/libraries_installed.txt"
|
46 |
-
|
47 |
-
if not os.path.exists(flag_file):
|
48 |
-
# automatic1111 update webui to 1.8.0
|
49 |
-
xformers = "xformers==0.0.23.post1 triton==2.1.0"
|
50 |
-
torch = "torch==2.1.2+cu121 torchvision==0.16.2+cu121 torchaudio==2.1.2 --extra-index-url https://download.pytorch.org/whl/cu121"
|
51 |
-
|
52 |
-
print("💿 Установка библиотек, это займет какое-то время...", end='')
|
53 |
-
with capture.capture_output() as cap:
|
54 |
-
get_ipython().system('pip install -U gdown')
|
55 |
-
get_ipython().system('apt-get update && apt -y install aria2')
|
56 |
-
get_ipython().system('npm install -g localtunnel &> /dev/null')
|
57 |
-
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
58 |
-
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')
|
59 |
-
get_ipython().system('pip install insightface')
|
60 |
-
get_ipython().system('curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.23/zrok_0.4.23_linux_amd64.tar.gz && tar -xzf zrok_0.4.23_linux_amd64.tar.gz -C /usr/bin && rm -f zrok_0.4.23_linux_amd64.tar.gz')
|
61 |
-
|
62 |
-
if env == "SageMaker Studio Lab":
|
63 |
-
get_ipython().run_line_magic('pip', 'install -q opencv-python-headless huggingface-hub')
|
64 |
-
get_ipython().run_line_magic('conda', 'update -q -n base conda')
|
65 |
-
get_ipython().run_line_magic('conda', 'install -q -y aria2')
|
66 |
-
get_ipython().run_line_magic('conda', 'install -q -y glib')
|
67 |
-
get_ipython().system('pip install tensorflow')
|
68 |
-
|
69 |
-
get_ipython().system('wget -P /home/studio-lab-user https://huggingface.co/NagisaNao/fast_repo/resolve/main/sagemaker/FULL_DELETED_NOTEBOOK.ipynb')
|
70 |
-
|
71 |
-
if env == "Google Colab":
|
72 |
-
get_ipython().system('pip install xformers==0.0.25 --no-deps')
|
73 |
-
else:
|
74 |
-
get_ipython().system('pip install -q {torch} -U')
|
75 |
-
get_ipython().system('pip install -q {xformers} -U')
|
76 |
-
|
77 |
-
with open(flag_file, "w") as f:
|
78 |
-
f.write("hey ;3")
|
79 |
-
del cap
|
80 |
-
print("\r🍪 Библиотеки установлены!" + " "*35)
|
81 |
-
time.sleep(2)
|
82 |
-
clear_output()
|
83 |
-
|
84 |
-
|
85 |
-
# ================= loading settings V4 =================
|
86 |
-
def load_settings(path):
|
87 |
-
if os.path.exists(path):
|
88 |
-
with open(path, 'r') as file:
|
89 |
-
return json.load(file)
|
90 |
-
return {}
|
91 |
-
|
92 |
-
settings = load_settings(f'{root_path}/settings.json')
|
93 |
-
|
94 |
-
variables = [
|
95 |
-
'Model', 'Model_Num', 'Inpainting_Model',
|
96 |
-
'Vae', 'Vae_Num',
|
97 |
-
'latest_webui', 'latest_exstensions', 'detailed_download',
|
98 |
-
'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
|
99 |
-
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
100 |
-
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'
|
101 |
-
]
|
102 |
-
|
103 |
-
locals().update({key: settings.get(key) for key in variables})
|
104 |
-
|
105 |
-
|
106 |
-
# ================= OTHER =================
|
107 |
-
try:
|
108 |
-
start_colab
|
109 |
-
except:
|
110 |
-
start_colab = int(time.time())-5
|
111 |
-
|
112 |
-
# CONFIG DIR
|
113 |
-
models_dir = f"{webui_path}/models/Stable-diffusion"
|
114 |
-
vaes_dir = f"{webui_path}/models/VAE"
|
115 |
-
embeddings_dir = f"{webui_path}/embeddings"
|
116 |
-
loras_dir = f"{webui_path}/models/Lora"
|
117 |
-
extensions_dir = f"{webui_path}/extensions"
|
118 |
-
control_dir = f"{webui_path}/models/ControlNet"
|
119 |
-
|
120 |
-
|
121 |
-
# ================= MAIN CODE =================
|
122 |
-
# --- Obsolescence warning ---
|
123 |
-
if env == "SageMaker Studio Lab":
|
124 |
-
print("Вы использует�� среду 'SageMaker' - эта среда устарела, поэтому многие ошибки не будут исправлены, а ее функциональность будет урезана. Для экономии памяти и/или во избежание ошибок.\n\n")
|
125 |
-
|
126 |
-
|
127 |
-
if not os.path.exists(webui_path):
|
128 |
-
start_install = int(time.time())
|
129 |
-
print("⌚ Распоковка Stable Diffusion...", end='')
|
130 |
-
with capture.capture_output() as cap:
|
131 |
-
get_ipython().system('aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip -o repo.zip')
|
132 |
-
get_ipython().system('unzip -q -o repo.zip -d {webui_path}')
|
133 |
-
get_ipython().system('rm -rf repo.zip')
|
134 |
-
|
135 |
-
get_ipython().run_line_magic('cd', '{root_path}')
|
136 |
-
os.environ["SAFETENSORS_FAST_GPU"]='1'
|
137 |
-
os.environ["CUDA_MODULE_LOADING"]="LAZY"
|
138 |
-
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
|
139 |
-
os.environ["PYTHONWARNINGS"] = "ignore"
|
140 |
-
|
141 |
-
get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
142 |
-
del cap
|
143 |
-
install_time = timedelta(seconds=time.time()-start_install)
|
144 |
-
print("\r🚀 Распаковка Завершена! За","%02d:%02d:%02d ⚡\n" % (install_time.seconds / 3600, (install_time.seconds / 60) % 60, install_time.seconds % 60), end='', flush=True)
|
145 |
-
else:
|
146 |
-
if env == "SageMaker Studio Lab":
|
147 |
-
get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
148 |
-
print("🚀 Все распакованно... Пропуск. ⚡")
|
149 |
-
start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
|
150 |
-
time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
|
151 |
-
print(f"⌚️ Вы проводите эту сессию в течение - \033[33m{time_since_start}\033[0m")
|
152 |
-
|
153 |
-
|
154 |
-
## Changes extensions and WebUi
|
155 |
-
if latest_webui or latest_exstensions:
|
156 |
-
action = "Обновление WebUI и Расширений" if latest_webui and latest_exstensions else ("Обновление WebUI" if latest_webui else "Обновление Расширений")
|
157 |
-
print(f"⌚️ {action}...", end='', flush=True)
|
158 |
-
with capture.capture_output() as cap:
|
159 |
-
get_ipython().system('git config --global user.email "[email protected]"')
|
160 |
-
get_ipython().system('git config --global user.name "Your Name"')
|
161 |
-
|
162 |
-
## Update Webui
|
163 |
-
if latest_webui:
|
164 |
-
get_ipython().run_line_magic('cd', '{webui_path}')
|
165 |
-
get_ipython().system('git restore .')
|
166 |
-
get_ipython().system('git pull -X theirs --rebase --autostash')
|
167 |
-
|
168 |
-
## Update extensions
|
169 |
-
if latest_exstensions:
|
170 |
-
if env != "SageMaker Studio Lab":
|
171 |
-
get_ipython().system('{\'for dir in \' + webui_path + \'/extensions/*/; do cd \\"$dir\\" && git reset --hard && git pull; done\'}')
|
172 |
-
else:
|
173 |
-
get_ipython().system('{\'for dir in /home/studio-lab-user/content/sdw/extensions/*/; do cd \\"$dir\\" && git fetch origin && git pull; done\'}')
|
174 |
-
|
175 |
-
# My Chinese friend, you broke the images again in the latest update... >W<'
|
176 |
-
get_ipython().run_line_magic('cd', '{webui_path}/extensions/Encrypt-Image')
|
177 |
-
get_ipython().system('git reset --hard 376358d8854472b9ea50e9fc8800367d1ca51137 # stable commit :3')
|
178 |
-
|
179 |
-
get_ipython().system('cd {webui_path}/repositories/stable-diffusion-stability-ai && git restore .')
|
180 |
-
del cap
|
181 |
-
print(f"\r✨ {action} Завершено!")
|
182 |
-
|
183 |
-
|
184 |
-
# === FIXING ERRORS ===
|
185 |
-
# --- Encrypt-Image ---
|
186 |
-
get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js")
|
187 |
-
|
188 |
-
# --- SageMaker ---
|
189 |
-
if env == "SageMaker Studio Lab":
|
190 |
-
with capture.capture_output() as cap:
|
191 |
-
# --- SuperMerger Remove ---
|
192 |
-
if os.path.exists(f"{webui_path}/extensions/supermerger"):
|
193 |
-
get_ipython().system('rm -rf {webui_path}/extensions/supermerger')
|
194 |
-
# --- Launch (Style) ---
|
195 |
-
get_ipython().system('wget -O {webui_path}/modules/styles.py https://huggingface.co/NagisaNao/fast_repo/resolve/main/sagemaker/fixing/webui/styles.py')
|
196 |
-
del cap
|
197 |
-
|
198 |
-
|
199 |
-
## Version switching
|
200 |
-
if commit_hash:
|
201 |
-
print('⏳ Активация машины времени...', end="", flush=True)
|
202 |
-
with capture.capture_output() as cap:
|
203 |
-
get_ipython().run_line_magic('cd', '{webui_path}')
|
204 |
-
get_ipython().system('git config --global user.email "[email protected]"')
|
205 |
-
get_ipython().system('git config --global user.name "Your Name"')
|
206 |
-
get_ipython().system('git reset --hard {commit_hash}')
|
207 |
-
del cap
|
208 |
-
print(f"\r⌛️ Машина времени активированна! Текущий коммит: \033[34m{commit_hash}\033[0m")
|
209 |
-
|
210 |
-
|
211 |
-
## Downloading model and stuff | oh yeah~ I'm starting to misunderstand my own code ( almost my own ;3 )
|
212 |
-
print("📦 Скачивание моделей и прочего...", end='')
|
213 |
-
model_list = {
|
214 |
-
"1.Anime (by XpucT) + INP": [
|
215 |
-
{"url": "https://huggingface.co/XpucT/Anime/resolve/main/Anime_v2.safetensors", "name": "Anime_v2.safetensors"},
|
216 |
-
{"url": "https://huggingface.co/XpucT/Anime/resolve/main/Anime_v2-inpainting.safetensors", "name": "Anime_v2-inpainting.safetensors"}
|
217 |
-
],
|
218 |
-
"2.BluMix [Anime] [V7]": [
|
219 |
-
{"url": "https://civitai.com/api/download/models/361779", "name": "BluMix_v7.safetensors"}
|
220 |
-
],
|
221 |
-
"3.Cetus-Mix [Anime] [V4] + INP": [
|
222 |
-
{"url": "https://civitai.com/api/download/models/130298", "name": "CetusMix_V4.safetensors"},
|
223 |
-
{"url": "https://civitai.com/api/download/models/139882", "name": "CetusMix_V4-inpainting.safetensors"}
|
224 |
-
],
|
225 |
-
"4.Counterfeit [Anime] [V3] + INP": [
|
226 |
-
{"url": "https://civitai.com/api/download/models/125050", "name": "Counterfeit_V3.safetensors"},
|
227 |
-
{"url": "https://civitai.com/api/download/models/137911", "name": "Counterfeit_V3-inpainting.safetensors"}
|
228 |
-
],
|
229 |
-
"5.CuteColor [Anime] [V3]": [
|
230 |
-
{"url": "https://civitai.com/api/download/models/138754", "name": "CuteColor_V3.safetensors"}
|
231 |
-
],
|
232 |
-
"6.Dark-Sushi-Mix [Anime]": [
|
233 |
-
{"url": "https://civitai.com/api/download/models/101640", "name": "DarkSushiMix_2_5D.safetensors"},
|
234 |
-
{"url": "https://civitai.com/api/download/models/56071", "name": "DarkSushiMix_colorful.safetensors"}
|
235 |
-
],
|
236 |
-
"7.Deliberate [Realism] [V6] + INP": [
|
237 |
-
{"url": "https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v6.safetensors", "name": "Deliberate_v6.safetensors"},
|
238 |
-
{"url": "https://huggingface.co/XpucT/Deliberate/resolve/main/Deliberate_v6-inpainting.safetensors", "name": "Deliberate_v6-inpainting.safetensors"}
|
239 |
-
],
|
240 |
-
"8.Meina-Mix [Anime] [V11] + INP": [
|
241 |
-
{"url": "https://civitai.com/api/download/models/119057", "name": "MeinaMix_V11.safetensors"},
|
242 |
-
{"url": "https://civitai.com/api/download/models/120702", "name": "MeinaMix_V11-inpainting.safetensors"}
|
243 |
-
],
|
244 |
-
"9.Mix-Pro [Anime] [V4] + INP": [
|
245 |
-
{"url": "https://civitai.com/api/download/models/125668", "name": "MixPro_V4.safetensors"},
|
246 |
-
{"url": "https://civitai.com/api/download/models/139878", "name": "MixPro_V4-inpainting.safetensors"}
|
247 |
-
]
|
248 |
-
}
|
249 |
-
|
250 |
-
# 1-4 (fp16/cleaned)
|
251 |
-
vae_list = {
|
252 |
-
"1.Anime.vae": [
|
253 |
-
{"url": "https://civitai.com/api/download/models/131654", "name": "Anime.vae.safetensors"},
|
254 |
-
{"url": "https://civitai.com/api/download/models/131658", "name": "vae-ft-mse.vae.safetensors"}
|
255 |
-
],
|
256 |
-
"2.Anything.vae": [{"url": "https://civitai.com/api/download/models/131656", "name": "Anything.vae.safetensors"}],
|
257 |
-
"3.Blessed2.vae": [{"url": "https://civitai.com/api/download/models/142467", "name": "Blessed2.vae.safetensors"}],
|
258 |
-
"4.ClearVae.vae": [{"url": "https://civitai.com/api/download/models/133362", "name": "ClearVae_23.vae.safetensors"}],
|
259 |
-
"5.WD.vae": [{"url": "https://huggingface.co/NoCrypt/resources/resolve/main/VAE/wd.vae.safetensors", "name": "WD.vae.safetensors"}]
|
260 |
-
}
|
261 |
-
|
262 |
-
controlnet_list = {
|
263 |
-
"1.canny": [
|
264 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_canny_fp16.safetensors", "name": "control_v11p_sd15_canny_fp16.safetensors"},
|
265 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_canny_fp16.yaml", "name": "control_v11p_sd15_canny_fp16.yaml"}
|
266 |
-
],
|
267 |
-
"2.openpose": [
|
268 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_openpose_fp16.safetensors", "name": "control_v11p_sd15_openpose_fp16.safetensors"},
|
269 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_openpose_fp16.yaml", "name": "control_v11p_sd15_openpose_fp16.yaml"}
|
270 |
-
],
|
271 |
-
"3.depth": [
|
272 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1p_sd15_depth_fp16.safetensors", "name": "control_v11f1p_sd15_depth_fp16.safetensors"},
|
273 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1p_sd15_depth_fp16.yaml", "name": "control_v11f1p_sd15_depth_fp16.yaml"},
|
274 |
-
{"url": "https://huggingface.co/NagisaNao/models/resolve/main/ControlNet_v11/control_v11p_sd15_depth_anything_fp16.safetensors", "name": "control_v11p_sd15_depth_anything_fp16.safetensors"}
|
275 |
-
],
|
276 |
-
"4.normal_map": [
|
277 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_normalbae_fp16.safetensors", "name": "control_v11p_sd15_normalbae_fp16.safetensors"},
|
278 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_normalbae_fp16.yaml", "name": "control_v11p_sd15_normalbae_fp16.yaml"}
|
279 |
-
],
|
280 |
-
"5.mlsd": [
|
281 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_mlsd_fp16.safetensors", "name": "control_v11p_sd15_mlsd_fp16.safetensors"},
|
282 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_mlsd_fp16.yaml", "name": "control_v11p_sd15_mlsd_fp16.yaml"}
|
283 |
-
],
|
284 |
-
"6.lineart": [
|
285 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_lineart_fp16.safetensors", "name": "control_v11p_sd15_lineart_fp16.safetensors"},
|
286 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15s2_lineart_anime_fp16.safetensors", "name": "control_v11p_sd15s2_lineart_anime_fp16.safetensors"},
|
287 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_lineart_fp16.yaml", "name": "control_v11p_sd15_lineart_fp16.yaml"},
|
288 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15s2_lineart_anime_fp16.yaml", "name": "control_v11p_sd15s2_lineart_anime_fp16.yaml"}
|
289 |
-
],
|
290 |
-
"7.soft_edge": [
|
291 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_softedge_fp16.safetensors", "name": "control_v11p_sd15_softedge_fp16.safetensors"},
|
292 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_softedge_fp16.yaml", "name": "control_v11p_sd15_softedge_fp16.yaml"}
|
293 |
-
],
|
294 |
-
"8.scribble": [
|
295 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_scribble_fp16.safetensors", "name": "control_v11p_sd15_scribble_fp16.safetensors"},
|
296 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_scribble_fp16.yaml", "name": "control_v11p_sd15_scribble_fp16.yaml"}
|
297 |
-
],
|
298 |
-
"9.segmentation": [
|
299 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_seg_fp16.safetensors", "name": "control_v11p_sd15_seg_fp16.safetensors"},
|
300 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_seg_fp16.yaml", "name": "control_v11p_sd15_seg_fp16.yaml"}
|
301 |
-
],
|
302 |
-
"10.shuffle": [
|
303 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle_fp16.safetensors", "name": "control_v11e_sd15_shuffle_fp16.safetensors"},
|
304 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_shuffle_fp16.yaml", "name": "control_v11e_sd15_shuffle_fp16.yaml"}
|
305 |
-
],
|
306 |
-
"11.tile": [
|
307 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11f1e_sd15_tile_fp16.safetensors", "name": "control_v11f1e_sd15_tile_fp16.safetensors"},
|
308 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11f1e_sd15_tile_fp16.yaml", "name": "control_v11f1e_sd15_tile_fp16.yaml"}
|
309 |
-
],
|
310 |
-
"12.inpaint": [
|
311 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11p_sd15_inpaint_fp16.safetensors", "name": "control_v11p_sd15_inpaint_fp16.safetensors"},
|
312 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11p_sd15_inpaint_fp16.yaml", "name": "control_v11p_sd15_inpaint_fp16.yaml"}
|
313 |
-
],
|
314 |
-
"13.instruct_p2p": [
|
315 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors", "name": "control_v11e_sd15_ip2p_fp16.safetensors"},
|
316 |
-
{"url": "https://huggingface.co/ckpt/ControlNet-v1-1/raw/main/control_v11e_sd15_ip2p_fp16.yaml", "name": "control_v11e_sd15_ip2p_fp16.yaml"}
|
317 |
-
]
|
318 |
-
}
|
319 |
-
|
320 |
-
extension_repo = []
|
321 |
-
prefixes = {
|
322 |
-
# It's complicated, but supplementing has become easier
|
323 |
-
"model": [models_dir, "Model_url"],
|
324 |
-
"vae": [vaes_dir, "Vae_url"],
|
325 |
-
"lora": [loras_dir, "LoRA_url"],
|
326 |
-
"embed": [embeddings_dir, "Embedding_url"],
|
327 |
-
"extension": [extensions_dir, "Extensions_url"],
|
328 |
-
"control": [control_dir, "ControlNet_url"]
|
329 |
-
}
|
330 |
-
|
331 |
-
get_ipython().system('mkdir -p {models_dir} {vaes_dir} {loras_dir} {embeddings_dir} {extensions_dir} {control_dir}')
|
332 |
-
|
333 |
-
url = ""
|
334 |
-
ControlNet_url = ""
|
335 |
-
hf_token = optional_huggingface_token if optional_huggingface_token else "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"
|
336 |
-
user_header = f"\"Authorization: Bearer {hf_token}\""
|
337 |
-
|
338 |
-
''' main download code '''
|
339 |
-
|
340 |
-
def handle_manual(url):
|
341 |
-
original_url = url
|
342 |
-
url = url.split(':', 1)[1]
|
343 |
-
file_name = re.search(r'\[(.*?)\]', url)
|
344 |
-
file_name = file_name.group(1) if file_name else None
|
345 |
-
if file_name:
|
346 |
-
url = re.sub(r'\[.*?\]', '', url)
|
347 |
-
|
348 |
-
for prefix, (dir, _) in prefixes.items():
|
349 |
-
if original_url.startswith(f"{prefix}:"):
|
350 |
-
if prefix != "extension":
|
351 |
-
manual_download(url, dir, file_name=file_name)
|
352 |
-
else:
|
353 |
-
extension_repo.append((url, file_name))
|
354 |
-
|
355 |
-
def manual_download(url, dst_dir, file_name):
|
356 |
-
basename = url.split("/")[-1] if file_name is None else file_name
|
357 |
-
header_option = f"--header={user_header}"
|
358 |
-
|
359 |
-
print("\033[32m---"*45 + f"\n\033[33mURL: \033[34m{url}\n\033[33mSAVE DIR: \033[34m{dst_dir}\n\033[33mFILE NAME: \033[34m{file_name}\033[32m\n~~~\033[0m")
|
360 |
-
|
361 |
-
# I do it at my own risk..... Fucking CivitAi >:(
|
362 |
-
civitai_token = "62c0c5956b2f9defbd844d754000180b"
|
363 |
-
if 'civitai' in url and civitai_token:
|
364 |
-
url = f"{url}?token={civitai_token}"
|
365 |
-
|
366 |
-
# -- GDrive --
|
367 |
-
if 'drive.google' in url:
|
368 |
-
if 'folders' in url:
|
369 |
-
get_ipython().system('gdown --folder "{url}" -O {dst_dir} --fuzzy -c')
|
370 |
-
else:
|
371 |
-
if file_name:
|
372 |
-
get_ipython().system('gdown "{url}" -O {dst_dir}/{file_name} --fuzzy -c')
|
373 |
-
else:
|
374 |
-
get_ipython().system('gdown "{url}" -O {dst_dir} --fuzzy -c')
|
375 |
-
# -- Huggin Face --
|
376 |
-
elif 'huggingface' in url:
|
377 |
-
if '/blob/' in url:
|
378 |
-
url = url.replace('/blob/', '/resolve/')
|
379 |
-
if file_name:
|
380 |
-
get_ipython().system('aria2c {header_option} --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -c -j5 -x16 -s16 -k1M -d {dst_dir} -o {basename} {url}')
|
381 |
-
else:
|
382 |
-
parsed_link = f'\n{url}\n\tout={unquote(url.split("/")[-1])}'
|
383 |
-
get_ipython().system('echo -e "{parsed_link}" | aria2c {header_option} --console-log-level=error --summary-interval=10 -i- -j5 -x16 -s16 -k1M -c -d "{dst_dir}" -o {basename}')
|
384 |
-
# -- Other --
|
385 |
-
elif 'http' in url or 'magnet' in url:
|
386 |
-
if file_name:
|
387 |
-
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -o {file_name} {url}')
|
388 |
-
else:
|
389 |
-
parsed_link = '"{}"'.format(url)
|
390 |
-
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {dst_dir} -Z {parsed_link}')
|
391 |
-
|
392 |
-
def download(url):
|
393 |
-
links_and_paths = url.split(',')
|
394 |
-
|
395 |
-
for link_or_path in links_and_paths:
|
396 |
-
link_or_path = link_or_path.strip()
|
397 |
-
if not link_or_path:
|
398 |
-
continue
|
399 |
-
if any(link_or_path.startswith(prefix.lower()) for prefix in prefixes):
|
400 |
-
handle_manual(link_or_path)
|
401 |
-
continue
|
402 |
-
|
403 |
-
url, dst_dir, file_name = link_or_path.split()
|
404 |
-
manual_download(url, dst_dir, file_name)
|
405 |
-
|
406 |
-
''' submodels - added urls '''
|
407 |
-
|
408 |
-
submodels = []
|
409 |
-
|
410 |
-
def add_submodels(selection, num_selection, model_dict, dst_dir):
|
411 |
-
if selection == "none":
|
412 |
-
return []
|
413 |
-
if selection == "ALL":
|
414 |
-
all_models = []
|
415 |
-
for models in model_dict.values():
|
416 |
-
all_models.extend(models)
|
417 |
-
selected_models = all_models
|
418 |
-
else:
|
419 |
-
selected_models = model_dict[selection]
|
420 |
-
selected_nums = map(int, num_selection.replace(',', '').split())
|
421 |
-
|
422 |
-
for num in selected_nums:
|
423 |
-
if 1 <= num <= len(model_dict):
|
424 |
-
name = list(model_dict)[num - 1]
|
425 |
-
selected_models.extend(model_dict[name])
|
426 |
-
|
427 |
-
unique_models = list({model['name']: model for model in selected_models}.values())
|
428 |
-
|
429 |
-
for model in unique_models:
|
430 |
-
model['dst_dir'] = dst_dir
|
431 |
-
|
432 |
-
return unique_models
|
433 |
-
|
434 |
-
submodels += add_submodels(Model, Model_Num, model_list, models_dir) # model
|
435 |
-
submodels += add_submodels(Vae, Vae_Num, vae_list, vaes_dir) # vae
|
436 |
-
submodels += add_submodels(controlnet, "" if controlnet == "ALL" else controlnet_Num, controlnet_list, control_dir) # controlnet
|
437 |
-
|
438 |
-
for submodel in submodels:
|
439 |
-
if not Inpainting_Model and "inpainting" in submodel['name']:
|
440 |
-
continue
|
441 |
-
url += f"{submodel['url']} {submodel['dst_dir']} {submodel['name']}, "
|
442 |
-
|
443 |
-
''' file.txt - added urls '''
|
444 |
-
|
445 |
-
unique_urls = []
|
446 |
-
|
447 |
-
def process_file_download(file_url):
|
448 |
-
if file_url.startswith("http"):
|
449 |
-
if "blob" in file_url:
|
450 |
-
file_url = file_url.replace("blob", "raw")
|
451 |
-
response = requests.get(file_url)
|
452 |
-
lines = response.text.split('\n')
|
453 |
-
else:
|
454 |
-
with open(file_url, 'r') as file:
|
455 |
-
lines = file.readlines()
|
456 |
-
|
457 |
-
current_tag = None
|
458 |
-
for line in lines:
|
459 |
-
if any(f'# {tag}' in line.lower() for tag in prefixes):
|
460 |
-
current_tag = next((tag for tag in prefixes if tag in line.lower()))
|
461 |
-
|
462 |
-
urls = [url.strip() for url in line.split(',')]
|
463 |
-
for url in urls:
|
464 |
-
if url.startswith("http") and url not in unique_urls:
|
465 |
-
globals()[prefixes[current_tag][1]] += ", " + url
|
466 |
-
unique_urls.append(url)
|
467 |
-
|
468 |
-
# fix all possible errors/options and function call
|
469 |
-
if custom_file_urls:
|
470 |
-
for custom_file_url in custom_file_urls.replace(',', '').split():
|
471 |
-
if not custom_file_url.endswith('.txt'):
|
472 |
-
custom_file_url += '.txt'
|
473 |
-
if not custom_file_url.startswith('http'):
|
474 |
-
if not custom_file_url.startswith(root_path):
|
475 |
-
custom_file_url = f'{root_path}/{custom_file_url}'
|
476 |
-
|
477 |
-
try:
|
478 |
-
process_file_download(custom_file_url)
|
479 |
-
except FileNotFoundError:
|
480 |
-
pass
|
481 |
-
|
482 |
-
# url prefixing
|
483 |
-
urls = [globals()[urls[1]] for urls in prefixes.values()]
|
484 |
-
for i, prefix in enumerate(prefixes):
|
485 |
-
if urls[i]:
|
486 |
-
prefixed_urls = [f"{prefix}:{url}" for url in urls[i].replace(',', '').split()]
|
487 |
-
if prefixed_urls:
|
488 |
-
url += ", ".join(prefixed_urls) + ", "
|
489 |
-
|
490 |
-
if detailed_download == "on":
|
491 |
-
print("\n\n\033[33m# ====== Подробная Загрузка ====== #\n\033[0m")
|
492 |
-
download(url)
|
493 |
-
print("\n\033[33m# =============================== #\n\033[0m")
|
494 |
-
else:
|
495 |
-
with capture.capture_output() as cap:
|
496 |
-
download(url)
|
497 |
-
del cap
|
498 |
-
|
499 |
-
print("\r🏁 Скачивание Завершено!" + " "*15)
|
500 |
-
|
501 |
-
|
502 |
-
# Cleaning shit after downloading...
|
503 |
-
get_ipython().system('find {webui_path} \\( -type d \\( -name ".ipynb_checkpoints" -o -name ".aria2" \\) -o -type f -name "*.aria2" \\) -exec rm -r {{}} \\; >/dev/null 2>&1')
|
504 |
-
|
505 |
-
|
506 |
-
## Install of Custom extensions
|
507 |
-
if len(extension_repo) > 0:
|
508 |
-
print("✨ Устанвока кастомных расширений...", end='', flush=True)
|
509 |
-
with capture.capture_output() as cap:
|
510 |
-
for repo, repo_name in extension_repo:
|
511 |
-
if not repo_name:
|
512 |
-
repo_name = repo.split('/')[-1]
|
513 |
-
get_ipython().system('cd {extensions_dir} && git clone {repo} {repo_name} && cd {repo_name} && git fetch')
|
514 |
-
del cap
|
515 |
-
print(f"\r📦 Установлено '{len(extension_repo)}', Кастомных расширений!")
|
516 |
-
|
517 |
-
|
518 |
-
## List Models and stuff
|
519 |
-
if detailed_download == "off":
|
520 |
-
print("\n\n\033[33mЕсли вы не видете каких-то скаченных файлов, включите в виджетах функцию 'Подробная Загрузка'.")
|
521 |
-
|
522 |
-
if any(not file.endswith('.txt') for file in os.listdir(models_dir)):
|
523 |
-
print("\n\033[33m➤ Models\033[0m")
|
524 |
-
get_ipython().system("find {models_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'")
|
525 |
-
if any(not file.endswith('.txt') for file in os.listdir(vaes_dir)):
|
526 |
-
print("\n\033[33m➤ VAEs\033[0m")
|
527 |
-
get_ipython().system("find {vaes_dir}/ -mindepth 1 ! -name '*.txt' -printf '%f\\n'")
|
528 |
-
if any(not file.endswith('.txt') and not os.path.isdir(os.path.join(embeddings_dir, file)) for file in os.listdir(embeddings_dir)):
|
529 |
-
print("\n\033[33m➤ Embeddings\033[0m")
|
530 |
-
get_ipython().system("find {embeddings_dir}/ -mindepth 1 -maxdepth 1 \\( -name '*.pt' -or -name '*.safetensors' \\) -printf '%f\\n'")
|
531 |
-
if any(not file.endswith('.txt') for file in os.listdir(loras_dir)):
|
532 |
-
print("\n\033[33m➤ LoRAs\033[0m")
|
533 |
-
get_ipython().system("find {loras_dir}/ -mindepth 1 ! -name '*.keep' -printf '%f\\n'")
|
534 |
-
print(f"\n\033[33m➤ Extensions\033[0m")
|
535 |
-
get_ipython().system("find {extensions_dir}/ -mindepth 1 -maxdepth 1 ! -name '*.txt' -printf '%f\\n'")
|
536 |
-
if any(not file.endswith(('.txt', '.yaml')) for file in os.listdir(control_dir)):
|
537 |
-
print("\n\033[33m➤ ControlNet\033[0m")
|
538 |
-
get_ipython().system("find {control_dir}/ -mindepth 1 ! -name '*.yaml' -printf '%f\\n' | sed 's/^[^_]*_[^_]*_[^_]*_\\(.*\\)_fp16\\.safetensors$/\\1/'")
|
539 |
-
|
540 |
-
|
541 |
-
# === OTHER ===
|
542 |
-
# Downlaod discord tags UmiWildcards
|
543 |
-
files_umi = [
|
544 |
-
"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/200_pan_gen.txt",
|
545 |
-
"https://huggingface.co/NagisaNao/fast_repo/resolve/main/extensions/UmiWildacrd/discord/150_bra_gen.txt"
|
546 |
-
]
|
547 |
-
save_dir_path = f"{webui_path}/extensions/Umi-AI-Wildcards/wildcards/discord"
|
548 |
-
|
549 |
-
with capture.capture_output() as cap:
|
550 |
-
for file in files_umi:
|
551 |
-
get_ipython().system('aria2c --optimize-concurrent-downloads --console-log-level=error --summary-interval=10 -j5 -x16 -s16 -k1M -c -d {save_dir_path} {file}')
|
552 |
-
del cap
|
553 |
-
|
554 |
-
|
555 |
-
# === ONLY SAGEMAKER ===
|
556 |
-
if env == "SageMaker Studio Lab":
|
557 |
-
with capture.capture_output() as cap:
|
558 |
-
get_ipython().system('rm -rf /home/studio-lab-user/.conda/envs/studiolab-safemode')
|
559 |
-
get_ipython().system('rm -rf /home/studio-lab-user/.conda/envs/sagemaker-distribution')
|
560 |
-
get_ipython().system('rm -rf /home/studio-lab-user/.conda/pkgs/cache')
|
561 |
-
get_ipython().system('pip cache purge')
|
562 |
-
get_ipython().system('rm -rf ~/.cache')
|
563 |
-
del cap
|
564 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/python/ru/launch_ru.py
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
##~ LAUNCH CODE | BY: ANXETY ~##
|
2 |
-
|
3 |
-
import os
|
4 |
-
import re
|
5 |
-
import time
|
6 |
-
import json
|
7 |
-
import requests
|
8 |
-
from datetime import timedelta
|
9 |
-
|
10 |
-
|
11 |
-
# ================= DETECT ENV =================
|
12 |
-
def detect_environment():
|
13 |
-
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
14 |
-
environments = {
|
15 |
-
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
16 |
-
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
17 |
-
'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', "/home/studio-lab-user/content")
|
18 |
-
}
|
19 |
-
|
20 |
-
for env_var, (environment, path) in environments.items():
|
21 |
-
if env_var in os.environ:
|
22 |
-
return environment, path, free_plan
|
23 |
-
|
24 |
-
env, root_path, free_plan = detect_environment()
|
25 |
-
webui_path = f"{root_path}/sdw"
|
26 |
-
# ----------------------------------------------
|
27 |
-
|
28 |
-
def load_settings():
|
29 |
-
SETTINGS_FILE = f'{root_path}/settings.json'
|
30 |
-
if os.path.exists(SETTINGS_FILE):
|
31 |
-
with open(SETTINGS_FILE, 'r') as f:
|
32 |
-
settings = json.load(f)
|
33 |
-
return settings
|
34 |
-
|
35 |
-
settings = load_settings()
|
36 |
-
ngrok_token = settings['ngrok_token']
|
37 |
-
zrok_token = settings['zrok_token']
|
38 |
-
commandline_arguments = settings['commandline_arguments']
|
39 |
-
|
40 |
-
|
41 |
-
# ======================== TUNNEL ========================
|
42 |
-
if env != "SageMaker Studio Lab":
|
43 |
-
import cloudpickle as pickle
|
44 |
-
|
45 |
-
def get_public_ip(version='ipv4'):
|
46 |
-
try:
|
47 |
-
url = f'https://api64.ipify.org?format=json&{version}=true'
|
48 |
-
response = requests.get(url)
|
49 |
-
data = response.json()
|
50 |
-
public_ip = data['ip']
|
51 |
-
return public_ip
|
52 |
-
except Exception as e:
|
53 |
-
print(f"Error getting public {version} address:", e)
|
54 |
-
|
55 |
-
public_ipv4 = get_public_ip(version='ipv4')
|
56 |
-
|
57 |
-
tunnel_class = pickle.load(open(f"{root_path}/new_tunnel", "rb"), encoding="utf-8")
|
58 |
-
tunnel_port= 1769
|
59 |
-
tunnel = tunnel_class(tunnel_port)
|
60 |
-
tunnel.add_tunnel(command="cl tunnel --url localhost:{port}", name="cl", pattern=re.compile(r"[\w-]+\.trycloudflare\.com"))
|
61 |
-
tunnel.add_tunnel(command="lt --port {port}", name="lt", pattern=re.compile(r"[\w-]+\.loca\.lt"), note="Password : " + "\033[32m" + public_ipv4 + "\033[0m" + " rerun cell if 404 error.")
|
62 |
-
|
63 |
-
''' add zrok tunnel '''
|
64 |
-
if zrok_token:
|
65 |
-
get_ipython().system('zrok enable {zrok_token} &> /dev/null')
|
66 |
-
tunnel.add_tunnel(command="zrok share public http://localhost:{port}/ --headless", name="zrok", pattern=re.compile(r"[\w-]+\.share\.zrok\.io"))
|
67 |
-
# ======================== TUNNEL ========================
|
68 |
-
|
69 |
-
|
70 |
-
# automatic fixing path V2
|
71 |
-
get_ipython().system('sed -i \'s#"tagger_hf_cache_dir": ".*models/interrogators"#"tagger_hf_cache_dir": "{root_path}/sdw/models/interrogators"#\' {webui_path}/config.json')
|
72 |
-
get_ipython().system('sed -i \'s#"additional_networks_extra_lora_path": ".*models/Lora/"#"additional_networks_extra_lora_path": "{root_path}/sdw/models/Lora/"#\' {webui_path}/config.json')
|
73 |
-
# ---
|
74 |
-
get_ipython().system('sed -i \'s/"sd_checkpoint_hash": ".*"/"sd_checkpoint_hash": ""/g; s/"sd_model_checkpoint": ".*"/"sd_model_checkpoint": ""/g; s/"sd_vae": ".*"/"sd_vae": "None"/g\' {webui_path}/config.json')
|
75 |
-
|
76 |
-
|
77 |
-
if env != "SageMaker Studio Lab":
|
78 |
-
with tunnel:
|
79 |
-
get_ipython().run_line_magic('cd', '{webui_path}')
|
80 |
-
commandline_arguments += f" --port=1769"
|
81 |
-
|
82 |
-
if ngrok_token:
|
83 |
-
commandline_arguments += ' --ngrok ' + ngrok_token
|
84 |
-
if env != "Google Colab":
|
85 |
-
commandline_arguments += f" --encrypt-pass=1769"
|
86 |
-
|
87 |
-
get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
|
88 |
-
|
89 |
-
start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
|
90 |
-
time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
|
91 |
-
print(f"\n⌚️ \033[0mВы проводите эту сессию в течение - \033[33m{time_since_start}\033[0m\n\n")
|
92 |
-
|
93 |
-
else:
|
94 |
-
if ngrok_token:
|
95 |
-
get_ipython().run_line_magic('cd', '{webui_path}')
|
96 |
-
|
97 |
-
commandline_arguments += ' --ngrok ' + ngrok_token
|
98 |
-
|
99 |
-
get_ipython().system('COMMANDLINE_ARGS="{commandline_arguments}" python launch.py')
|
100 |
-
|
101 |
-
start_colab = float(open(f'{webui_path}/static/colabTimer.txt', 'r').read())
|
102 |
-
time_since_start = str(timedelta(seconds=time.time()-start_colab)).split('.')[0]
|
103 |
-
print(f"\n⌚️ \033[0mВы проводите эту сессию в течение - \033[33m{time_since_start}\033[0m\n\n")
|
104 |
-
|
105 |
-
else:
|
106 |
-
print("Упс... Я думаю, вы забыли вставить токен `ngrok`..... вернитесь к виджетам и вставьте его, чтобы запустить webui... без него никак :/\nВы можете получить токен здесь:\n\nhttps://dashboard.ngrok.com/get-started/your-authtoken")
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sagemaker/files_cells/python/ru/widgets_ru.py
DELETED
@@ -1,592 +0,0 @@
|
|
1 |
-
##~ WIDGET CODE | BY: ANXETY ~##
|
2 |
-
|
3 |
-
import os
|
4 |
-
import json
|
5 |
-
import time
|
6 |
-
import ipywidgets as widgets
|
7 |
-
from ipywidgets import widgets, Layout, Label, Button, VBox, HBox
|
8 |
-
from IPython.display import display, HTML, Javascript, clear_output
|
9 |
-
|
10 |
-
|
11 |
-
# ================= DETECT ENV =================
|
12 |
-
def detect_environment():
|
13 |
-
free_plan = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024. ** 3) <= 20)
|
14 |
-
environments = {
|
15 |
-
'COLAB_GPU': ('Google Colab', "/root" if free_plan else "/content"),
|
16 |
-
'KAGGLE_URL_BASE': ('Kaggle', "/kaggle/working/content"),
|
17 |
-
'SAGEMAKER_INTERNAL_IMAGE_URI': ('SageMaker Studio Lab', "/home/studio-lab-user/content")
|
18 |
-
}
|
19 |
-
|
20 |
-
for env_var, (environment, path) in environments.items():
|
21 |
-
if env_var in os.environ:
|
22 |
-
return environment, path, free_plan
|
23 |
-
|
24 |
-
env, root_path, free_plan = detect_environment()
|
25 |
-
webui_path = f"{root_path}/sdw"
|
26 |
-
|
27 |
-
get_ipython().system('mkdir -p {root_path}')
|
28 |
-
# ----------------------------------------------
|
29 |
-
|
30 |
-
|
31 |
-
# ==================== CSS JS ====================
|
32 |
-
# custom background images (test)
|
33 |
-
import argparse
|
34 |
-
parser = argparse.ArgumentParser(description='This script processes an background image.')
|
35 |
-
parser.add_argument('-i', '--image', type=str, help='URL of the image to process', metavar='')
|
36 |
-
parser.add_argument('-o', '--opacity', type=float, help='Opacity level for the image, between 0 and 1', metavar='', default=0.3)
|
37 |
-
parser.add_argument('-b', '--blur', type=str, help='Blur level for the image', metavar='', default=0)
|
38 |
-
parser.add_argument('-y', type=int, help='Y coordinate for the image in px', metavar='', default=0)
|
39 |
-
parser.add_argument('-x', type=int, help='X coordinate for the image in px', metavar='', default=0)
|
40 |
-
parser.add_argument('-s', '--scale', type=int, help='Scale image in %%', metavar='', default=100)
|
41 |
-
parser.add_argument('-m', '--mode', type=str, help='Specify "no-repeat" so that the image pattern is not repeated.', metavar='', default='repeat')
|
42 |
-
parser.add_argument('-t', '--transparent', action='store_true', help='Flag to exclude z-index from CSS. Makes fields transparent')
|
43 |
-
args = parser.parse_args()
|
44 |
-
# ---
|
45 |
-
url_img, opacity_img, blur_img, y_img, x_img, scale_img, mode_img = args.image, args.opacity, args.blur, args.y, args.x, args.scale, args.mode
|
46 |
-
|
47 |
-
# WTF COLAB - WHAT THE FUCK IS THE DIFFERENCE OF 40 PIXELS!?!?!?
|
48 |
-
fix_heigh_img = "-780px"
|
49 |
-
if env == "Google Colab": # betrayal..
|
50 |
-
fix_heigh_img = "-740px"
|
51 |
-
|
52 |
-
container_background = f'''
|
53 |
-
<style>
|
54 |
-
:root {{
|
55 |
-
--img_background: url({url_img});
|
56 |
-
--img_opacity: {opacity_img};
|
57 |
-
--img_blur: {blur_img}px;
|
58 |
-
--image_y: {y_img}px;
|
59 |
-
--image_x: {x_img}px;
|
60 |
-
--img_scale: {scale_img}%;
|
61 |
-
--img_mode: {mode_img};
|
62 |
-
--img_height_dif: {fix_heigh_img}
|
63 |
-
}}
|
64 |
-
|
65 |
-
.widget-dropdown select,
|
66 |
-
.widget-text input[type="text"] {{
|
67 |
-
height: 30px;
|
68 |
-
background-color: #1c1c1c;
|
69 |
-
border: 1px solid #262626;
|
70 |
-
border-radius: 10px;
|
71 |
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
72 |
-
transition: all 0.3s ease-in-out;
|
73 |
-
'''
|
74 |
-
|
75 |
-
if not args.transparent:
|
76 |
-
container_background += " z-index: 1;\n</style>\n"
|
77 |
-
|
78 |
-
display(HTML(container_background))
|
79 |
-
# ---
|
80 |
-
|
81 |
-
CSS = '''
|
82 |
-
<style>
|
83 |
-
/* General Styles */
|
84 |
-
.header {
|
85 |
-
font-family: cursive;
|
86 |
-
font-size: 20px;
|
87 |
-
font-weight: bold;
|
88 |
-
color: #ff8cee;
|
89 |
-
margin-bottom: 15px;
|
90 |
-
user-select: none;
|
91 |
-
cursor: default;
|
92 |
-
display: inline-block;
|
93 |
-
}
|
94 |
-
|
95 |
-
hr {
|
96 |
-
border-color: grey;
|
97 |
-
background-color: grey;
|
98 |
-
opacity: 0.25;
|
99 |
-
}
|
100 |
-
|
101 |
-
a {
|
102 |
-
text-decoration: none;
|
103 |
-
color: inherit;
|
104 |
-
}
|
105 |
-
|
106 |
-
|
107 |
-
/* Container style */
|
108 |
-
|
109 |
-
.container {
|
110 |
-
position: relative;
|
111 |
-
background-color: #232323;
|
112 |
-
width: 1080px;
|
113 |
-
padding: 10px 15px;
|
114 |
-
border-radius: 15px;
|
115 |
-
box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
|
116 |
-
margin-bottom: 5px;
|
117 |
-
overflow: hidden;
|
118 |
-
}
|
119 |
-
|
120 |
-
.container::after {
|
121 |
-
position: absolute;
|
122 |
-
top: 5px;
|
123 |
-
right: 10px;
|
124 |
-
content: "ANXETY";
|
125 |
-
font-weight: bold;
|
126 |
-
font-size: 24px;
|
127 |
-
color: rgba(0, 0, 0, 0.2);
|
128 |
-
}
|
129 |
-
|
130 |
-
/* background img */
|
131 |
-
.container::before {
|
132 |
-
content: "";
|
133 |
-
position: absolute;
|
134 |
-
top: 0;
|
135 |
-
left: 0;
|
136 |
-
right: 0;
|
137 |
-
bottom: 0;
|
138 |
-
background-image: var(--img_background);
|
139 |
-
background-size: var(--img_scale);
|
140 |
-
background-repeat: var(--img_mode);
|
141 |
-
opacity: var(--img_opacity);
|
142 |
-
mix-blend-mode: screen;
|
143 |
-
pointer-events: none;
|
144 |
-
filter: blur(var(--img_blur));
|
145 |
-
}
|
146 |
-
|
147 |
-
.image_1::before {
|
148 |
-
background-position: var(--image_x) calc(-120px - var(--image_y));
|
149 |
-
}
|
150 |
-
.image_2::before {
|
151 |
-
background-position: var(--image_x) calc(-290px - var(--image_y));
|
152 |
-
}
|
153 |
-
.image_3::before {
|
154 |
-
background-position: var(--image_x) calc(-430px - var(--image_y));
|
155 |
-
}
|
156 |
-
.image_4::before {
|
157 |
-
background-position: var(--image_x) calc(var(--img_height_dif) - var(--image_y));
|
158 |
-
}
|
159 |
-
|
160 |
-
.container_custom_downlad {
|
161 |
-
height: 55px;
|
162 |
-
transition: all 0.5s;
|
163 |
-
}
|
164 |
-
|
165 |
-
.container_custom_downlad.expanded {
|
166 |
-
height: 270px;
|
167 |
-
}
|
168 |
-
|
169 |
-
|
170 |
-
/* Element text style */
|
171 |
-
|
172 |
-
.widget-html,
|
173 |
-
.widget-button,
|
174 |
-
.widget-text label,
|
175 |
-
.widget-checkbox label,
|
176 |
-
.widget-dropdown label,
|
177 |
-
.widget-dropdown select,
|
178 |
-
.widget-text input[type="text"] {
|
179 |
-
font-family: cursive;
|
180 |
-
font-size: 14px;
|
181 |
-
color: white !important;
|
182 |
-
user-select: none;
|
183 |
-
}
|
184 |
-
|
185 |
-
.widget-text input[type="text"]::placeholder {
|
186 |
-
color: grey;
|
187 |
-
}
|
188 |
-
|
189 |
-
|
190 |
-
/* Input field styles */
|
191 |
-
/*
|
192 |
-
.widget-dropdown select,
|
193 |
-
.widget-text input[type="text"] {
|
194 |
-
height: 30px;
|
195 |
-
background-color: #1c1c1c;
|
196 |
-
border: 1px solid #262626;
|
197 |
-
border-radius: 10px;
|
198 |
-
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
199 |
-
transition: all 0.3s ease-in-out;
|
200 |
-
}
|
201 |
-
*/
|
202 |
-
|
203 |
-
.widget-dropdown select:focus,
|
204 |
-
.widget-text input[type="text"]:focus {
|
205 |
-
border-color: #006ee5;
|
206 |
-
}
|
207 |
-
|
208 |
-
.widget-dropdown select:hover,
|
209 |
-
.widget-text input[type="text"]:hover {
|
210 |
-
transform: scale(1.003);
|
211 |
-
background-color: #262626;
|
212 |
-
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
|
213 |
-
}
|
214 |
-
|
215 |
-
|
216 |
-
/* Slider Checkbox style */
|
217 |
-
|
218 |
-
.widget-checkbox input[type="checkbox"] {
|
219 |
-
appearance: none;
|
220 |
-
position: relative;
|
221 |
-
top: 4px; /* Why is he taller?! */
|
222 |
-
width: 40px;
|
223 |
-
height: 20px;
|
224 |
-
border: none;
|
225 |
-
border-radius: 10px;
|
226 |
-
background-color: #20b2aa;
|
227 |
-
cursor: pointer;
|
228 |
-
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
|
229 |
-
transition: background-color 0.3s ease;
|
230 |
-
}
|
231 |
-
.widget-checkbox input[type="checkbox"]:checked {
|
232 |
-
background-color: #2196F3;
|
233 |
-
}
|
234 |
-
|
235 |
-
.widget-checkbox input[type="checkbox"]:before {
|
236 |
-
content: '';
|
237 |
-
position: absolute;
|
238 |
-
top: 50%;
|
239 |
-
left: 3px;
|
240 |
-
width: 16px;
|
241 |
-
height: 16px;
|
242 |
-
border-radius: inherit;
|
243 |
-
background-color: white;
|
244 |
-
box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
|
245 |
-
transform: translateY(-50%);
|
246 |
-
transition: left 0.3s ease;
|
247 |
-
}
|
248 |
-
.widget-checkbox input[type="checkbox"]:checked:before {
|
249 |
-
left: 21px;
|
250 |
-
}
|
251 |
-
|
252 |
-
|
253 |
-
/* Button styles */
|
254 |
-
|
255 |
-
.button_save {
|
256 |
-
font-size: 15px;
|
257 |
-
font-weight: bold;
|
258 |
-
width: 120px;
|
259 |
-
height: 35px;
|
260 |
-
border-radius: 15px;
|
261 |
-
background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
|
262 |
-
background-size: 200% 200%;
|
263 |
-
background-position: left bottom;
|
264 |
-
transition: background 0.5s ease-in-out, transform 0.3s ease;
|
265 |
-
}
|
266 |
-
|
267 |
-
.button_save:hover {
|
268 |
-
cursor: pointer;
|
269 |
-
background-image: radial-gradient(circle at top left, purple 10%, #93ac47 90%);
|
270 |
-
background-size: 200% 200%;
|
271 |
-
background-position: right bottom;
|
272 |
-
transform: translateY(1px);
|
273 |
-
}
|
274 |
-
|
275 |
-
.button_ngrok {
|
276 |
-
font-size: 12px;
|
277 |
-
height: 30px;
|
278 |
-
border-radius: 10px;
|
279 |
-
padding: 1px 12px;
|
280 |
-
background-image: radial-gradient(circle at top left, purple 10%, violet 90%);
|
281 |
-
background-size: 200% 200%;
|
282 |
-
background-position: left bottom;
|
283 |
-
transition: background 0.5s ease-in-out, transform 0.3s ease;
|
284 |
-
white-space: nowrap;
|
285 |
-
}
|
286 |
-
|
287 |
-
.button_ngrok:hover {
|
288 |
-
cursor: pointer;
|
289 |
-
background-image: radial-gradient(circle at top left, purple 10%, #1D94BB 90%);
|
290 |
-
background-size: 200% 200%;
|
291 |
-
background-position: right bottom;
|
292 |
-
transform: translateY(1px);
|
293 |
-
}
|
294 |
-
|
295 |
-
.button_save:active,
|
296 |
-
.button_ngrok:active {
|
297 |
-
filter: brightness(0.75) !important;
|
298 |
-
}
|
299 |
-
|
300 |
-
/* Removes ugly stroke from widget buttons. */
|
301 |
-
.jupyter-widgets.lm-Widget:focus {
|
302 |
-
outline: none;
|
303 |
-
}
|
304 |
-
|
305 |
-
|
306 |
-
/* Popup style of `FAQ` window */
|
307 |
-
|
308 |
-
.info {
|
309 |
-
position: absolute;
|
310 |
-
top: -5px;
|
311 |
-
right: 95px;
|
312 |
-
color: grey;
|
313 |
-
font-family: cursive;
|
314 |
-
font-size: 14px;
|
315 |
-
font-weight: normal;
|
316 |
-
user-select: none;
|
317 |
-
pointer-events: none;
|
318 |
-
opacity: 0;
|
319 |
-
transition: opacity 0.3s ease-in-out;
|
320 |
-
display: inline-block;
|
321 |
-
}
|
322 |
-
|
323 |
-
.popup {
|
324 |
-
position: absolute;
|
325 |
-
top: 120px;
|
326 |
-
z-index: 999;
|
327 |
-
width: auto;
|
328 |
-
padding: 10px;
|
329 |
-
text-align: center;
|
330 |
-
background-color: rgba(255, 255, 255, 0.05);
|
331 |
-
backdrop-filter: blur(20px);
|
332 |
-
border: 1px solid rgba(255, 255, 255, 0.45);
|
333 |
-
border-radius: 8px;
|
334 |
-
box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
|
335 |
-
opacity: 0;
|
336 |
-
color: #fff;
|
337 |
-
font-size: 16px;
|
338 |
-
font-family: cursive;
|
339 |
-
user-select: none;
|
340 |
-
cursor: default;
|
341 |
-
pointer-events: none;
|
342 |
-
transform: rotate(-5deg);
|
343 |
-
transition: top 0.3s ease-in-out, opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
|
344 |
-
}
|
345 |
-
|
346 |
-
.sample {
|
347 |
-
display: inline-block;
|
348 |
-
margin-top: 25px;
|
349 |
-
padding: 10px 100px;
|
350 |
-
background-color: rgba(255, 255, 255, 0.2);
|
351 |
-
color: #c6e2ff;
|
352 |
-
border: 2px solid rgba(255, 255, 255, 0.2);
|
353 |
-
border-radius: 8px;
|
354 |
-
box-shadow: 0 0 10px rgba(255, 255, 255, 0.2), inset 0 0 25px rgba(255, 255, 255, 0.2);
|
355 |
-
}
|
356 |
-
|
357 |
-
.info.showed {
|
358 |
-
opacity: 1;
|
359 |
-
pointer-events: auto;
|
360 |
-
}
|
361 |
-
|
362 |
-
.info:hover + .popup {
|
363 |
-
top: 35px;
|
364 |
-
opacity: 1;
|
365 |
-
pointer-events: initial;
|
366 |
-
transform: rotate(0deg);
|
367 |
-
}
|
368 |
-
|
369 |
-
|
370 |
-
/* Animation of elements */
|
371 |
-
|
372 |
-
.container,
|
373 |
-
.button_save {
|
374 |
-
animation-name: showedWidgets;
|
375 |
-
animation-duration: 1s;
|
376 |
-
animation-fill-mode: forwards;
|
377 |
-
}
|
378 |
-
|
379 |
-
.container.hide,
|
380 |
-
.button_save.hide {
|
381 |
-
animation-name: hideWidgets;
|
382 |
-
animation-duration: 0.5s;
|
383 |
-
animation-fill-mode: forwards;
|
384 |
-
}
|
385 |
-
|
386 |
-
@keyframes showedWidgets {
|
387 |
-
0% {
|
388 |
-
transform: translate3d(-65%, 15%, 0) scale(0) rotate(15deg);
|
389 |
-
filter: blur(25px) grayscale(1) brightness(0.3);
|
390 |
-
opacity: 0;
|
391 |
-
}
|
392 |
-
100% {
|
393 |
-
transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
|
394 |
-
filter: blur(0) grayscale(0) brightness(1);
|
395 |
-
opacity: 1;
|
396 |
-
}
|
397 |
-
}
|
398 |
-
|
399 |
-
@keyframes hideWidgets {
|
400 |
-
0% {
|
401 |
-
transform: translate3d(0, 0, 0) scale(1) rotate3d(1, 0, 0, 0deg);
|
402 |
-
filter: blur(0) grayscale(0) brightness(1);
|
403 |
-
opacity: 1;
|
404 |
-
}
|
405 |
-
100% {
|
406 |
-
transform: translate3d(0, 5%, 0) scale(0.9) rotate3d(1, 0, 0, 90deg);
|
407 |
-
filter: blur(15px) grayscale(1) brightness(0.5);
|
408 |
-
opacity: 0;
|
409 |
-
}
|
410 |
-
}
|
411 |
-
</style>
|
412 |
-
|
413 |
-
<!-- TOGGLE 'CustomDL' SCRIPT -->
|
414 |
-
<script>
|
415 |
-
function toggleContainer() {
|
416 |
-
let downloadContainer = document.querySelector('.container_custom_downlad');
|
417 |
-
let info = document.querySelector('.info');
|
418 |
-
|
419 |
-
downloadContainer.classList.toggle('expanded');
|
420 |
-
info.classList.toggle('showed');
|
421 |
-
}
|
422 |
-
</script>
|
423 |
-
'''
|
424 |
-
|
425 |
-
display(HTML(CSS))
|
426 |
-
# ==================== CSS JS ====================
|
427 |
-
|
428 |
-
|
429 |
-
# ==================== WIDGETS ====================
|
430 |
-
# --- global widgets ---
|
431 |
-
style = {'description_width': 'initial'}
|
432 |
-
layout = widgets.Layout(min_width='1047px')
|
433 |
-
|
434 |
-
HR = widgets.HTML('<hr>')
|
435 |
-
|
436 |
-
# --- MODEL ---
|
437 |
-
model_header = widgets.HTML('<div class="header">Выбор Модели<div>')
|
438 |
-
model_options = ['none',
|
439 |
-
'1.Anime (by XpucT) + INP',
|
440 |
-
'2.BluMix [Anime] [V7]',
|
441 |
-
'3.Cetus-Mix [Anime] [V4] + INP',
|
442 |
-
'4.Counterfeit [Anime] [V3] + INP',
|
443 |
-
'5.CuteColor [Anime] [V3]',
|
444 |
-
'6.Dark-Sushi-Mix [Anime]',
|
445 |
-
'7.Deliberate [Realism] [V6] + INP',
|
446 |
-
'8.Meina-Mix [Anime] [V11] + INP',
|
447 |
-
'9.Mix-Pro [Anime] [V4] + INP']
|
448 |
-
# ---
|
449 |
-
Model_widget = widgets.Dropdown(options=model_options, value='4.Counterfeit [Anime] [V3] + INP', description='Модель:', style=style, layout=layout)
|
450 |
-
Model_Num_widget = widgets.Text(description='Номер Модели:', placeholder='Введите номера моделей для скачивания через запятую/пробел.', style=style, layout=layout)
|
451 |
-
Inpainting_Model_widget = widgets.Checkbox(value=False, description='Inpainting Модели', style=style)
|
452 |
-
|
453 |
-
''' Display Model'''
|
454 |
-
all_model_box = widgets.VBox([model_header, Model_widget, Model_Num_widget, Inpainting_Model_widget]).add_class("container").add_class("image_1")
|
455 |
-
display(all_model_box)
|
456 |
-
|
457 |
-
# --- VAE ---
|
458 |
-
vae_header = widgets.HTML('<div class="header" >Выбор VAE</div>')
|
459 |
-
vae_options = ['none',
|
460 |
-
'1.Anime.vae',
|
461 |
-
'2.Anything.vae',
|
462 |
-
'3.Blessed2.vae',
|
463 |
-
'4.ClearVae.vae',
|
464 |
-
'5.WD.vae']
|
465 |
-
Vae_widget = widgets.Dropdown(options=vae_options, value='3.Blessed2.vae', description='Vae:', style=style, layout=layout)
|
466 |
-
Vae_Num_widget = widgets.Text(description='Номер Vae:', placeholder='Введите номера vae для скачивания через запятую/пробел.', style=style, layout=layout)
|
467 |
-
|
468 |
-
''' Display Vae'''
|
469 |
-
all_vae_box= widgets.VBox([vae_header, Vae_widget, Vae_Num_widget]).add_class("container").add_class("image_2")
|
470 |
-
display(all_vae_box)
|
471 |
-
|
472 |
-
# --- ADDITIONAL ---
|
473 |
-
additional_header = widgets.HTML('<div class="header">Дополнительно</div>')
|
474 |
-
latest_webui_widget = widgets.Checkbox(value=True, description='Обновить WebUI', style=style)
|
475 |
-
latest_exstensions_widget = widgets.Checkbox(value=True, description='Обновить Расширения', style=style)
|
476 |
-
detailed_download_widget = widgets.Dropdown(options=['off', 'on'], value='off', description='Подробная Загрузка:', style=style)
|
477 |
-
latest_changes_widget = HBox([latest_webui_widget, latest_exstensions_widget, detailed_download_widget], layout=widgets.Layout(justify_content='space-between'))
|
478 |
-
controlnet_options = ['none', 'ALL', '1.canny',
|
479 |
-
'2.openpose', '3.depth',
|
480 |
-
'4.normal_map', '5.mlsd',
|
481 |
-
'6.lineart', '7.soft_edge',
|
482 |
-
'8.scribble', '9.segmentation',
|
483 |
-
'10.shuffle', '11.tile',
|
484 |
-
'12.inpaint', '13.instruct_p2p']
|
485 |
-
# ---
|
486 |
-
controlnet_widget = widgets.Dropdown(options=controlnet_options, value='none', description='ControlNet:', style=style, layout=layout)
|
487 |
-
controlnet_Num_widget = widgets.Text(description='Номер ControlNet:', placeholder='Введите номера моделей ControlNet для скачивания через запятую/пробел.', style=style, layout=layout)
|
488 |
-
commit_hash_widget = widgets.Text(description='Commit Hash:', style=style, layout=layout)
|
489 |
-
optional_huggingface_token_widget = widgets.Text(description='Токен HuggingFace:', style=style, layout=layout)
|
490 |
-
ngrok_token_widget = widgets.Text(description='Токен Ngrok:', style=style, layout=widgets.Layout(width='1047px'))
|
491 |
-
ngrock_button = widgets.HTML('<a href="https://dashboard.ngrok.com/get-started/your-authtoken" target="_blank">Получить Ngrok Токен</a>').add_class("button_ngrok")
|
492 |
-
ngrok_widget = widgets.HBox([ngrok_token_widget, ngrock_button], style=style, layout=layout)
|
493 |
-
zrok_token_widget = widgets.Text(description='Zrok Token:', style=style, layout=widgets.Layout(width='1047px'))
|
494 |
-
zrok_button = widgets.HTML('<a href="https://colab.research.google.com/drive/1d2sjWDJi_GYBUavrHSuQyHTDuLy36WpU" target="_blank">Зарегать Zrok Токен</a>').add_class("button_ngrok")
|
495 |
-
zrok_widget = widgets.HBox([zrok_token_widget, zrok_button], style=style, layout=layout)
|
496 |
-
# ---
|
497 |
-
commandline_arguments_options = "--listen --enable-insecure-extension-access --theme dark --no-half-vae --disable-console-progressbars --xformers"
|
498 |
-
commandline_arguments_widget = widgets.Text(description='Аргументы:', value=commandline_arguments_options, style=style, layout=layout)
|
499 |
-
|
500 |
-
''' Display Additional'''
|
501 |
-
additional_widget_list = [additional_header, latest_changes_widget, HR, controlnet_widget, controlnet_Num_widget, commit_hash_widget, optional_huggingface_token_widget, ngrok_widget, zrok_widget, HR, commandline_arguments_widget]
|
502 |
-
if free_plan and env == "Google Colab": # remove ngrok from colab
|
503 |
-
additional_widget_list.remove(ngrok_widget)
|
504 |
-
if env == "SageMaker Studio Lab": # remove zrok from sagemaker
|
505 |
-
additional_widget_list.remove(zrok_widget)
|
506 |
-
# ```
|
507 |
-
all_additional_box = widgets.VBox(additional_widget_list).add_class("container").add_class("image_3")
|
508 |
-
display(all_additional_box)
|
509 |
-
|
510 |
-
# --- CUSTOM DOWNLOAD ---
|
511 |
-
custom_download_header_popup = widgets.HTML('''
|
512 |
-
<style>
|
513 |
-
/* Color */
|
514 |
-
.sample_label {color: #dbafff;}
|
515 |
-
.braces {color: #ffff00;}
|
516 |
-
.extension {color: #eb934b;}
|
517 |
-
.file_name {color: #ffffd8;}
|
518 |
-
</style>
|
519 |
-
|
520 |
-
<div class="header" style="cursor: pointer;" onclick="toggleContainer()">Кастомная Загрузка</div>
|
521 |
-
<!-- PopUp window -->
|
522 |
-
<div class="info" id="info_dl">INFO</div>
|
523 |
-
<div class="popup">
|
524 |
-
Разделите несколько URL-адресов запятой/пробелом. Для <span class="file_name">пользовательского имени</span> файла/расширения укажите его через <span class="braces">[]</span>
|
525 |
-
после URL без пробелов.
|
526 |
-
<span style="color: #ff9999">Для файлов обязательно укажите</span> - <span class="extension">Расширение Файла.</span>
|
527 |
-
<div class="sample">
|
528 |
-
<span class="sample_label">Пример для Файла:</span>
|
529 |
-
https://civitai.com/api/download/models/229782<span class="braces">[</span><span class="file_name">Detailer</span><span class="extension">.safetensors</span><span class="braces">]</span>
|
530 |
-
<br>
|
531 |
-
<span class="sample_label">Пример для Расширения:</span>
|
532 |
-
https://github.com/hako-mikan/sd-webui-regional-prompter<span class="braces">[</span><span class="file_name">Regional-Prompter</span><span class="braces">]</span>
|
533 |
-
</div>
|
534 |
-
</div>
|
535 |
-
''')
|
536 |
-
# ---
|
537 |
-
Model_url_widget = widgets.Text(description='Model:', style=style, layout=layout)
|
538 |
-
Vae_url_widget = widgets.Text(description='Vae:', style=style, layout=layout)
|
539 |
-
LoRA_url_widget = widgets.Text(description='LoRa:', style=style, layout=layout)
|
540 |
-
Embedding_url_widget = widgets.Text(description='Embedding:', style=style, layout=layout)
|
541 |
-
Extensions_url_widget = widgets.Text(description='Extensions:', style=style, layout=layout)
|
542 |
-
custom_file_urls_widget = widgets.Text(description='Файл (txt):', style=style, layout=layout)
|
543 |
-
|
544 |
-
''' Display CustomDl'''
|
545 |
-
all_custom_box = widgets.VBox([
|
546 |
-
custom_download_header_popup, Model_url_widget, Vae_url_widget, LoRA_url_widget, Embedding_url_widget, Extensions_url_widget, custom_file_urls_widget
|
547 |
-
]).add_class("container").add_class("image_4").add_class("container_custom_downlad")
|
548 |
-
display(all_custom_box)
|
549 |
-
|
550 |
-
# --- Save Button ---
|
551 |
-
save_button = widgets.Button(description='Сохранить').add_class("button_save")
|
552 |
-
display(save_button)
|
553 |
-
|
554 |
-
|
555 |
-
# ============ Load / Save - Settings V2 ============
|
556 |
-
SETTINGS_FILE = f'{root_path}/settings.json'
|
557 |
-
|
558 |
-
settings_keys = [
|
559 |
-
'Model', 'Model_Num', 'Inpainting_Model',
|
560 |
-
'Vae', 'Vae_Num',
|
561 |
-
'latest_webui', 'latest_exstensions', 'detailed_download',
|
562 |
-
'controlnet', 'controlnet_Num', 'commit_hash', 'optional_huggingface_token',
|
563 |
-
'ngrok_token', 'zrok_token', 'commandline_arguments',
|
564 |
-
'Model_url', 'Vae_url', 'LoRA_url', 'Embedding_url', 'Extensions_url', 'custom_file_urls'
|
565 |
-
]
|
566 |
-
|
567 |
-
def save_settings():
|
568 |
-
settings = {key: globals()[f"{key}_widget"].value for key in settings_keys}
|
569 |
-
with open(SETTINGS_FILE, 'w') as f:
|
570 |
-
json.dump(settings, f)
|
571 |
-
|
572 |
-
def load_settings():
|
573 |
-
if os.path.exists(SETTINGS_FILE):
|
574 |
-
with open(SETTINGS_FILE, 'r') as f:
|
575 |
-
settings = json.load(f)
|
576 |
-
for key in settings_keys:
|
577 |
-
globals()[f"{key}_widget"].value = settings.get(key)
|
578 |
-
|
579 |
-
def save_data(button):
|
580 |
-
save_settings()
|
581 |
-
|
582 |
-
# --- uhh - hide... ---
|
583 |
-
widgets_list = [all_model_box, all_vae_box, all_additional_box, all_custom_box, save_button]
|
584 |
-
for widget in widgets_list:
|
585 |
-
widget.add_class("hide")
|
586 |
-
time.sleep(0.5)
|
587 |
-
|
588 |
-
widgets.Widget.close_all()
|
589 |
-
|
590 |
-
settings = load_settings()
|
591 |
-
save_button.on_click(save_data)
|
592 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|