test new downlaod lib system
Browse files- files_cells/notebooks/en/auto-cleaner_en.ipynb +17 -37
- files_cells/notebooks/en/downloading_en.ipynb +20 -16
- files_cells/notebooks/en/widgets_en.ipynb +19 -14
- files_cells/notebooks/ru/auto-cleaner_ru.ipynb +16 -36
- files_cells/notebooks/ru/downloading_ru.ipynb +67 -42
- files_cells/notebooks/ru/widgets_ru.ipynb +19 -14
- files_cells/python/en/auto-cleaner_en.py +17 -37
- files_cells/python/en/downloading_en.py +20 -16
- files_cells/python/en/widgets_en.py +19 -14
- files_cells/python/ru/auto-cleaner_ru.py +16 -36
- files_cells/python/ru/downloading_ru.py +67 -42
- files_cells/python/ru/widgets_ru.py +19 -14
files_cells/notebooks/en/auto-cleaner_en.ipynb
CHANGED
|
@@ -52,15 +52,6 @@
|
|
| 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",
|
|
@@ -259,6 +250,15 @@
|
|
| 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",
|
|
@@ -270,20 +270,6 @@
|
|
| 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",
|
|
@@ -291,10 +277,9 @@
|
|
| 291 |
" free = disk_space.free / (1024 ** 3)\n",
|
| 292 |
"\n",
|
| 293 |
" storage_info.value = f'''\n",
|
| 294 |
-
" <div class=\"storage_info_AC\"
|
| 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",
|
|
@@ -312,28 +297,23 @@
|
|
| 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\":
|
| 326 |
-
" \"Models\":
|
| 327 |
-
" \"Vae\":
|
| 328 |
-
" \"LoRa\":
|
| 329 |
-
" \"ControlNet Models\":
|
| 330 |
" }\n",
|
| 331 |
-
" deleted_word_variants = [\"Deleted\", \"Deleted\", \"Deleted\"]\n",
|
| 332 |
" for key, value in deleted_files_dict.items():\n",
|
| 333 |
-
"
|
| 334 |
-
"
|
| 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",
|
|
|
|
| 52 |
"# ----------------------------------------------\n",
|
| 53 |
"\n",
|
| 54 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
"# ==================== CSS ====================\n",
|
| 56 |
"CSS = \"\"\"\n",
|
| 57 |
"<style>\n",
|
|
|
|
| 250 |
"\n",
|
| 251 |
"\n",
|
| 252 |
"# ================ AutoCleaner function ================\n",
|
| 253 |
+
"directories = {\n",
|
| 254 |
+
" \"Images\": f\"{webui_path}/outputs\",\n",
|
| 255 |
+
" \"Models\": f\"{webui_path}/models/Stable-diffusion/\",\n",
|
| 256 |
+
" \"Vae\": f\"{webui_path}/models/VAE/\",\n",
|
| 257 |
+
" \"LoRa\": f\"{webui_path}/models/Lora/\",\n",
|
| 258 |
+
" \"ControlNet Models\": f\"{webui_path}/models/ControlNet/\"\n",
|
| 259 |
+
"}\n",
|
| 260 |
+
"\n",
|
| 261 |
+
"\"\"\" functions \"\"\"\n",
|
| 262 |
"def clean_directory(directory):\n",
|
| 263 |
" deleted_files = 0\n",
|
| 264 |
" for root, dirs, files in os.walk(directory):\n",
|
|
|
|
| 270 |
" deleted_files += 1\n",
|
| 271 |
" return deleted_files\n",
|
| 272 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
"def update_memory_info():\n",
|
| 274 |
" disk_space = psutil.disk_usage(os.getcwd())\n",
|
| 275 |
" total = disk_space.total / (1024 ** 3)\n",
|
|
|
|
| 277 |
" free = disk_space.free / (1024 ** 3)\n",
|
| 278 |
"\n",
|
| 279 |
" storage_info.value = f'''\n",
|
| 280 |
+
" <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",
|
| 281 |
" '''\n",
|
| 282 |
"\n",
|
|
|
|
| 283 |
"def on_execute_button_press(button):\n",
|
| 284 |
" selected_cleaners = auto_cleaner_widget.value\n",
|
| 285 |
" deleted_files_dict = {}\n",
|
|
|
|
| 297 |
"\n",
|
| 298 |
" update_memory_info()\n",
|
| 299 |
"\n",
|
|
|
|
| 300 |
"def on_clear_button_press(button):\n",
|
| 301 |
" container.add_class(\"hide\")\n",
|
| 302 |
" time.sleep(0.5)\n",
|
| 303 |
" widgets.Widget.close_all()\n",
|
| 304 |
"\n",
|
|
|
|
| 305 |
"def generate_messages(deleted_files_dict):\n",
|
| 306 |
" messages = []\n",
|
| 307 |
" word_variants = {\n",
|
| 308 |
+
" \"Images\": \"Images\",\n",
|
| 309 |
+
" \"Models\": \"Models\",\n",
|
| 310 |
+
" \"Vae\": \"Vae\",\n",
|
| 311 |
+
" \"LoRa\": \"LoRa\",\n",
|
| 312 |
+
" \"ControlNet Models\": \"ControlNet Models\"\n",
|
| 313 |
" }\n",
|
|
|
|
| 314 |
" for key, value in deleted_files_dict.items():\n",
|
| 315 |
+
" object_word = word_variants.get(key)\n",
|
| 316 |
+
" messages.append(f\"Deleted {value} {object_word}\")\n",
|
|
|
|
|
|
|
| 317 |
" return messages\n",
|
| 318 |
"# ================ AutoCleaner function ================\n",
|
| 319 |
"\n",
|
files_cells/notebooks/en/downloading_en.ipynb
CHANGED
|
@@ -191,28 +191,32 @@
|
|
| 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 |
-
"
|
| 195 |
-
"
|
| 196 |
-
"
|
| 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 |
-
"
|
| 205 |
-
"!sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js\n",
|
| 206 |
"\n",
|
| 207 |
-
"
|
| 208 |
-
"
|
| 209 |
-
"
|
| 210 |
-
"
|
| 211 |
-
"
|
| 212 |
-
"
|
| 213 |
-
"
|
| 214 |
-
"
|
| 215 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
"\n",
|
| 217 |
"\n",
|
| 218 |
"## Version switching\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 |
" del cap\n",
|
| 198 |
" print(f\"\\r✨ {action} Completed!\")\n",
|
| 199 |
"\n",
|
| 200 |
"\n",
|
| 201 |
"# === FIXING ERRORS ===\n",
|
| 202 |
+
"anxety_repos = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main\"\n",
|
|
|
|
| 203 |
"\n",
|
| 204 |
+
"with capture.capture_output() as cap:\n",
|
| 205 |
+
" # --- Encrypt-Image ---\n",
|
| 206 |
+
" !sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js\n",
|
| 207 |
+
"\n",
|
| 208 |
+
" # --- Additional-Networks ---\n",
|
| 209 |
+
" !wget -O {webui_path}/extensions/additional-networks/scripts/metadata_editor.py {anxety_repos}/extensions/Additional-Networks/fix/metadata_editor.py\n",
|
| 210 |
+
"\n",
|
| 211 |
+
" # --= SageMaker =--\n",
|
| 212 |
+
" if env == \"SageMaker Studio Lab\":\n",
|
| 213 |
+
" with capture.capture_output() as cap:\n",
|
| 214 |
+
" # --- SuperMerger Remove ---\n",
|
| 215 |
+
" if os.path.exists(f\"{webui_path}/extensions/supermerger\"):\n",
|
| 216 |
+
" !rm -rf {webui_path}/extensions/supermerger\n",
|
| 217 |
+
" # --- Launch (Style) ---\n",
|
| 218 |
+
" !wget -O {webui_path}/modules/styles.py {anxety_repos}/sagemaker/fixing/webui/styles.py\n",
|
| 219 |
+
"del cap\n",
|
| 220 |
"\n",
|
| 221 |
"\n",
|
| 222 |
"## Version switching\n",
|
files_cells/notebooks/en/widgets_en.ipynb
CHANGED
|
@@ -48,7 +48,7 @@
|
|
| 48 |
"\n",
|
| 49 |
"\n",
|
| 50 |
"# ==================== CSS JS ====================\n",
|
| 51 |
-
"# custom background images V1.
|
| 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",
|
|
@@ -57,8 +57,9 @@
|
|
| 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',
|
| 61 |
-
"parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35
|
|
|
|
| 62 |
"args = parser.parse_args()\n",
|
| 63 |
"\"\"\"---\"\"\"\n",
|
| 64 |
"url_img = args.image\n",
|
|
@@ -67,16 +68,18 @@
|
|
| 67 |
"y_img = args.y\n",
|
| 68 |
"x_img = args.x\n",
|
| 69 |
"scale_img = args.scale\n",
|
| 70 |
-
"
|
| 71 |
"\n",
|
| 72 |
-
"
|
| 73 |
-
"
|
| 74 |
-
"if env
|
| 75 |
-
"
|
| 76 |
-
"
|
| 77 |
-
"t_bg_alpha = \"1\"\n",
|
| 78 |
-
"
|
| 79 |
-
"
|
|
|
|
|
|
|
| 80 |
"\n",
|
| 81 |
"container_background = f'''\n",
|
| 82 |
"<style>\n",
|
|
@@ -94,6 +97,7 @@
|
|
| 94 |
" /* for fields */\n",
|
| 95 |
" --bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */\n",
|
| 96 |
" --bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */\n",
|
|
|
|
| 97 |
"}}\n",
|
| 98 |
"'''\n",
|
| 99 |
"\n",
|
|
@@ -220,6 +224,7 @@
|
|
| 220 |
" border-radius: 10px;\n",
|
| 221 |
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
| 222 |
" transition: all 0.3s ease-in-out;\n",
|
|
|
|
| 223 |
"}\n",
|
| 224 |
"\n",
|
| 225 |
".widget-dropdown select:focus,\n",
|
|
@@ -329,7 +334,7 @@
|
|
| 329 |
"}\n",
|
| 330 |
"\n",
|
| 331 |
"\n",
|
| 332 |
-
"/* Popup style of `
|
| 333 |
"\n",
|
| 334 |
".info {\n",
|
| 335 |
" position: absolute;\n",
|
|
@@ -593,7 +598,7 @@
|
|
| 593 |
"def save_settings():\n",
|
| 594 |
" settings = {key: globals()[f\"{key}_widget\"].value for key in settings_keys}\n",
|
| 595 |
" with open(SETTINGS_FILE, 'w') as f:\n",
|
| 596 |
-
" json.dump(settings, f)\n",
|
| 597 |
"\n",
|
| 598 |
"def load_settings():\n",
|
| 599 |
" if os.path.exists(SETTINGS_FILE):\n",
|
|
|
|
| 48 |
"\n",
|
| 49 |
"\n",
|
| 50 |
"# ==================== CSS JS ====================\n",
|
| 51 |
+
"# custom background images V1.5\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",
|
|
|
|
| 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', action='store_true', help='Removes repetitive image tiles')\n",
|
| 61 |
+
"parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')\n",
|
| 62 |
+
"parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)\n",
|
| 63 |
"args = parser.parse_args()\n",
|
| 64 |
"\"\"\"---\"\"\"\n",
|
| 65 |
"url_img = args.image\n",
|
|
|
|
| 68 |
"y_img = args.y\n",
|
| 69 |
"x_img = args.x\n",
|
| 70 |
"scale_img = args.scale\n",
|
| 71 |
+
"blur_fields = args.blur_fields\n",
|
| 72 |
"\n",
|
| 73 |
+
"## ---\n",
|
| 74 |
+
"\"\"\" WTF COLAB - WHAT THE FUCK IS THE DIFFERENCE OF 35 PIXELS!?!?!? \"\"\"\n",
|
| 75 |
+
"fix_heigh_img = \"-810px\" if env != \"Google Colab\" else \"-775px\"\n",
|
| 76 |
+
"\n",
|
| 77 |
+
"\"\"\" transperent fields \"\"\"\n",
|
| 78 |
+
"t_bg_alpha = \"1\" if not args.transparent else \"0.65\"\n",
|
| 79 |
+
"\n",
|
| 80 |
+
"\"\"\" mode img - repeats \"\"\"\n",
|
| 81 |
+
"mode_img = \"repeat\" if not args.mode else \"no-repeat\"\n",
|
| 82 |
+
"## ---\n",
|
| 83 |
"\n",
|
| 84 |
"container_background = f'''\n",
|
| 85 |
"<style>\n",
|
|
|
|
| 97 |
" /* for fields */\n",
|
| 98 |
" --bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */\n",
|
| 99 |
" --bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */\n",
|
| 100 |
+
" --bg-field-blur-level: {blur_fields}px;\n",
|
| 101 |
"}}\n",
|
| 102 |
"'''\n",
|
| 103 |
"\n",
|
|
|
|
| 224 |
" border-radius: 10px;\n",
|
| 225 |
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
| 226 |
" transition: all 0.3s ease-in-out;\n",
|
| 227 |
+
" backdrop-filter: blur(var(--bg-field-blur-level));\n",
|
| 228 |
"}\n",
|
| 229 |
"\n",
|
| 230 |
".widget-dropdown select:focus,\n",
|
|
|
|
| 334 |
"}\n",
|
| 335 |
"\n",
|
| 336 |
"\n",
|
| 337 |
+
"/* Popup style of `INFO` window */\n",
|
| 338 |
"\n",
|
| 339 |
".info {\n",
|
| 340 |
" position: absolute;\n",
|
|
|
|
| 598 |
"def save_settings():\n",
|
| 599 |
" settings = {key: globals()[f\"{key}_widget\"].value for key in settings_keys}\n",
|
| 600 |
" with open(SETTINGS_FILE, 'w') as f:\n",
|
| 601 |
+
" json.dump(settings, f, indent=2)\n",
|
| 602 |
"\n",
|
| 603 |
"def load_settings():\n",
|
| 604 |
" if os.path.exists(SETTINGS_FILE):\n",
|
files_cells/notebooks/ru/auto-cleaner_ru.ipynb
CHANGED
|
@@ -52,15 +52,6 @@
|
|
| 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",
|
|
@@ -259,6 +250,15 @@
|
|
| 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",
|
|
@@ -270,20 +270,6 @@
|
|
| 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",
|
|
@@ -294,7 +280,6 @@
|
|
| 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",
|
|
@@ -312,28 +297,23 @@
|
|
| 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 |
-
" \"Изображения\":
|
| 326 |
-
" \"Модели\":
|
| 327 |
-
" \"Vae\":
|
| 328 |
-
" \"LoRa\":
|
| 329 |
-
" \"ControlNet Модели\":
|
| 330 |
" }\n",
|
| 331 |
-
" deleted_word_variants = [\"Удалена\", \"Удалены\", \"Удалено\"]\n",
|
| 332 |
" for key, value in deleted_files_dict.items():\n",
|
| 333 |
-
"
|
| 334 |
-
"
|
| 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",
|
|
|
|
| 52 |
"# ----------------------------------------------\n",
|
| 53 |
"\n",
|
| 54 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
"# ==================== CSS ====================\n",
|
| 56 |
"CSS_AC = \"\"\"\n",
|
| 57 |
"<style>\n",
|
|
|
|
| 250 |
"\n",
|
| 251 |
"\n",
|
| 252 |
"# ================ AutoCleaner function ================\n",
|
| 253 |
+
"directories = {\n",
|
| 254 |
+
" \"Изображения\": f\"{webui_path}/outputs\",\n",
|
| 255 |
+
" \"Модели\": f\"{webui_path}/models/Stable-diffusion/\",\n",
|
| 256 |
+
" \"Vae\": f\"{webui_path}/models/VAE/\",\n",
|
| 257 |
+
" \"LoRa\": f\"{webui_path}/models/Lora/\",\n",
|
| 258 |
+
" \"ControlNet Модели\": f\"{webui_path}/models/ControlNet/\"\n",
|
| 259 |
+
"}\n",
|
| 260 |
+
"\n",
|
| 261 |
+
"\"\"\" functions \"\"\"\n",
|
| 262 |
"def clean_directory(directory):\n",
|
| 263 |
" deleted_files = 0\n",
|
| 264 |
" for root, dirs, files in os.walk(directory):\n",
|
|
|
|
| 270 |
" deleted_files += 1\n",
|
| 271 |
" return deleted_files\n",
|
| 272 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
"def update_memory_info():\n",
|
| 274 |
" disk_space = psutil.disk_usage(os.getcwd())\n",
|
| 275 |
" total = disk_space.total / (1024 ** 3)\n",
|
|
|
|
| 280 |
" <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",
|
| 281 |
" '''\n",
|
| 282 |
"\n",
|
|
|
|
| 283 |
"def on_execute_button_press(button):\n",
|
| 284 |
" selected_cleaners = auto_cleaner_widget.value\n",
|
| 285 |
" deleted_files_dict = {}\n",
|
|
|
|
| 297 |
"\n",
|
| 298 |
" update_memory_info()\n",
|
| 299 |
"\n",
|
|
|
|
| 300 |
"def on_clear_button_press(button):\n",
|
| 301 |
" container.add_class(\"hide\")\n",
|
| 302 |
" time.sleep(0.5)\n",
|
| 303 |
" widgets.Widget.close_all()\n",
|
| 304 |
"\n",
|
|
|
|
| 305 |
"def generate_messages(deleted_files_dict):\n",
|
| 306 |
" messages = []\n",
|
| 307 |
" word_variants = {\n",
|
| 308 |
+
" \"Изображения\": \"Изображений\",\n",
|
| 309 |
+
" \"Модели\": \"Моделей\",\n",
|
| 310 |
+
" \"Vae\": \"Vae\",\n",
|
| 311 |
+
" \"LoRa\": \"LoRa\",\n",
|
| 312 |
+
" \"ControlNet Модели\": \"ControlNet Моделей\"\n",
|
| 313 |
" }\n",
|
|
|
|
| 314 |
" for key, value in deleted_files_dict.items():\n",
|
| 315 |
+
" object_word = word_variants.get(key)\n",
|
| 316 |
+
" messages.append(f\"Удалено {value} {object_word}\")\n",
|
|
|
|
|
|
|
| 317 |
" return messages\n",
|
| 318 |
"# ================ AutoCleaner function ================\n",
|
| 319 |
"\n",
|
files_cells/notebooks/ru/downloading_ru.ipynb
CHANGED
|
@@ -60,43 +60,64 @@
|
|
| 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 |
-
"
|
| 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 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
"
|
| 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 |
-
"
|
| 91 |
-
"
|
| 92 |
-
"
|
| 93 |
-
" !pip install -q {torch} -U\n",
|
| 94 |
-
" !pip install -q {xformers} -U\n",
|
| 95 |
"\n",
|
| 96 |
-
"
|
| 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",
|
|
@@ -191,28 +212,32 @@
|
|
| 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 |
-
"
|
| 195 |
-
"
|
| 196 |
-
"
|
| 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 |
-
"
|
| 205 |
-
"!sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js\n",
|
| 206 |
"\n",
|
| 207 |
-
"
|
| 208 |
-
"
|
| 209 |
-
"
|
| 210 |
-
"
|
| 211 |
-
"
|
| 212 |
-
"
|
| 213 |
-
"
|
| 214 |
-
"
|
| 215 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
"\n",
|
| 217 |
"\n",
|
| 218 |
"## Version switching\n",
|
|
|
|
| 60 |
" clear_output()\n",
|
| 61 |
"\n",
|
| 62 |
"\n",
|
| 63 |
+
"# ================ LIBRARIES V2 ================\n",
|
| 64 |
"flag_file = f\"{root_path}/libraries_installed.txt\"\n",
|
| 65 |
"\n",
|
| 66 |
"if not os.path.exists(flag_file):\n",
|
| 67 |
+
" print(\"💿 Установка библиотек, это займет какое-то время...\\n\")\n",
|
|
|
|
|
|
|
| 68 |
"\n",
|
| 69 |
+
" install_lib = {\n",
|
| 70 |
+
" \"gdown\": \"pip install -U gdown\",\n",
|
| 71 |
+
" \"aria2\": \"apt-get update && apt -y install aria2\",\n",
|
| 72 |
+
" \"localtunnel\": \"npm install -g localtunnel &> /dev/null\",\n",
|
| 73 |
+
" \"insightface\": \"pip install insightface\",\n",
|
| 74 |
+
" }\n",
|
| 75 |
+
"\n",
|
| 76 |
+
" # Dictionary of additional libraries specific to certain environments\n",
|
| 77 |
+
" additional_libs = {\n",
|
| 78 |
+
" \"Google Colab\": {\n",
|
| 79 |
+
" \"xformers\": \"pip install xformers==0.0.25 --no-deps\"\n",
|
| 80 |
+
" },\n",
|
| 81 |
+
" \"Kaggle\": {\n",
|
| 82 |
+
" \"xformers\": \"pip install -q xformers==0.0.23.post1 triton==2.1.0\",\n",
|
| 83 |
+
" \"torch\": \"pip install -q torch==2.1.2+cu121 --extra-index-url https://download.pytorch.org/whl/cu121\"\n",
|
| 84 |
+
" },\n",
|
| 85 |
+
" \"SageMaker Studio Lab\": {\n",
|
| 86 |
+
" \"opencv\": \"pip install -q opencv-python-headless\",\n",
|
| 87 |
+
" \"huggingface\": \"pip install -q huggingface-hub\",\n",
|
| 88 |
+
" \"conda_update\": \"conda update -q -n base conda\",\n",
|
| 89 |
+
" \"conda_aria2\": \"conda install -q -y aria2\",\n",
|
| 90 |
+
" \"conda_glib\": \"conda install -q -y glib\",\n",
|
| 91 |
+
" \"tensorflow\": \"pip install tensorflow\",\n",
|
| 92 |
+
" \"xformers\": \"pip install -q xformers==0.0.23.post1 triton==2.1.0\",\n",
|
| 93 |
+
" \"torch\": \"pip install -q torch==2.1.2+cu121 torchvision==0.16.2+cu121 torchaudio==2.1.2 --extra-index-url https://download.pytorch.org/whl/cu121\"\n",
|
| 94 |
+
" }\n",
|
| 95 |
+
" }\n",
|
| 96 |
+
"\n",
|
| 97 |
+
" # If the current environment has additional libraries, update the install_lib dictionary\n",
|
| 98 |
+
" if env in additional_libs:\n",
|
| 99 |
+
" install_lib.update(additional_libs[env])\n",
|
| 100 |
+
"\n",
|
| 101 |
+
" # Loop through libraries and execute install commands\n",
|
| 102 |
+
" for index, (package, install_cmd) in enumerate(install_lib.items(), start=1):\n",
|
| 103 |
+
" print(f\"\\r\\033[96m[{index}/{len(install_lib)}] \\033[32m>>\\033[96m Installing \\033[33m{package}\\033[96m...\\033[0m\", end='')\n",
|
| 104 |
+
" subprocess.run(install_cmd, shell=True, capture_output=True)\n",
|
| 105 |
+
"\n",
|
| 106 |
+
" # Additional manual installation steps for specific packages\n",
|
| 107 |
" with capture.capture_output() as cap:\n",
|
|
|
|
|
|
|
|
|
|
| 108 |
" !curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}\n",
|
| 109 |
" !curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl\n",
|
|
|
|
| 110 |
" !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",
|
| 111 |
+
" !wget -P /home/studio-lab-user https://huggingface.co/NagisaNao/fast_repo/resolve/main/sagemaker/FULL_DELETED_NOTEBOOK.ipynb\n",
|
| 112 |
+
" del cap\n",
|
| 113 |
"\n",
|
| 114 |
+
" clear_output()\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
"\n",
|
| 116 |
+
" # save file install lib\n",
|
| 117 |
+
" with open(flag_file, \"w\") as f:\n",
|
| 118 |
+
" f.write(\">W<'\")\n",
|
|
|
|
|
|
|
| 119 |
"\n",
|
| 120 |
+
" print(\"🍪 Библиотеки установлены!\" + \" \"*35)\n",
|
|
|
|
|
|
|
|
|
|
| 121 |
" time.sleep(2)\n",
|
| 122 |
" clear_output()\n",
|
| 123 |
"\n",
|
|
|
|
| 212 |
" else:\n",
|
| 213 |
" !{'for dir in /home/studio-lab-user/content/sdw/extensions/*/; do cd \\\"$dir\\\" && git fetch origin && git pull; done'}\n",
|
| 214 |
"\n",
|
| 215 |
+
" # My Chinese friend, you broke the images again in the latest update... >W<'\n",
|
| 216 |
+
" %cd {webui_path}/extensions/Encrypt-Image\n",
|
| 217 |
+
" !git reset --hard 376358d8854472b9ea50e9fc8800367d1ca51137 # stable commit :3\n",
|
|
|
|
|
|
|
| 218 |
" del cap\n",
|
| 219 |
" print(f\"\\r✨ {action} Завершено!\")\n",
|
| 220 |
"\n",
|
| 221 |
"\n",
|
| 222 |
"# === FIXING ERRORS ===\n",
|
| 223 |
+
"anxety_repos = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main\"\n",
|
|
|
|
| 224 |
"\n",
|
| 225 |
+
"with capture.capture_output() as cap:\n",
|
| 226 |
+
" # --- Encrypt-Image ---\n",
|
| 227 |
+
" !sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js\n",
|
| 228 |
+
"\n",
|
| 229 |
+
" # --- Additional-Networks ---\n",
|
| 230 |
+
" !wget -O {webui_path}/extensions/additional-networks/scripts/metadata_editor.py {anxety_repos}/extensions/Additional-Networks/fix/metadata_editor.py\n",
|
| 231 |
+
"\n",
|
| 232 |
+
" # --= SageMaker =--\n",
|
| 233 |
+
" if env == \"SageMaker Studio Lab\":\n",
|
| 234 |
+
" with capture.capture_output() as cap:\n",
|
| 235 |
+
" # --- SuperMerger Remove ---\n",
|
| 236 |
+
" if os.path.exists(f\"{webui_path}/extensions/supermerger\"):\n",
|
| 237 |
+
" !rm -rf {webui_path}/extensions/supermerger\n",
|
| 238 |
+
" # --- Launch (Style) ---\n",
|
| 239 |
+
" !wget -O {webui_path}/modules/styles.py {anxety_repos}/sagemaker/fixing/webui/styles.py\n",
|
| 240 |
+
"del cap\n",
|
| 241 |
"\n",
|
| 242 |
"\n",
|
| 243 |
"## Version switching\n",
|
files_cells/notebooks/ru/widgets_ru.ipynb
CHANGED
|
@@ -48,7 +48,7 @@
|
|
| 48 |
"\n",
|
| 49 |
"\n",
|
| 50 |
"# ==================== CSS JS ====================\n",
|
| 51 |
-
"# custom background images V1.
|
| 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",
|
|
@@ -57,8 +57,9 @@
|
|
| 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',
|
| 61 |
-
"parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35
|
|
|
|
| 62 |
"args = parser.parse_args()\n",
|
| 63 |
"\"\"\"---\"\"\"\n",
|
| 64 |
"url_img = args.image\n",
|
|
@@ -67,16 +68,18 @@
|
|
| 67 |
"y_img = args.y\n",
|
| 68 |
"x_img = args.x\n",
|
| 69 |
"scale_img = args.scale\n",
|
| 70 |
-
"
|
| 71 |
"\n",
|
| 72 |
-
"
|
| 73 |
-
"
|
| 74 |
-
"if env
|
| 75 |
-
"
|
| 76 |
-
"
|
| 77 |
-
"t_bg_alpha = \"1\"\n",
|
| 78 |
-
"
|
| 79 |
-
"
|
|
|
|
|
|
|
| 80 |
"\n",
|
| 81 |
"container_background = f'''\n",
|
| 82 |
"<style>\n",
|
|
@@ -94,6 +97,7 @@
|
|
| 94 |
" /* for fields */\n",
|
| 95 |
" --bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */\n",
|
| 96 |
" --bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */\n",
|
|
|
|
| 97 |
"}}\n",
|
| 98 |
"'''\n",
|
| 99 |
"\n",
|
|
@@ -220,6 +224,7 @@
|
|
| 220 |
" border-radius: 10px;\n",
|
| 221 |
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
| 222 |
" transition: all 0.3s ease-in-out;\n",
|
|
|
|
| 223 |
"}\n",
|
| 224 |
"\n",
|
| 225 |
".widget-dropdown select:focus,\n",
|
|
@@ -329,7 +334,7 @@
|
|
| 329 |
"}\n",
|
| 330 |
"\n",
|
| 331 |
"\n",
|
| 332 |
-
"/* Popup style of `
|
| 333 |
"\n",
|
| 334 |
".info {\n",
|
| 335 |
" position: absolute;\n",
|
|
@@ -593,7 +598,7 @@
|
|
| 593 |
"def save_settings():\n",
|
| 594 |
" settings = {key: globals()[f\"{key}_widget\"].value for key in settings_keys}\n",
|
| 595 |
" with open(SETTINGS_FILE, 'w') as f:\n",
|
| 596 |
-
" json.dump(settings, f)\n",
|
| 597 |
"\n",
|
| 598 |
"def load_settings():\n",
|
| 599 |
" if os.path.exists(SETTINGS_FILE):\n",
|
|
|
|
| 48 |
"\n",
|
| 49 |
"\n",
|
| 50 |
"# ==================== CSS JS ====================\n",
|
| 51 |
+
"# custom background images V1.5\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",
|
|
|
|
| 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',action='store_true', help='Removes repetitive image tiles')\n",
|
| 61 |
+
"parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')\n",
|
| 62 |
+
"parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)\n",
|
| 63 |
"args = parser.parse_args()\n",
|
| 64 |
"\"\"\"---\"\"\"\n",
|
| 65 |
"url_img = args.image\n",
|
|
|
|
| 68 |
"y_img = args.y\n",
|
| 69 |
"x_img = args.x\n",
|
| 70 |
"scale_img = args.scale\n",
|
| 71 |
+
"blur_fields = args.blur_fields\n",
|
| 72 |
"\n",
|
| 73 |
+
"## ---\n",
|
| 74 |
+
"\"\"\" WTF COLAB - WHAT THE FUCK IS THE DIFFERENCE OF 35 PIXELS!?!?!? \"\"\"\n",
|
| 75 |
+
"fix_heigh_img = \"-810px\" if env != \"Google Colab\" else \"-775px\"\n",
|
| 76 |
+
"\n",
|
| 77 |
+
"\"\"\" transperent fields \"\"\"\n",
|
| 78 |
+
"t_bg_alpha = \"1\" if not args.transparent else \"0.65\"\n",
|
| 79 |
+
"\n",
|
| 80 |
+
"\"\"\" mode img - repeats \"\"\"\n",
|
| 81 |
+
"mode_img = \"repeat\" if not args.mode else \"no-repeat\"\n",
|
| 82 |
+
"## ---\n",
|
| 83 |
"\n",
|
| 84 |
"container_background = f'''\n",
|
| 85 |
"<style>\n",
|
|
|
|
| 97 |
" /* for fields */\n",
|
| 98 |
" --bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */\n",
|
| 99 |
" --bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */\n",
|
| 100 |
+
" --bg-field-blur-level: {blur_fields}px;\n",
|
| 101 |
"}}\n",
|
| 102 |
"'''\n",
|
| 103 |
"\n",
|
|
|
|
| 224 |
" border-radius: 10px;\n",
|
| 225 |
" box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);\n",
|
| 226 |
" transition: all 0.3s ease-in-out;\n",
|
| 227 |
+
" backdrop-filter: blur(var(--bg-field-blur-level));\n",
|
| 228 |
"}\n",
|
| 229 |
"\n",
|
| 230 |
".widget-dropdown select:focus,\n",
|
|
|
|
| 334 |
"}\n",
|
| 335 |
"\n",
|
| 336 |
"\n",
|
| 337 |
+
"/* Popup style of `INFO` window */\n",
|
| 338 |
"\n",
|
| 339 |
".info {\n",
|
| 340 |
" position: absolute;\n",
|
|
|
|
| 598 |
"def save_settings():\n",
|
| 599 |
" settings = {key: globals()[f\"{key}_widget\"].value for key in settings_keys}\n",
|
| 600 |
" with open(SETTINGS_FILE, 'w') as f:\n",
|
| 601 |
+
" json.dump(settings, f, indent=2)\n",
|
| 602 |
"\n",
|
| 603 |
"def load_settings():\n",
|
| 604 |
" if os.path.exists(SETTINGS_FILE):\n",
|
files_cells/python/en/auto-cleaner_en.py
CHANGED
|
@@ -33,15 +33,6 @@ 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>
|
|
@@ -240,6 +231,15 @@ display(HTML(CSS))
|
|
| 240 |
|
| 241 |
|
| 242 |
# ================ AutoCleaner function ================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
def clean_directory(directory):
|
| 244 |
deleted_files = 0
|
| 245 |
for root, dirs, files in os.walk(directory):
|
|
@@ -251,20 +251,6 @@ def clean_directory(directory):
|
|
| 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)
|
|
@@ -272,10 +258,9 @@ def update_memory_info():
|
|
| 272 |
free = disk_space.free / (1024 ** 3)
|
| 273 |
|
| 274 |
storage_info.value = f'''
|
| 275 |
-
<div class="storage_info_AC"
|
| 276 |
'''
|
| 277 |
|
| 278 |
-
|
| 279 |
def on_execute_button_press(button):
|
| 280 |
selected_cleaners = auto_cleaner_widget.value
|
| 281 |
deleted_files_dict = {}
|
|
@@ -293,28 +278,23 @@ def on_execute_button_press(button):
|
|
| 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":
|
| 307 |
-
"Models":
|
| 308 |
-
"Vae":
|
| 309 |
-
"LoRa":
|
| 310 |
-
"ControlNet Models":
|
| 311 |
}
|
| 312 |
-
deleted_word_variants = ["Deleted", "Deleted", "Deleted"]
|
| 313 |
for key, value in deleted_files_dict.items():
|
| 314 |
-
|
| 315 |
-
|
| 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 |
|
|
|
|
| 33 |
# ----------------------------------------------
|
| 34 |
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
# ==================== CSS ====================
|
| 37 |
CSS = """
|
| 38 |
<style>
|
|
|
|
| 231 |
|
| 232 |
|
| 233 |
# ================ AutoCleaner function ================
|
| 234 |
+
directories = {
|
| 235 |
+
"Images": f"{webui_path}/outputs",
|
| 236 |
+
"Models": f"{webui_path}/models/Stable-diffusion/",
|
| 237 |
+
"Vae": f"{webui_path}/models/VAE/",
|
| 238 |
+
"LoRa": f"{webui_path}/models/Lora/",
|
| 239 |
+
"ControlNet Models": f"{webui_path}/models/ControlNet/"
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
""" functions """
|
| 243 |
def clean_directory(directory):
|
| 244 |
deleted_files = 0
|
| 245 |
for root, dirs, files in os.walk(directory):
|
|
|
|
| 251 |
deleted_files += 1
|
| 252 |
return deleted_files
|
| 253 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
def update_memory_info():
|
| 255 |
disk_space = psutil.disk_usage(os.getcwd())
|
| 256 |
total = disk_space.total / (1024 ** 3)
|
|
|
|
| 258 |
free = disk_space.free / (1024 ** 3)
|
| 259 |
|
| 260 |
storage_info.value = f'''
|
| 261 |
+
<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>
|
| 262 |
'''
|
| 263 |
|
|
|
|
| 264 |
def on_execute_button_press(button):
|
| 265 |
selected_cleaners = auto_cleaner_widget.value
|
| 266 |
deleted_files_dict = {}
|
|
|
|
| 278 |
|
| 279 |
update_memory_info()
|
| 280 |
|
|
|
|
| 281 |
def on_clear_button_press(button):
|
| 282 |
container.add_class("hide")
|
| 283 |
time.sleep(0.5)
|
| 284 |
widgets.Widget.close_all()
|
| 285 |
|
|
|
|
| 286 |
def generate_messages(deleted_files_dict):
|
| 287 |
messages = []
|
| 288 |
word_variants = {
|
| 289 |
+
"Images": "Images",
|
| 290 |
+
"Models": "Models",
|
| 291 |
+
"Vae": "Vae",
|
| 292 |
+
"LoRa": "LoRa",
|
| 293 |
+
"ControlNet Models": "ControlNet Models"
|
| 294 |
}
|
|
|
|
| 295 |
for key, value in deleted_files_dict.items():
|
| 296 |
+
object_word = word_variants.get(key)
|
| 297 |
+
messages.append(f"Deleted {value} {object_word}")
|
|
|
|
|
|
|
| 298 |
return messages
|
| 299 |
# ================ AutoCleaner function ================
|
| 300 |
|
files_cells/python/en/downloading_en.py
CHANGED
|
@@ -172,28 +172,32 @@ if latest_webui or latest_exstensions:
|
|
| 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 |
-
|
| 176 |
-
|
| 177 |
-
|
| 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 |
-
|
| 186 |
-
get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js")
|
| 187 |
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
|
| 199 |
## Version switching
|
|
|
|
| 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 |
del cap
|
| 179 |
print(f"\r✨ {action} Completed!")
|
| 180 |
|
| 181 |
|
| 182 |
# === FIXING ERRORS ===
|
| 183 |
+
anxety_repos = "https://huggingface.co/NagisaNao/fast_repo/resolve/main"
|
|
|
|
| 184 |
|
| 185 |
+
with capture.capture_output() as cap:
|
| 186 |
+
# --- Encrypt-Image ---
|
| 187 |
+
get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js")
|
| 188 |
+
|
| 189 |
+
# --- Additional-Networks ---
|
| 190 |
+
get_ipython().system('wget -O {webui_path}/extensions/additional-networks/scripts/metadata_editor.py {anxety_repos}/extensions/Additional-Networks/fix/metadata_editor.py')
|
| 191 |
+
|
| 192 |
+
# --= SageMaker =--
|
| 193 |
+
if env == "SageMaker Studio Lab":
|
| 194 |
+
with capture.capture_output() as cap:
|
| 195 |
+
# --- SuperMerger Remove ---
|
| 196 |
+
if os.path.exists(f"{webui_path}/extensions/supermerger"):
|
| 197 |
+
get_ipython().system('rm -rf {webui_path}/extensions/supermerger')
|
| 198 |
+
# --- Launch (Style) ---
|
| 199 |
+
get_ipython().system('wget -O {webui_path}/modules/styles.py {anxety_repos}/sagemaker/fixing/webui/styles.py')
|
| 200 |
+
del cap
|
| 201 |
|
| 202 |
|
| 203 |
## Version switching
|
files_cells/python/en/widgets_en.py
CHANGED
|
@@ -29,7 +29,7 @@ get_ipython().system('mkdir -p {root_path}')
|
|
| 29 |
|
| 30 |
|
| 31 |
# ==================== CSS JS ====================
|
| 32 |
-
# custom background images V1.
|
| 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='')
|
|
@@ -38,8 +38,9 @@ parser.add_argument('-b', '--blur', type=str, help='Blur level for the image', m
|
|
| 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',
|
| 42 |
-
parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35
|
|
|
|
| 43 |
args = parser.parse_args()
|
| 44 |
"""---"""
|
| 45 |
url_img = args.image
|
|
@@ -48,16 +49,18 @@ blur_img = args.blur
|
|
| 48 |
y_img = args.y
|
| 49 |
x_img = args.x
|
| 50 |
scale_img = args.scale
|
| 51 |
-
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
if env
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
t_bg_alpha = "1"
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
| 61 |
|
| 62 |
container_background = f'''
|
| 63 |
<style>
|
|
@@ -75,6 +78,7 @@ container_background = f'''
|
|
| 75 |
/* for fields */
|
| 76 |
--bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */
|
| 77 |
--bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */
|
|
|
|
| 78 |
}}
|
| 79 |
'''
|
| 80 |
|
|
@@ -201,6 +205,7 @@ a {
|
|
| 201 |
border-radius: 10px;
|
| 202 |
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
| 203 |
transition: all 0.3s ease-in-out;
|
|
|
|
| 204 |
}
|
| 205 |
|
| 206 |
.widget-dropdown select:focus,
|
|
@@ -310,7 +315,7 @@ a {
|
|
| 310 |
}
|
| 311 |
|
| 312 |
|
| 313 |
-
/* Popup style of `
|
| 314 |
|
| 315 |
.info {
|
| 316 |
position: absolute;
|
|
@@ -574,7 +579,7 @@ settings_keys = [
|
|
| 574 |
def save_settings():
|
| 575 |
settings = {key: globals()[f"{key}_widget"].value for key in settings_keys}
|
| 576 |
with open(SETTINGS_FILE, 'w') as f:
|
| 577 |
-
json.dump(settings, f)
|
| 578 |
|
| 579 |
def load_settings():
|
| 580 |
if os.path.exists(SETTINGS_FILE):
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
# ==================== CSS JS ====================
|
| 32 |
+
# custom background images V1.5
|
| 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='')
|
|
|
|
| 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',action='store_true', help='Removes repetitive image tiles')
|
| 42 |
+
parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')
|
| 43 |
+
parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)
|
| 44 |
args = parser.parse_args()
|
| 45 |
"""---"""
|
| 46 |
url_img = args.image
|
|
|
|
| 49 |
y_img = args.y
|
| 50 |
x_img = args.x
|
| 51 |
scale_img = args.scale
|
| 52 |
+
blur_fields = args.blur_fields
|
| 53 |
|
| 54 |
+
## ---
|
| 55 |
+
""" WTF COLAB - WHAT THE FUCK IS THE DIFFERENCE OF 35 PIXELS!?!?!? """
|
| 56 |
+
fix_heigh_img = "-810px" if env != "Google Colab" else "-775px"
|
| 57 |
+
|
| 58 |
+
""" transperent fields """
|
| 59 |
+
t_bg_alpha = "1" if not args.transparent else "0.65"
|
| 60 |
+
|
| 61 |
+
""" mode img - repeats """
|
| 62 |
+
mode_img = "repeat" if not args.mode else "no-repeat"
|
| 63 |
+
## ---
|
| 64 |
|
| 65 |
container_background = f'''
|
| 66 |
<style>
|
|
|
|
| 78 |
/* for fields */
|
| 79 |
--bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */
|
| 80 |
--bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */
|
| 81 |
+
--bg-field-blur-level: {blur_fields}px;
|
| 82 |
}}
|
| 83 |
'''
|
| 84 |
|
|
|
|
| 205 |
border-radius: 10px;
|
| 206 |
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
| 207 |
transition: all 0.3s ease-in-out;
|
| 208 |
+
backdrop-filter: blur(var(--bg-field-blur-level));
|
| 209 |
}
|
| 210 |
|
| 211 |
.widget-dropdown select:focus,
|
|
|
|
| 315 |
}
|
| 316 |
|
| 317 |
|
| 318 |
+
/* Popup style of `INFO` window */
|
| 319 |
|
| 320 |
.info {
|
| 321 |
position: absolute;
|
|
|
|
| 579 |
def save_settings():
|
| 580 |
settings = {key: globals()[f"{key}_widget"].value for key in settings_keys}
|
| 581 |
with open(SETTINGS_FILE, 'w') as f:
|
| 582 |
+
json.dump(settings, f, indent=2)
|
| 583 |
|
| 584 |
def load_settings():
|
| 585 |
if os.path.exists(SETTINGS_FILE):
|
files_cells/python/ru/auto-cleaner_ru.py
CHANGED
|
@@ -33,15 +33,6 @@ 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>
|
|
@@ -240,6 +231,15 @@ display(HTML(CSS_AC))
|
|
| 240 |
|
| 241 |
|
| 242 |
# ================ AutoCleaner function ================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
def clean_directory(directory):
|
| 244 |
deleted_files = 0
|
| 245 |
for root, dirs, files in os.walk(directory):
|
|
@@ -251,20 +251,6 @@ def clean_directory(directory):
|
|
| 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)
|
|
@@ -275,7 +261,6 @@ def update_memory_info():
|
|
| 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 = {}
|
|
@@ -293,28 +278,23 @@ def on_execute_button_press(button):
|
|
| 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":
|
| 309 |
-
"LoRa":
|
| 310 |
-
"ControlNet Модели":
|
| 311 |
}
|
| 312 |
-
deleted_word_variants = ["Удалена", "Удалены", "Удалено"]
|
| 313 |
for key, value in deleted_files_dict.items():
|
| 314 |
-
|
| 315 |
-
|
| 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 |
|
|
|
|
| 33 |
# ----------------------------------------------
|
| 34 |
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
# ==================== CSS ====================
|
| 37 |
CSS_AC = """
|
| 38 |
<style>
|
|
|
|
| 231 |
|
| 232 |
|
| 233 |
# ================ AutoCleaner function ================
|
| 234 |
+
directories = {
|
| 235 |
+
"Изображения": f"{webui_path}/outputs",
|
| 236 |
+
"Модели": f"{webui_path}/models/Stable-diffusion/",
|
| 237 |
+
"Vae": f"{webui_path}/models/VAE/",
|
| 238 |
+
"LoRa": f"{webui_path}/models/Lora/",
|
| 239 |
+
"ControlNet Модели": f"{webui_path}/models/ControlNet/"
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
""" functions """
|
| 243 |
def clean_directory(directory):
|
| 244 |
deleted_files = 0
|
| 245 |
for root, dirs, files in os.walk(directory):
|
|
|
|
| 251 |
deleted_files += 1
|
| 252 |
return deleted_files
|
| 253 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
def update_memory_info():
|
| 255 |
disk_space = psutil.disk_usage(os.getcwd())
|
| 256 |
total = disk_space.total / (1024 ** 3)
|
|
|
|
| 261 |
<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>
|
| 262 |
'''
|
| 263 |
|
|
|
|
| 264 |
def on_execute_button_press(button):
|
| 265 |
selected_cleaners = auto_cleaner_widget.value
|
| 266 |
deleted_files_dict = {}
|
|
|
|
| 278 |
|
| 279 |
update_memory_info()
|
| 280 |
|
|
|
|
| 281 |
def on_clear_button_press(button):
|
| 282 |
container.add_class("hide")
|
| 283 |
time.sleep(0.5)
|
| 284 |
widgets.Widget.close_all()
|
| 285 |
|
|
|
|
| 286 |
def generate_messages(deleted_files_dict):
|
| 287 |
messages = []
|
| 288 |
word_variants = {
|
| 289 |
+
"Изображения": "Изображений",
|
| 290 |
+
"Модели": "Моделей",
|
| 291 |
+
"Vae": "Vae",
|
| 292 |
+
"LoRa": "LoRa",
|
| 293 |
+
"ControlNet Модели": "ControlNet Моделей"
|
| 294 |
}
|
|
|
|
| 295 |
for key, value in deleted_files_dict.items():
|
| 296 |
+
object_word = word_variants.get(key)
|
| 297 |
+
messages.append(f"Удалено {value} {object_word}")
|
|
|
|
|
|
|
| 298 |
return messages
|
| 299 |
# ================ AutoCleaner function ================
|
| 300 |
|
files_cells/python/ru/downloading_ru.py
CHANGED
|
@@ -41,43 +41,64 @@ if env == "SageMaker Studio Lab":
|
|
| 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 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 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 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
get_ipython().system('pip install -q {torch} -U')
|
| 75 |
-
get_ipython().system('pip install -q {xformers} -U')
|
| 76 |
|
| 77 |
-
|
| 78 |
-
f.write("hey ;3")
|
| 79 |
-
del cap
|
| 80 |
-
print("\r🍪 Библиотеки установлены!" + " "*35)
|
| 81 |
time.sleep(2)
|
| 82 |
clear_output()
|
| 83 |
|
|
@@ -172,28 +193,32 @@ if latest_webui or latest_exstensions:
|
|
| 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 |
-
|
| 176 |
-
|
| 177 |
-
|
| 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 |
-
|
| 186 |
-
get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js")
|
| 187 |
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
|
| 199 |
## Version switching
|
|
|
|
| 41 |
clear_output()
|
| 42 |
|
| 43 |
|
| 44 |
+
# ================ LIBRARIES V2 ================
|
| 45 |
flag_file = f"{root_path}/libraries_installed.txt"
|
| 46 |
|
| 47 |
if not os.path.exists(flag_file):
|
| 48 |
+
print("💿 Установка библиотек, это займет какое-то время...\n")
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
install_lib = {
|
| 51 |
+
"gdown": "pip install -U gdown",
|
| 52 |
+
"aria2": "apt-get update && apt -y install aria2",
|
| 53 |
+
"localtunnel": "npm install -g localtunnel &> /dev/null",
|
| 54 |
+
"insightface": "pip install insightface",
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
# Dictionary of additional libraries specific to certain environments
|
| 58 |
+
additional_libs = {
|
| 59 |
+
"Google Colab": {
|
| 60 |
+
"xformers": "pip install xformers==0.0.25 --no-deps"
|
| 61 |
+
},
|
| 62 |
+
"Kaggle": {
|
| 63 |
+
"xformers": "pip install -q xformers==0.0.23.post1 triton==2.1.0",
|
| 64 |
+
"torch": "pip install -q torch==2.1.2+cu121 --extra-index-url https://download.pytorch.org/whl/cu121"
|
| 65 |
+
},
|
| 66 |
+
"SageMaker Studio Lab": {
|
| 67 |
+
"opencv": "pip install -q opencv-python-headless",
|
| 68 |
+
"huggingface": "pip install -q huggingface-hub",
|
| 69 |
+
"conda_update": "conda update -q -n base conda",
|
| 70 |
+
"conda_aria2": "conda install -q -y aria2",
|
| 71 |
+
"conda_glib": "conda install -q -y glib",
|
| 72 |
+
"tensorflow": "pip install tensorflow",
|
| 73 |
+
"xformers": "pip install -q xformers==0.0.23.post1 triton==2.1.0",
|
| 74 |
+
"torch": "pip install -q torch==2.1.2+cu121 torchvision==0.16.2+cu121 torchaudio==2.1.2 --extra-index-url https://download.pytorch.org/whl/cu121"
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
# If the current environment has additional libraries, update the install_lib dictionary
|
| 79 |
+
if env in additional_libs:
|
| 80 |
+
install_lib.update(additional_libs[env])
|
| 81 |
+
|
| 82 |
+
# Loop through libraries and execute install commands
|
| 83 |
+
for index, (package, install_cmd) in enumerate(install_lib.items(), start=1):
|
| 84 |
+
print(f"\r\033[96m[{index}/{len(install_lib)}] \033[32m>>\033[96m Installing \033[33m{package}\033[96m...\033[0m", end='')
|
| 85 |
+
subprocess.run(install_cmd, shell=True, capture_output=True)
|
| 86 |
+
|
| 87 |
+
# Additional manual installation steps for specific packages
|
| 88 |
with capture.capture_output() as cap:
|
|
|
|
|
|
|
|
|
|
| 89 |
get_ipython().system('curl -s -OL https://github.com/DEX-1101/sd-webui-notebook/raw/main/res/new_tunnel --output-dir {root_path}')
|
| 90 |
get_ipython().system('curl -s -Lo /usr/bin/cl https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x /usr/bin/cl')
|
|
|
|
| 91 |
get_ipython().system('curl -sLO https://github.com/openziti/zrok/releases/download/v0.4.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')
|
| 92 |
+
get_ipython().system('wget -P /home/studio-lab-user https://huggingface.co/NagisaNao/fast_repo/resolve/main/sagemaker/FULL_DELETED_NOTEBOOK.ipynb')
|
| 93 |
+
del cap
|
| 94 |
|
| 95 |
+
clear_output()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
+
# save file install lib
|
| 98 |
+
with open(flag_file, "w") as f:
|
| 99 |
+
f.write(">W<'")
|
|
|
|
|
|
|
| 100 |
|
| 101 |
+
print("🍪 Библиотеки установлены!" + " "*35)
|
|
|
|
|
|
|
|
|
|
| 102 |
time.sleep(2)
|
| 103 |
clear_output()
|
| 104 |
|
|
|
|
| 193 |
else:
|
| 194 |
get_ipython().system('{\'for dir in /home/studio-lab-user/content/sdw/extensions/*/; do cd \\"$dir\\" && git fetch origin && git pull; done\'}')
|
| 195 |
|
| 196 |
+
# My Chinese friend, you broke the images again in the latest update... >W<'
|
| 197 |
+
get_ipython().run_line_magic('cd', '{webui_path}/extensions/Encrypt-Image')
|
| 198 |
+
get_ipython().system('git reset --hard 376358d8854472b9ea50e9fc8800367d1ca51137 # stable commit :3')
|
|
|
|
|
|
|
| 199 |
del cap
|
| 200 |
print(f"\r✨ {action} Завершено!")
|
| 201 |
|
| 202 |
|
| 203 |
# === FIXING ERRORS ===
|
| 204 |
+
anxety_repos = "https://huggingface.co/NagisaNao/fast_repo/resolve/main"
|
|
|
|
| 205 |
|
| 206 |
+
with capture.capture_output() as cap:
|
| 207 |
+
# --- Encrypt-Image ---
|
| 208 |
+
get_ipython().system("sed -i '9,37d' {webui_path}/extensions/Encrypt-Image/javascript/encrypt_images_info.js")
|
| 209 |
+
|
| 210 |
+
# --- Additional-Networks ---
|
| 211 |
+
get_ipython().system('wget -O {webui_path}/extensions/additional-networks/scripts/metadata_editor.py {anxety_repos}/extensions/Additional-Networks/fix/metadata_editor.py')
|
| 212 |
+
|
| 213 |
+
# --= SageMaker =--
|
| 214 |
+
if env == "SageMaker Studio Lab":
|
| 215 |
+
with capture.capture_output() as cap:
|
| 216 |
+
# --- SuperMerger Remove ---
|
| 217 |
+
if os.path.exists(f"{webui_path}/extensions/supermerger"):
|
| 218 |
+
get_ipython().system('rm -rf {webui_path}/extensions/supermerger')
|
| 219 |
+
# --- Launch (Style) ---
|
| 220 |
+
get_ipython().system('wget -O {webui_path}/modules/styles.py {anxety_repos}/sagemaker/fixing/webui/styles.py')
|
| 221 |
+
del cap
|
| 222 |
|
| 223 |
|
| 224 |
## Version switching
|
files_cells/python/ru/widgets_ru.py
CHANGED
|
@@ -29,7 +29,7 @@ get_ipython().system('mkdir -p {root_path}')
|
|
| 29 |
|
| 30 |
|
| 31 |
# ==================== CSS JS ====================
|
| 32 |
-
# custom background images V1.
|
| 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='')
|
|
@@ -38,8 +38,9 @@ parser.add_argument('-b', '--blur', type=str, help='Blur level for the image', m
|
|
| 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',
|
| 42 |
-
parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35
|
|
|
|
| 43 |
args = parser.parse_args()
|
| 44 |
"""---"""
|
| 45 |
url_img = args.image
|
|
@@ -48,16 +49,18 @@ blur_img = args.blur
|
|
| 48 |
y_img = args.y
|
| 49 |
x_img = args.x
|
| 50 |
scale_img = args.scale
|
| 51 |
-
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
if env
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
t_bg_alpha = "1"
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
| 61 |
|
| 62 |
container_background = f'''
|
| 63 |
<style>
|
|
@@ -75,6 +78,7 @@ container_background = f'''
|
|
| 75 |
/* for fields */
|
| 76 |
--bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */
|
| 77 |
--bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */
|
|
|
|
| 78 |
}}
|
| 79 |
'''
|
| 80 |
|
|
@@ -201,6 +205,7 @@ a {
|
|
| 201 |
border-radius: 10px;
|
| 202 |
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
| 203 |
transition: all 0.3s ease-in-out;
|
|
|
|
| 204 |
}
|
| 205 |
|
| 206 |
.widget-dropdown select:focus,
|
|
@@ -310,7 +315,7 @@ a {
|
|
| 310 |
}
|
| 311 |
|
| 312 |
|
| 313 |
-
/* Popup style of `
|
| 314 |
|
| 315 |
.info {
|
| 316 |
position: absolute;
|
|
@@ -574,7 +579,7 @@ settings_keys = [
|
|
| 574 |
def save_settings():
|
| 575 |
settings = {key: globals()[f"{key}_widget"].value for key in settings_keys}
|
| 576 |
with open(SETTINGS_FILE, 'w') as f:
|
| 577 |
-
json.dump(settings, f)
|
| 578 |
|
| 579 |
def load_settings():
|
| 580 |
if os.path.exists(SETTINGS_FILE):
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
# ==================== CSS JS ====================
|
| 32 |
+
# custom background images V1.5
|
| 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='')
|
|
|
|
| 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',action='store_true', help='Removes repetitive image tiles')
|
| 42 |
+
parser.add_argument('-t', '--transparent', action='store_true', help='Makes input/selection fields 35%% more transparent')
|
| 43 |
+
parser.add_argument('-bf', '--blur-fields', type=str, help='Background blur level for input/selection fields', metavar='', default=2)
|
| 44 |
args = parser.parse_args()
|
| 45 |
"""---"""
|
| 46 |
url_img = args.image
|
|
|
|
| 49 |
y_img = args.y
|
| 50 |
x_img = args.x
|
| 51 |
scale_img = args.scale
|
| 52 |
+
blur_fields = args.blur_fields
|
| 53 |
|
| 54 |
+
## ---
|
| 55 |
+
""" WTF COLAB - WHAT THE FUCK IS THE DIFFERENCE OF 35 PIXELS!?!?!? """
|
| 56 |
+
fix_heigh_img = "-810px" if env != "Google Colab" else "-775px"
|
| 57 |
+
|
| 58 |
+
""" transperent fields """
|
| 59 |
+
t_bg_alpha = "1" if not args.transparent else "0.65"
|
| 60 |
+
|
| 61 |
+
""" mode img - repeats """
|
| 62 |
+
mode_img = "repeat" if not args.mode else "no-repeat"
|
| 63 |
+
## ---
|
| 64 |
|
| 65 |
container_background = f'''
|
| 66 |
<style>
|
|
|
|
| 78 |
/* for fields */
|
| 79 |
--bg-field-color: rgba(28, 28, 28, {t_bg_alpha}); /* -> #1c1c1c */
|
| 80 |
--bg-field-color-hover: rgba(38, 38, 38, {t_bg_alpha}); /* -> #262626; */
|
| 81 |
+
--bg-field-blur-level: {blur_fields}px;
|
| 82 |
}}
|
| 83 |
'''
|
| 84 |
|
|
|
|
| 205 |
border-radius: 10px;
|
| 206 |
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
|
| 207 |
transition: all 0.3s ease-in-out;
|
| 208 |
+
backdrop-filter: blur(var(--bg-field-blur-level));
|
| 209 |
}
|
| 210 |
|
| 211 |
.widget-dropdown select:focus,
|
|
|
|
| 315 |
}
|
| 316 |
|
| 317 |
|
| 318 |
+
/* Popup style of `INFO` window */
|
| 319 |
|
| 320 |
.info {
|
| 321 |
position: absolute;
|
|
|
|
| 579 |
def save_settings():
|
| 580 |
settings = {key: globals()[f"{key}_widget"].value for key in settings_keys}
|
| 581 |
with open(SETTINGS_FILE, 'w') as f:
|
| 582 |
+
json.dump(settings, f, indent=2)
|
| 583 |
|
| 584 |
def load_settings():
|
| 585 |
if os.path.exists(SETTINGS_FILE):
|