🐛 fixes+improvements
Browse files
files_cells/notebooks/en/downloading_en.ipynb
CHANGED
|
@@ -112,10 +112,7 @@
|
|
| 112 |
"\n",
|
| 113 |
"# =================== OTHER ====================\n",
|
| 114 |
"# Setup Timer\n",
|
| 115 |
-
"
|
| 116 |
-
" start_colab\n",
|
| 117 |
-
"except:\n",
|
| 118 |
-
" start_colab = int(time.time())-5\n",
|
| 119 |
"\n",
|
| 120 |
"# Save files temporarily\n",
|
| 121 |
"temporarily_dir = f'{root_path}/temp_dir'\n",
|
|
@@ -128,68 +125,84 @@
|
|
| 128 |
" 'models/Lora'\n",
|
| 129 |
" ]\n",
|
| 130 |
"\n",
|
| 131 |
-
" print(\"
|
|
|
|
| 132 |
" for item in items_to_copy:\n",
|
| 133 |
" src = os.path.join(src_base, item)\n",
|
| 134 |
" dst = os.path.join(dst_base, item)\n",
|
| 135 |
"\n",
|
| 136 |
-
" if os.path.
|
| 137 |
" if os.path.exists(dst):\n",
|
| 138 |
" shutil.rmtree(dst)\n",
|
|
|
|
| 139 |
" shutil.move(src, dst)\n",
|
| 140 |
-
"
|
| 141 |
-
"
|
| 142 |
-
"
|
| 143 |
-
"
|
| 144 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
"\n",
|
| 147 |
"# ================= MAIN CODE ==================\n",
|
| 148 |
-
"# WebUI switch\n",
|
| 149 |
"if os.path.exists(webui_path):\n",
|
| 150 |
" if UI != OLD_UI:\n",
|
| 151 |
" print(f'Switching the WebUI from \\033[33m{OLD_UI}\\033[0m to \\033[33m{UI}\\033[0m:\\n', end='')\n",
|
| 152 |
" copy_items_with_replace(webui_path, temporarily_dir)\n",
|
| 153 |
" shutil.rmtree(webui_path)\n",
|
| 154 |
-
"\n",
|
| 155 |
-
" # Updating the environment variable after a change\n",
|
| 156 |
" os.environ['SDW_OLD_UI'] = UI\n",
|
| 157 |
" time.sleep(2)\n",
|
| 158 |
" clear_output()\n",
|
| 159 |
"\n",
|
| 160 |
-
"# Unpacking the WebUI\n",
|
| 161 |
"if not os.path.exists(webui_path):\n",
|
| 162 |
-
"
|
| 163 |
-
" print(\"⌚ Unpacking Stable Diffusion...\" if UI != 'Forge' else \"⌚ Unpacking Stable Diffusion (Forge)...\", end='')\n",
|
| 164 |
-
" with capture.capture_output() as cap:\n",
|
| 165 |
-
" aria2_command = \"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M\"\n",
|
| 166 |
-
" url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip\" if UI != 'Forge' else \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip\"\n",
|
| 167 |
-
" !{aria2_command} {url} -o repo.zip\n",
|
| 168 |
-
"\n",
|
| 169 |
-
" !unzip -q -o repo.zip -d {webui_path}\n",
|
| 170 |
-
" !rm -rf repo.zip\n",
|
| 171 |
-
"\n",
|
| 172 |
-
" # other\n",
|
| 173 |
-
" %cd {root_path}\n",
|
| 174 |
-
" os.environ[\"SAFETENSORS_FAST_GPU\"]='1'\n",
|
| 175 |
-
" os.environ[\"CUDA_MODULE_LOADING\"]=\"LAZY\"\n",
|
| 176 |
-
" os.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"3\"\n",
|
| 177 |
-
" os.environ[\"PYTHONWARNINGS\"] = \"ignore\"\n",
|
| 178 |
-
"\n",
|
| 179 |
-
" !echo -n {start_colab} > {webui_path}/static/colabTimer.txt\n",
|
| 180 |
-
" del cap\n",
|
| 181 |
-
" install_time = timedelta(seconds=time.time()-start_install)\n",
|
| 182 |
-
" 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",
|
| 183 |
-
"\n",
|
| 184 |
-
" # Move temporary files\n",
|
| 185 |
-
" if os.path.exists(temporarily_dir):\n",
|
| 186 |
-
" copy_items_with_replace(temporarily_dir, webui_path)\n",
|
| 187 |
-
" shutil.rmtree(temporarily_dir)\n",
|
| 188 |
"else:\n",
|
| 189 |
" print(\"🚀 All unpacked... Skip. ⚡\")\n",
|
| 190 |
-
"
|
| 191 |
-
"
|
| 192 |
-
" print(f\"⌚️ You have been conducting this session for - \\033[33m{
|
| 193 |
"\n",
|
| 194 |
"\n",
|
| 195 |
"## Changes extensions and WebUi\n",
|
|
@@ -332,8 +345,8 @@
|
|
| 332 |
" def get_download_url(data, model_type):\n",
|
| 333 |
" if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):\n",
|
| 334 |
" return data['files'][0]['downloadUrl']\n",
|
| 335 |
-
"
|
| 336 |
-
"
|
| 337 |
"\n",
|
| 338 |
" download_url = get_download_url(data, model_type)\n",
|
| 339 |
"\n",
|
|
|
|
| 112 |
"\n",
|
| 113 |
"# =================== OTHER ====================\n",
|
| 114 |
"# Setup Timer\n",
|
| 115 |
+
"start_colab = globals().get('start_colab', int(time.time()) - 5)\n",
|
|
|
|
|
|
|
|
|
|
| 116 |
"\n",
|
| 117 |
"# Save files temporarily\n",
|
| 118 |
"temporarily_dir = f'{root_path}/temp_dir'\n",
|
|
|
|
| 125 |
" 'models/Lora'\n",
|
| 126 |
" ]\n",
|
| 127 |
"\n",
|
| 128 |
+
" print(\"Moving files...\", end='')\n",
|
| 129 |
+
" time.sleep(1)\n",
|
| 130 |
" for item in items_to_copy:\n",
|
| 131 |
" src = os.path.join(src_base, item)\n",
|
| 132 |
" dst = os.path.join(dst_base, item)\n",
|
| 133 |
"\n",
|
| 134 |
+
" if os.path.exists(src):\n",
|
| 135 |
" if os.path.exists(dst):\n",
|
| 136 |
" shutil.rmtree(dst)\n",
|
| 137 |
+
" os.makedirs(os.path.dirname(dst), exist_ok=True)\n",
|
| 138 |
" shutil.move(src, dst)\n",
|
| 139 |
+
" print(\"\\r🔥 Files moved!\" + \" \"*15)\n",
|
| 140 |
+
"\n",
|
| 141 |
+
"def configure_environment():\n",
|
| 142 |
+
" os.chdir(root_path)\n",
|
| 143 |
+
" os.environ.update({\n",
|
| 144 |
+
" \"SAFETENSORS_FAST_GPU\": '1',\n",
|
| 145 |
+
" \"CUDA_MODULE_LOADING\": \"LAZY\",\n",
|
| 146 |
+
" \"TF_CPP_MIN_LOG_LEVEL\": \"3\",\n",
|
| 147 |
+
" \"PYTHONWARNINGS\": \"ignore\"\n",
|
| 148 |
+
" })\n",
|
| 149 |
+
"\n",
|
| 150 |
+
"def download_and_unpack(url, dest_path):\n",
|
| 151 |
+
" aria2_args = \"--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --stderr=true -c -x16 -s16 -k1M -j5\"\n",
|
| 152 |
+
" get_ipython().system(f\"aria2c {aria2_args} '{url}' -o repo.zip\")\n",
|
| 153 |
+
" get_ipython().system(f'unzip -q -o repo.zip -d {dest_path}')\n",
|
| 154 |
+
" get_ipython().system('rm -rf repo.zip')\n",
|
| 155 |
+
"\n",
|
| 156 |
+
"def handle_colab_timer(webui_path, timer_colab):\n",
|
| 157 |
+
" timer_file_path = os.path.join(webui_path, 'static', 'colabTimer.txt')\n",
|
| 158 |
+
" if not os.path.exists(timer_file_path):\n",
|
| 159 |
+
" with open(timer_file_path, 'w') as timer_file:\n",
|
| 160 |
+
" timer_file.write(str(timer_colab))\n",
|
| 161 |
+
" else:\n",
|
| 162 |
+
" with open(timer_file_path, 'r') as timer_file:\n",
|
| 163 |
+
" timer_colab = float(timer_file.read())\n",
|
| 164 |
+
" return timer_colab\n",
|
| 165 |
+
"\n",
|
| 166 |
+
"def unpack_webui():\n",
|
| 167 |
+
" start_install = time.time()\n",
|
| 168 |
+
" print(f\"⌚ Unpacking Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...\", end='')\n",
|
| 169 |
+
"\n",
|
| 170 |
+
" with capture.capture_output() as cap:\n",
|
| 171 |
+
" download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip\"\n",
|
| 172 |
+
" if UI == 'Forge':\n",
|
| 173 |
+
" download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip\"\n",
|
| 174 |
+
"\n",
|
| 175 |
+
" download_and_unpack(download_url, webui_path)\n",
|
| 176 |
+
" configure_environment()\n",
|
| 177 |
"\n",
|
| 178 |
+
" get_ipython().system(f'echo -n {start_colab} > {webui_path}/static/colabTimer.txt')\n",
|
| 179 |
+
" del cap\n",
|
| 180 |
+
"\n",
|
| 181 |
+
" install_time = time.time() - start_install\n",
|
| 182 |
+
" minutes, seconds = divmod(int(install_time), 60)\n",
|
| 183 |
+
" print(f\"\\r🚀 Unpacking complete! For {minutes:02}:{seconds:02} ⚡\", flush=True)\n",
|
| 184 |
+
"\n",
|
| 185 |
+
" if os.path.exists(temporarily_dir):\n",
|
| 186 |
+
" copy_items_with_replace(temporarily_dir, webui_path)\n",
|
| 187 |
+
" shutil.rmtree(temporarily_dir)\n",
|
| 188 |
"\n",
|
| 189 |
"# ================= MAIN CODE ==================\n",
|
|
|
|
| 190 |
"if os.path.exists(webui_path):\n",
|
| 191 |
" if UI != OLD_UI:\n",
|
| 192 |
" print(f'Switching the WebUI from \\033[33m{OLD_UI}\\033[0m to \\033[33m{UI}\\033[0m:\\n', end='')\n",
|
| 193 |
" copy_items_with_replace(webui_path, temporarily_dir)\n",
|
| 194 |
" shutil.rmtree(webui_path)\n",
|
|
|
|
|
|
|
| 195 |
" os.environ['SDW_OLD_UI'] = UI\n",
|
| 196 |
" time.sleep(2)\n",
|
| 197 |
" clear_output()\n",
|
| 198 |
"\n",
|
|
|
|
| 199 |
"if not os.path.exists(webui_path):\n",
|
| 200 |
+
" unpack_webui()\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
"else:\n",
|
| 202 |
" print(\"🚀 All unpacked... Skip. ⚡\")\n",
|
| 203 |
+
" timer_colab = handle_colab_timer(webui_path, start_colab)\n",
|
| 204 |
+
" elapsed_time = str(timedelta(seconds=time.time() - timer_colab)).split('.')[0]\n",
|
| 205 |
+
" print(f\"⌚️ You have been conducting this session for - \\033[33m{elapsed_time}\\033[0m\")\n",
|
| 206 |
"\n",
|
| 207 |
"\n",
|
| 208 |
"## Changes extensions and WebUi\n",
|
|
|
|
| 345 |
" def get_download_url(data, model_type):\n",
|
| 346 |
" if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):\n",
|
| 347 |
" return data['files'][0]['downloadUrl']\n",
|
| 348 |
+
"\n",
|
| 349 |
+
" return data['files'][1]['downloadUrl'] if 'type' in url else data['files'][0]['downloadUrl']\n",
|
| 350 |
"\n",
|
| 351 |
" download_url = get_download_url(data, model_type)\n",
|
| 352 |
"\n",
|
files_cells/notebooks/ru/downloading_ru.ipynb
CHANGED
|
@@ -112,10 +112,7 @@
|
|
| 112 |
"\n",
|
| 113 |
"# =================== OTHER ====================\n",
|
| 114 |
"# Setup Timer\n",
|
| 115 |
-
"
|
| 116 |
-
" start_colab\n",
|
| 117 |
-
"except:\n",
|
| 118 |
-
" start_colab = int(time.time())-5\n",
|
| 119 |
"\n",
|
| 120 |
"# Save files temporarily\n",
|
| 121 |
"temporarily_dir = f'{root_path}/temp_dir'\n",
|
|
@@ -128,74 +125,90 @@
|
|
| 128 |
" 'models/Lora'\n",
|
| 129 |
" ]\n",
|
| 130 |
"\n",
|
| 131 |
-
" print(\"
|
|
|
|
| 132 |
" for item in items_to_copy:\n",
|
| 133 |
" src = os.path.join(src_base, item)\n",
|
| 134 |
" dst = os.path.join(dst_base, item)\n",
|
| 135 |
"\n",
|
| 136 |
-
" if os.path.
|
| 137 |
" if os.path.exists(dst):\n",
|
| 138 |
" shutil.rmtree(dst)\n",
|
|
|
|
| 139 |
" shutil.move(src, dst)\n",
|
| 140 |
-
"
|
| 141 |
-
"
|
| 142 |
-
"
|
| 143 |
-
"
|
| 144 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
"\n",
|
| 147 |
"# ================= MAIN CODE ==================\n",
|
| 148 |
-
"# WebUI switch\n",
|
| 149 |
"if os.path.exists(webui_path):\n",
|
| 150 |
" if UI != OLD_UI:\n",
|
| 151 |
" print(f'Переключение веб-интерфейса с \\033[33m{OLD_UI}\\033[0m на \\033[33m{UI}\\033[0m:\\n', end='')\n",
|
| 152 |
" copy_items_with_replace(webui_path, temporarily_dir)\n",
|
| 153 |
" shutil.rmtree(webui_path)\n",
|
| 154 |
-
"\n",
|
| 155 |
-
" # Updating the environment variable after a change\n",
|
| 156 |
" os.environ['SDW_OLD_UI'] = UI\n",
|
| 157 |
" time.sleep(2)\n",
|
| 158 |
" clear_output()\n",
|
| 159 |
"\n",
|
| 160 |
-
"# Unpacking the WebUI\n",
|
| 161 |
"if not os.path.exists(webui_path):\n",
|
| 162 |
-
"
|
| 163 |
-
" print(\"⌚ Распаковка Stable Diffusion...\" if UI != 'Forge' else \"⌚ Распаковка Stable Diffusion (Forge)...\", end='')\n",
|
| 164 |
-
" with capture.capture_output() as cap:\n",
|
| 165 |
-
" aria2_command = \"aria2c --console-log-level=error -c -x 16 -s 16 -k 1M\"\n",
|
| 166 |
-
" url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip\" if UI != 'Forge' else \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip\"\n",
|
| 167 |
-
" !{aria2_command} {url} -o repo.zip\n",
|
| 168 |
-
"\n",
|
| 169 |
-
" !unzip -q -o repo.zip -d {webui_path}\n",
|
| 170 |
-
" !rm -rf repo.zip\n",
|
| 171 |
-
"\n",
|
| 172 |
-
" # other\n",
|
| 173 |
-
" get_ipython().run_line_magic('cd', '{root_path}')\n",
|
| 174 |
-
" os.environ[\"SAFETENSORS_FAST_GPU\"]='1'\n",
|
| 175 |
-
" os.environ[\"CUDA_MODULE_LOADING\"]=\"LAZY\"\n",
|
| 176 |
-
" os.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"3\"\n",
|
| 177 |
-
" os.environ[\"PYTHONWARNINGS\"] = \"ignore\"\n",
|
| 178 |
-
"\n",
|
| 179 |
-
" !echo -n {start_colab} > {webui_path}/static/colabTimer.txt\n",
|
| 180 |
-
" del cap\n",
|
| 181 |
-
" install_time = timedelta(seconds=time.time()-start_install)\n",
|
| 182 |
-
" print(\"\\r🚀 Распаковка Завершена! За\",\"%02d:%02d:%02d ⚡\\n\" % (install_time.seconds / 3600, (install_time.seconds / 60) % 60, install_time.seconds % 60), end='', flush=True)\n",
|
| 183 |
-
"\n",
|
| 184 |
-
" # Move temporary files\n",
|
| 185 |
-
" if os.path.exists(temporarily_dir):\n",
|
| 186 |
-
" copy_items_with_replace(temporarily_dir, webui_path)\n",
|
| 187 |
-
" shutil.rmtree(temporarily_dir)\n",
|
| 188 |
"else:\n",
|
| 189 |
-
" print(\"🚀 Все распакованно... Пропуск.
|
| 190 |
-
"
|
| 191 |
-
"
|
| 192 |
-
" print(f\"⌚️ Вы проводите эту сессию в течение - \\033[33m{
|
| 193 |
"\n",
|
| 194 |
"\n",
|
| 195 |
"## Changes extensions and WebUi\n",
|
| 196 |
"if latest_webui or latest_exstensions:\n",
|
| 197 |
-
" action = \"
|
| 198 |
-
" print(f\"⌚️ {action}...\", end='', flush=True)\n",
|
| 199 |
" with capture.capture_output() as cap:\n",
|
| 200 |
" !git config --global user.email \"you@example.com\"\n",
|
| 201 |
" !git config --global user.name \"Your Name\"\n",
|
|
@@ -210,7 +223,7 @@
|
|
| 210 |
" if latest_exstensions:\n",
|
| 211 |
" !{'for dir in ' + webui_path + '/extensions/*/; do cd \\\"$dir\\\" && git reset --hard && git pull; done'}\n",
|
| 212 |
" del cap\n",
|
| 213 |
-
" print(f\"\\r✨ {action} Завершено!\")\n",
|
| 214 |
"\n",
|
| 215 |
"\n",
|
| 216 |
"# === FIXING EXTENSIONS ===\n",
|
|
@@ -332,8 +345,8 @@
|
|
| 332 |
" def get_download_url(data, model_type):\n",
|
| 333 |
" if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):\n",
|
| 334 |
" return data['files'][0]['downloadUrl']\n",
|
| 335 |
-
"
|
| 336 |
-
"
|
| 337 |
"\n",
|
| 338 |
" download_url = get_download_url(data, model_type)\n",
|
| 339 |
"\n",
|
|
|
|
| 112 |
"\n",
|
| 113 |
"# =================== OTHER ====================\n",
|
| 114 |
"# Setup Timer\n",
|
| 115 |
+
"start_colab = globals().get('start_colab', int(time.time()) - 5)\n",
|
|
|
|
|
|
|
|
|
|
| 116 |
"\n",
|
| 117 |
"# Save files temporarily\n",
|
| 118 |
"temporarily_dir = f'{root_path}/temp_dir'\n",
|
|
|
|
| 125 |
" 'models/Lora'\n",
|
| 126 |
" ]\n",
|
| 127 |
"\n",
|
| 128 |
+
" print(\"Перемещение файлов...\", end='')\n",
|
| 129 |
+
" time.sleep(1)\n",
|
| 130 |
" for item in items_to_copy:\n",
|
| 131 |
" src = os.path.join(src_base, item)\n",
|
| 132 |
" dst = os.path.join(dst_base, item)\n",
|
| 133 |
"\n",
|
| 134 |
+
" if os.path.exists(src):\n",
|
| 135 |
" if os.path.exists(dst):\n",
|
| 136 |
" shutil.rmtree(dst)\n",
|
| 137 |
+
" os.makedirs(os.path.dirname(dst), exist_ok=True)\n",
|
| 138 |
" shutil.move(src, dst)\n",
|
| 139 |
+
" print(\"\\r🔥 Файлы перемещены!\" + \" \"*15)\n",
|
| 140 |
+
"\n",
|
| 141 |
+
"def configure_environment():\n",
|
| 142 |
+
" os.chdir(root_path)\n",
|
| 143 |
+
" os.environ.update({\n",
|
| 144 |
+
" \"SAFETENSORS_FAST_GPU\": '1',\n",
|
| 145 |
+
" \"CUDA_MODULE_LOADING\": \"LAZY\",\n",
|
| 146 |
+
" \"TF_CPP_MIN_LOG_LEVEL\": \"3\",\n",
|
| 147 |
+
" \"PYTHONWARNINGS\": \"ignore\"\n",
|
| 148 |
+
" })\n",
|
| 149 |
+
"\n",
|
| 150 |
+
"def download_and_unpack(url, dest_path):\n",
|
| 151 |
+
" aria2_args = \"--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --stderr=true -c -x16 -s16 -k1M -j5\"\n",
|
| 152 |
+
" get_ipython().system(f\"aria2c {aria2_args} '{url}' -o repo.zip\")\n",
|
| 153 |
+
" get_ipython().system(f'unzip -q -o repo.zip -d {dest_path}')\n",
|
| 154 |
+
" get_ipython().system('rm -rf repo.zip')\n",
|
| 155 |
+
"\n",
|
| 156 |
+
"def handle_colab_timer(webui_path, timer_colab):\n",
|
| 157 |
+
" timer_file_path = os.path.join(webui_path, 'static', 'colabTimer.txt')\n",
|
| 158 |
+
" if not os.path.exists(timer_file_path):\n",
|
| 159 |
+
" with open(timer_file_path, 'w') as timer_file:\n",
|
| 160 |
+
" timer_file.write(str(timer_colab))\n",
|
| 161 |
+
" else:\n",
|
| 162 |
+
" with open(timer_file_path, 'r') as timer_file:\n",
|
| 163 |
+
" timer_colab = float(timer_file.read())\n",
|
| 164 |
+
" return timer_colab\n",
|
| 165 |
+
"\n",
|
| 166 |
+
"def unpack_webui():\n",
|
| 167 |
+
" start_install = time.time()\n",
|
| 168 |
+
" print(f\"⌚ Распаковка Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...\", end='')\n",
|
| 169 |
+
"\n",
|
| 170 |
+
" with capture.capture_output() as cap:\n",
|
| 171 |
+
" download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip\"\n",
|
| 172 |
+
" if UI == 'Forge':\n",
|
| 173 |
+
" download_url = \"https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip\"\n",
|
| 174 |
+
"\n",
|
| 175 |
+
" download_and_unpack(download_url, webui_path)\n",
|
| 176 |
+
" configure_environment()\n",
|
| 177 |
"\n",
|
| 178 |
+
" get_ipython().system(f'echo -n {start_colab} > {webui_path}/static/colabTimer.txt')\n",
|
| 179 |
+
" del cap\n",
|
| 180 |
+
"\n",
|
| 181 |
+
" install_time = time.time() - start_install\n",
|
| 182 |
+
" minutes, seconds = divmod(int(install_time), 60)\n",
|
| 183 |
+
" print(f\"\\r🚀 Распаковка Завершена! За {minutes:02}:{seconds:02} ⚡\", flush=True)\n",
|
| 184 |
+
"\n",
|
| 185 |
+
" if os.path.exists(temporarily_dir):\n",
|
| 186 |
+
" copy_items_with_replace(temporarily_dir, webui_path)\n",
|
| 187 |
+
" shutil.rmtree(temporarily_dir)\n",
|
| 188 |
"\n",
|
| 189 |
"# ================= MAIN CODE ==================\n",
|
|
|
|
| 190 |
"if os.path.exists(webui_path):\n",
|
| 191 |
" if UI != OLD_UI:\n",
|
| 192 |
" print(f'Переключение веб-интерфейса с \\033[33m{OLD_UI}\\033[0m на \\033[33m{UI}\\033[0m:\\n', end='')\n",
|
| 193 |
" copy_items_with_replace(webui_path, temporarily_dir)\n",
|
| 194 |
" shutil.rmtree(webui_path)\n",
|
|
|
|
|
|
|
| 195 |
" os.environ['SDW_OLD_UI'] = UI\n",
|
| 196 |
" time.sleep(2)\n",
|
| 197 |
" clear_output()\n",
|
| 198 |
"\n",
|
|
|
|
| 199 |
"if not os.path.exists(webui_path):\n",
|
| 200 |
+
" unpack_webui()\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
"else:\n",
|
| 202 |
+
" print(\"🚀 Все распакованно... Пропуск. ⚡\")\n",
|
| 203 |
+
" timer_colab = handle_colab_timer(webui_path, start_colab)\n",
|
| 204 |
+
" elapsed_time = str(timedelta(seconds=time.time() - timer_colab)).split('.')[0]\n",
|
| 205 |
+
" print(f\"⌚️ Вы проводите эту сессию в течение - \\033[33m{elapsed_time}\\033[0m\")\n",
|
| 206 |
"\n",
|
| 207 |
"\n",
|
| 208 |
"## Changes extensions and WebUi\n",
|
| 209 |
"if latest_webui or latest_exstensions:\n",
|
| 210 |
+
" action = \"WebUI и Расширений\" if latest_webui and latest_exstensions else (\"WebUI\" if latest_webui else \"Расширений\")\n",
|
| 211 |
+
" print(f\"⌚️ Обновление {action}...\", end='', flush=True)\n",
|
| 212 |
" with capture.capture_output() as cap:\n",
|
| 213 |
" !git config --global user.email \"you@example.com\"\n",
|
| 214 |
" !git config --global user.name \"Your Name\"\n",
|
|
|
|
| 223 |
" if latest_exstensions:\n",
|
| 224 |
" !{'for dir in ' + webui_path + '/extensions/*/; do cd \\\"$dir\\\" && git reset --hard && git pull; done'}\n",
|
| 225 |
" del cap\n",
|
| 226 |
+
" print(f\"\\r✨ Обновление {action} Завершено!\")\n",
|
| 227 |
"\n",
|
| 228 |
"\n",
|
| 229 |
"# === FIXING EXTENSIONS ===\n",
|
|
|
|
| 345 |
" def get_download_url(data, model_type):\n",
|
| 346 |
" if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):\n",
|
| 347 |
" return data['files'][0]['downloadUrl']\n",
|
| 348 |
+
"\n",
|
| 349 |
+
" return data['files'][1]['downloadUrl'] if 'type' in url else data['files'][0]['downloadUrl']\n",
|
| 350 |
"\n",
|
| 351 |
" download_url = get_download_url(data, model_type)\n",
|
| 352 |
"\n",
|
files_cells/python/en/downloading_en.py
CHANGED
|
@@ -102,10 +102,7 @@ locals().update({key: settings.get(key) for key in VARIABLES})
|
|
| 102 |
|
| 103 |
# =================== OTHER ====================
|
| 104 |
# Setup Timer
|
| 105 |
-
|
| 106 |
-
start_colab
|
| 107 |
-
except:
|
| 108 |
-
start_colab = int(time.time())-5
|
| 109 |
|
| 110 |
# Save files temporarily
|
| 111 |
temporarily_dir = f'{root_path}/temp_dir'
|
|
@@ -118,68 +115,84 @@ def copy_items_with_replace(src_base, dst_base):
|
|
| 118 |
'models/Lora'
|
| 119 |
]
|
| 120 |
|
| 121 |
-
print("
|
|
|
|
| 122 |
for item in items_to_copy:
|
| 123 |
src = os.path.join(src_base, item)
|
| 124 |
dst = os.path.join(dst_base, item)
|
| 125 |
|
| 126 |
-
if os.path.
|
| 127 |
if os.path.exists(dst):
|
| 128 |
shutil.rmtree(dst)
|
|
|
|
| 129 |
shutil.move(src, dst)
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
# ================= MAIN CODE ==================
|
| 138 |
-
# WebUI switch
|
| 139 |
if os.path.exists(webui_path):
|
| 140 |
if UI != OLD_UI:
|
| 141 |
print(f'Switching the WebUI from \033[33m{OLD_UI}\033[0m to \033[33m{UI}\033[0m:\n', end='')
|
| 142 |
copy_items_with_replace(webui_path, temporarily_dir)
|
| 143 |
shutil.rmtree(webui_path)
|
| 144 |
-
|
| 145 |
-
# Updating the environment variable after a change
|
| 146 |
os.environ['SDW_OLD_UI'] = UI
|
| 147 |
time.sleep(2)
|
| 148 |
clear_output()
|
| 149 |
|
| 150 |
-
# Unpacking the WebUI
|
| 151 |
if not os.path.exists(webui_path):
|
| 152 |
-
|
| 153 |
-
print("⌚ Unpacking Stable Diffusion..." if UI != 'Forge' else "⌚ Unpacking Stable Diffusion (Forge)...", end='')
|
| 154 |
-
with capture.capture_output() as cap:
|
| 155 |
-
aria2_command = "aria2c --console-log-level=error -c -x 16 -s 16 -k 1M"
|
| 156 |
-
url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip" if UI != 'Forge' else "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip"
|
| 157 |
-
get_ipython().system('{aria2_command} {url} -o repo.zip')
|
| 158 |
-
|
| 159 |
-
get_ipython().system('unzip -q -o repo.zip -d {webui_path}')
|
| 160 |
-
get_ipython().system('rm -rf repo.zip')
|
| 161 |
-
|
| 162 |
-
# other
|
| 163 |
-
get_ipython().run_line_magic('cd', '{root_path}')
|
| 164 |
-
os.environ["SAFETENSORS_FAST_GPU"]='1'
|
| 165 |
-
os.environ["CUDA_MODULE_LOADING"]="LAZY"
|
| 166 |
-
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
|
| 167 |
-
os.environ["PYTHONWARNINGS"] = "ignore"
|
| 168 |
-
|
| 169 |
-
get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
| 170 |
-
del cap
|
| 171 |
-
install_time = timedelta(seconds=time.time()-start_install)
|
| 172 |
-
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)
|
| 173 |
-
|
| 174 |
-
# Move temporary files
|
| 175 |
-
if os.path.exists(temporarily_dir):
|
| 176 |
-
copy_items_with_replace(temporarily_dir, webui_path)
|
| 177 |
-
shutil.rmtree(temporarily_dir)
|
| 178 |
else:
|
| 179 |
print("🚀 All unpacked... Skip. ⚡")
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
print(f"⌚️ You have been conducting this session for - \033[33m{
|
| 183 |
|
| 184 |
|
| 185 |
## Changes extensions and WebUi
|
|
@@ -322,8 +335,8 @@ def CivitAi_API(url, file_name=None):
|
|
| 322 |
def get_download_url(data, model_type):
|
| 323 |
if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):
|
| 324 |
return data['files'][0]['downloadUrl']
|
| 325 |
-
|
| 326 |
-
|
| 327 |
|
| 328 |
download_url = get_download_url(data, model_type)
|
| 329 |
|
|
|
|
| 102 |
|
| 103 |
# =================== OTHER ====================
|
| 104 |
# Setup Timer
|
| 105 |
+
start_colab = globals().get('start_colab', int(time.time()) - 5)
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
# Save files temporarily
|
| 108 |
temporarily_dir = f'{root_path}/temp_dir'
|
|
|
|
| 115 |
'models/Lora'
|
| 116 |
]
|
| 117 |
|
| 118 |
+
print("Moving files...", end='')
|
| 119 |
+
time.sleep(1)
|
| 120 |
for item in items_to_copy:
|
| 121 |
src = os.path.join(src_base, item)
|
| 122 |
dst = os.path.join(dst_base, item)
|
| 123 |
|
| 124 |
+
if os.path.exists(src):
|
| 125 |
if os.path.exists(dst):
|
| 126 |
shutil.rmtree(dst)
|
| 127 |
+
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
| 128 |
shutil.move(src, dst)
|
| 129 |
+
print("\r🔥 Files moved!" + " "*15)
|
| 130 |
+
|
| 131 |
+
def configure_environment():
|
| 132 |
+
os.chdir(root_path)
|
| 133 |
+
os.environ.update({
|
| 134 |
+
"SAFETENSORS_FAST_GPU": '1',
|
| 135 |
+
"CUDA_MODULE_LOADING": "LAZY",
|
| 136 |
+
"TF_CPP_MIN_LOG_LEVEL": "3",
|
| 137 |
+
"PYTHONWARNINGS": "ignore"
|
| 138 |
+
})
|
| 139 |
+
|
| 140 |
+
def download_and_unpack(url, dest_path):
|
| 141 |
+
aria2_args = "--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --stderr=true -c -x16 -s16 -k1M -j5"
|
| 142 |
+
get_ipython().system(f"aria2c {aria2_args} '{url}' -o repo.zip")
|
| 143 |
+
get_ipython().system(f'unzip -q -o repo.zip -d {dest_path}')
|
| 144 |
+
get_ipython().system('rm -rf repo.zip')
|
| 145 |
+
|
| 146 |
+
def handle_colab_timer(webui_path, timer_colab):
|
| 147 |
+
timer_file_path = os.path.join(webui_path, 'static', 'colabTimer.txt')
|
| 148 |
+
if not os.path.exists(timer_file_path):
|
| 149 |
+
with open(timer_file_path, 'w') as timer_file:
|
| 150 |
+
timer_file.write(str(timer_colab))
|
| 151 |
+
else:
|
| 152 |
+
with open(timer_file_path, 'r') as timer_file:
|
| 153 |
+
timer_colab = float(timer_file.read())
|
| 154 |
+
return timer_colab
|
| 155 |
+
|
| 156 |
+
def unpack_webui():
|
| 157 |
+
start_install = time.time()
|
| 158 |
+
print(f"⌚ Unpacking Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...", end='')
|
| 159 |
+
|
| 160 |
+
with capture.capture_output() as cap:
|
| 161 |
+
download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip"
|
| 162 |
+
if UI == 'Forge':
|
| 163 |
+
download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip"
|
| 164 |
+
|
| 165 |
+
download_and_unpack(download_url, webui_path)
|
| 166 |
+
configure_environment()
|
| 167 |
|
| 168 |
+
get_ipython().system(f'echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
| 169 |
+
del cap
|
| 170 |
+
|
| 171 |
+
install_time = time.time() - start_install
|
| 172 |
+
minutes, seconds = divmod(int(install_time), 60)
|
| 173 |
+
print(f"\r🚀 Unpacking complete! For {minutes:02}:{seconds:02} ⚡", flush=True)
|
| 174 |
+
|
| 175 |
+
if os.path.exists(temporarily_dir):
|
| 176 |
+
copy_items_with_replace(temporarily_dir, webui_path)
|
| 177 |
+
shutil.rmtree(temporarily_dir)
|
| 178 |
|
| 179 |
# ================= MAIN CODE ==================
|
|
|
|
| 180 |
if os.path.exists(webui_path):
|
| 181 |
if UI != OLD_UI:
|
| 182 |
print(f'Switching the WebUI from \033[33m{OLD_UI}\033[0m to \033[33m{UI}\033[0m:\n', end='')
|
| 183 |
copy_items_with_replace(webui_path, temporarily_dir)
|
| 184 |
shutil.rmtree(webui_path)
|
|
|
|
|
|
|
| 185 |
os.environ['SDW_OLD_UI'] = UI
|
| 186 |
time.sleep(2)
|
| 187 |
clear_output()
|
| 188 |
|
|
|
|
| 189 |
if not os.path.exists(webui_path):
|
| 190 |
+
unpack_webui()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
else:
|
| 192 |
print("🚀 All unpacked... Skip. ⚡")
|
| 193 |
+
timer_colab = handle_colab_timer(webui_path, start_colab)
|
| 194 |
+
elapsed_time = str(timedelta(seconds=time.time() - timer_colab)).split('.')[0]
|
| 195 |
+
print(f"⌚️ You have been conducting this session for - \033[33m{elapsed_time}\033[0m")
|
| 196 |
|
| 197 |
|
| 198 |
## Changes extensions and WebUi
|
|
|
|
| 335 |
def get_download_url(data, model_type):
|
| 336 |
if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):
|
| 337 |
return data['files'][0]['downloadUrl']
|
| 338 |
+
|
| 339 |
+
return data['files'][1]['downloadUrl'] if 'type' in url else data['files'][0]['downloadUrl']
|
| 340 |
|
| 341 |
download_url = get_download_url(data, model_type)
|
| 342 |
|
files_cells/python/ru/downloading_ru.py
CHANGED
|
@@ -102,10 +102,7 @@ locals().update({key: settings.get(key) for key in VARIABLES})
|
|
| 102 |
|
| 103 |
# =================== OTHER ====================
|
| 104 |
# Setup Timer
|
| 105 |
-
|
| 106 |
-
start_colab
|
| 107 |
-
except:
|
| 108 |
-
start_colab = int(time.time())-5
|
| 109 |
|
| 110 |
# Save files temporarily
|
| 111 |
temporarily_dir = f'{root_path}/temp_dir'
|
|
@@ -118,74 +115,90 @@ def copy_items_with_replace(src_base, dst_base):
|
|
| 118 |
'models/Lora'
|
| 119 |
]
|
| 120 |
|
| 121 |
-
print("
|
|
|
|
| 122 |
for item in items_to_copy:
|
| 123 |
src = os.path.join(src_base, item)
|
| 124 |
dst = os.path.join(dst_base, item)
|
| 125 |
|
| 126 |
-
if os.path.
|
| 127 |
if os.path.exists(dst):
|
| 128 |
shutil.rmtree(dst)
|
|
|
|
| 129 |
shutil.move(src, dst)
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
# ================= MAIN CODE ==================
|
| 138 |
-
# WebUI switch
|
| 139 |
if os.path.exists(webui_path):
|
| 140 |
if UI != OLD_UI:
|
| 141 |
print(f'Переключение веб-интерфейса с \033[33m{OLD_UI}\033[0m на \033[33m{UI}\033[0m:\n', end='')
|
| 142 |
copy_items_with_replace(webui_path, temporarily_dir)
|
| 143 |
shutil.rmtree(webui_path)
|
| 144 |
-
|
| 145 |
-
# Updating the environment variable after a change
|
| 146 |
os.environ['SDW_OLD_UI'] = UI
|
| 147 |
time.sleep(2)
|
| 148 |
clear_output()
|
| 149 |
|
| 150 |
-
# Unpacking the WebUI
|
| 151 |
if not os.path.exists(webui_path):
|
| 152 |
-
|
| 153 |
-
print("⌚ Распаковка Stable Diffusion..." if UI != 'Forge' else "⌚ Распаковка Stable Diffusion (Forge)...", end='')
|
| 154 |
-
with capture.capture_output() as cap:
|
| 155 |
-
aria2_command = "aria2c --console-log-level=error -c -x 16 -s 16 -k 1M"
|
| 156 |
-
url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip" if UI != 'Forge' else "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip"
|
| 157 |
-
get_ipython().system('{aria2_command} {url} -o repo.zip')
|
| 158 |
-
|
| 159 |
-
get_ipython().system('unzip -q -o repo.zip -d {webui_path}')
|
| 160 |
-
get_ipython().system('rm -rf repo.zip')
|
| 161 |
-
|
| 162 |
-
# other
|
| 163 |
-
get_ipython().run_line_magic('cd', '{root_path}')
|
| 164 |
-
os.environ["SAFETENSORS_FAST_GPU"]='1'
|
| 165 |
-
os.environ["CUDA_MODULE_LOADING"]="LAZY"
|
| 166 |
-
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
|
| 167 |
-
os.environ["PYTHONWARNINGS"] = "ignore"
|
| 168 |
-
|
| 169 |
-
get_ipython().system('echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
| 170 |
-
del cap
|
| 171 |
-
install_time = timedelta(seconds=time.time()-start_install)
|
| 172 |
-
print("\r🚀 Распаковка Завершена! За","%02d:%02d:%02d ⚡\n" % (install_time.seconds / 3600, (install_time.seconds / 60) % 60, install_time.seconds % 60), end='', flush=True)
|
| 173 |
-
|
| 174 |
-
# Move temporary files
|
| 175 |
-
if os.path.exists(temporarily_dir):
|
| 176 |
-
copy_items_with_replace(temporarily_dir, webui_path)
|
| 177 |
-
shutil.rmtree(temporarily_dir)
|
| 178 |
else:
|
| 179 |
-
print("🚀 Все распакованно... Пропуск.
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
print(f"⌚️ Вы проводите эту сессию в течение - \033[33m{
|
| 183 |
|
| 184 |
|
| 185 |
## Changes extensions and WebUi
|
| 186 |
if latest_webui or latest_exstensions:
|
| 187 |
-
action = "
|
| 188 |
-
print(f"⌚️ {action}...", end='', flush=True)
|
| 189 |
with capture.capture_output() as cap:
|
| 190 |
get_ipython().system('git config --global user.email "you@example.com"')
|
| 191 |
get_ipython().system('git config --global user.name "Your Name"')
|
|
@@ -200,7 +213,7 @@ if latest_webui or latest_exstensions:
|
|
| 200 |
if latest_exstensions:
|
| 201 |
get_ipython().system('{\'for dir in \' + webui_path + \'/extensions/*/; do cd \\"$dir\\" && git reset --hard && git pull; done\'}')
|
| 202 |
del cap
|
| 203 |
-
print(f"\r✨ {action} Завершено!")
|
| 204 |
|
| 205 |
|
| 206 |
# === FIXING EXTENSIONS ===
|
|
@@ -322,8 +335,8 @@ def CivitAi_API(url, file_name=None):
|
|
| 322 |
def get_download_url(data, model_type):
|
| 323 |
if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):
|
| 324 |
return data['files'][0]['downloadUrl']
|
| 325 |
-
|
| 326 |
-
|
| 327 |
|
| 328 |
download_url = get_download_url(data, model_type)
|
| 329 |
|
|
|
|
| 102 |
|
| 103 |
# =================== OTHER ====================
|
| 104 |
# Setup Timer
|
| 105 |
+
start_colab = globals().get('start_colab', int(time.time()) - 5)
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
# Save files temporarily
|
| 108 |
temporarily_dir = f'{root_path}/temp_dir'
|
|
|
|
| 115 |
'models/Lora'
|
| 116 |
]
|
| 117 |
|
| 118 |
+
print("Перемещение файлов...", end='')
|
| 119 |
+
time.sleep(1)
|
| 120 |
for item in items_to_copy:
|
| 121 |
src = os.path.join(src_base, item)
|
| 122 |
dst = os.path.join(dst_base, item)
|
| 123 |
|
| 124 |
+
if os.path.exists(src):
|
| 125 |
if os.path.exists(dst):
|
| 126 |
shutil.rmtree(dst)
|
| 127 |
+
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
| 128 |
shutil.move(src, dst)
|
| 129 |
+
print("\r🔥 Файлы перемещены!" + " "*15)
|
| 130 |
+
|
| 131 |
+
def configure_environment():
|
| 132 |
+
os.chdir(root_path)
|
| 133 |
+
os.environ.update({
|
| 134 |
+
"SAFETENSORS_FAST_GPU": '1',
|
| 135 |
+
"CUDA_MODULE_LOADING": "LAZY",
|
| 136 |
+
"TF_CPP_MIN_LOG_LEVEL": "3",
|
| 137 |
+
"PYTHONWARNINGS": "ignore"
|
| 138 |
+
})
|
| 139 |
+
|
| 140 |
+
def download_and_unpack(url, dest_path):
|
| 141 |
+
aria2_args = "--optimize-concurrent-downloads --console-log-level=error --summary-interval=10 --stderr=true -c -x16 -s16 -k1M -j5"
|
| 142 |
+
get_ipython().system(f"aria2c {aria2_args} '{url}' -o repo.zip")
|
| 143 |
+
get_ipython().system(f'unzip -q -o repo.zip -d {dest_path}')
|
| 144 |
+
get_ipython().system('rm -rf repo.zip')
|
| 145 |
+
|
| 146 |
+
def handle_colab_timer(webui_path, timer_colab):
|
| 147 |
+
timer_file_path = os.path.join(webui_path, 'static', 'colabTimer.txt')
|
| 148 |
+
if not os.path.exists(timer_file_path):
|
| 149 |
+
with open(timer_file_path, 'w') as timer_file:
|
| 150 |
+
timer_file.write(str(timer_colab))
|
| 151 |
+
else:
|
| 152 |
+
with open(timer_file_path, 'r') as timer_file:
|
| 153 |
+
timer_colab = float(timer_file.read())
|
| 154 |
+
return timer_colab
|
| 155 |
+
|
| 156 |
+
def unpack_webui():
|
| 157 |
+
start_install = time.time()
|
| 158 |
+
print(f"⌚ Распаковка Stable Diffusion{' (Forge)' if UI == 'Forge' else ''}...", end='')
|
| 159 |
+
|
| 160 |
+
with capture.capture_output() as cap:
|
| 161 |
+
download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO.zip"
|
| 162 |
+
if UI == 'Forge':
|
| 163 |
+
download_url = "https://huggingface.co/NagisaNao/fast_repo/resolve/main/FULL_REPO_forge.zip"
|
| 164 |
+
|
| 165 |
+
download_and_unpack(download_url, webui_path)
|
| 166 |
+
configure_environment()
|
| 167 |
|
| 168 |
+
get_ipython().system(f'echo -n {start_colab} > {webui_path}/static/colabTimer.txt')
|
| 169 |
+
del cap
|
| 170 |
+
|
| 171 |
+
install_time = time.time() - start_install
|
| 172 |
+
minutes, seconds = divmod(int(install_time), 60)
|
| 173 |
+
print(f"\r🚀 Распаковка Завершена! За {minutes:02}:{seconds:02} ⚡", flush=True)
|
| 174 |
+
|
| 175 |
+
if os.path.exists(temporarily_dir):
|
| 176 |
+
copy_items_with_replace(temporarily_dir, webui_path)
|
| 177 |
+
shutil.rmtree(temporarily_dir)
|
| 178 |
|
| 179 |
# ================= MAIN CODE ==================
|
|
|
|
| 180 |
if os.path.exists(webui_path):
|
| 181 |
if UI != OLD_UI:
|
| 182 |
print(f'Переключение веб-интерфейса с \033[33m{OLD_UI}\033[0m на \033[33m{UI}\033[0m:\n', end='')
|
| 183 |
copy_items_with_replace(webui_path, temporarily_dir)
|
| 184 |
shutil.rmtree(webui_path)
|
|
|
|
|
|
|
| 185 |
os.environ['SDW_OLD_UI'] = UI
|
| 186 |
time.sleep(2)
|
| 187 |
clear_output()
|
| 188 |
|
|
|
|
| 189 |
if not os.path.exists(webui_path):
|
| 190 |
+
unpack_webui()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
else:
|
| 192 |
+
print("🚀 Все распакованно... Пропуск. ⚡")
|
| 193 |
+
timer_colab = handle_colab_timer(webui_path, start_colab)
|
| 194 |
+
elapsed_time = str(timedelta(seconds=time.time() - timer_colab)).split('.')[0]
|
| 195 |
+
print(f"⌚️ Вы проводите эту сессию в течение - \033[33m{elapsed_time}\033[0m")
|
| 196 |
|
| 197 |
|
| 198 |
## Changes extensions and WebUi
|
| 199 |
if latest_webui or latest_exstensions:
|
| 200 |
+
action = "WebUI и Расширений" if latest_webui and latest_exstensions else ("WebUI" if latest_webui else "Расширений")
|
| 201 |
+
print(f"⌚️ Обновление {action}...", end='', flush=True)
|
| 202 |
with capture.capture_output() as cap:
|
| 203 |
get_ipython().system('git config --global user.email "you@example.com"')
|
| 204 |
get_ipython().system('git config --global user.name "Your Name"')
|
|
|
|
| 213 |
if latest_exstensions:
|
| 214 |
get_ipython().system('{\'for dir in \' + webui_path + \'/extensions/*/; do cd \\"$dir\\" && git reset --hard && git pull; done\'}')
|
| 215 |
del cap
|
| 216 |
+
print(f"\r✨ Обновление {action} Завершено!")
|
| 217 |
|
| 218 |
|
| 219 |
# === FIXING EXTENSIONS ===
|
|
|
|
| 335 |
def get_download_url(data, model_type):
|
| 336 |
if any(t.lower() in model_type.lower() for t in SUPPORT_TYPES):
|
| 337 |
return data['files'][0]['downloadUrl']
|
| 338 |
+
|
| 339 |
+
return data['files'][1]['downloadUrl'] if 'type' in url else data['files'][0]['downloadUrl']
|
| 340 |
|
| 341 |
download_url = get_download_url(data, model_type)
|
| 342 |
|